Problem

ACS is hogging all of the good command options. How can I use the command options I want?

Solution

What you want to do in this case is process the options before you give them to the Python client code. This is easily done, since any unknown options that are given to the option parser are returned in the args list. To allow the logging configuration to work, you need to add the program name, sys.argv[0], to that list. Also, you must ensure that the edited sys.argv is used.

The example below overloads the '-m' option.


#! /usr/bin/env python
# Proof that ACS shadows a command line option "-m".
# SimpleClient imports BaseClient
# Base Client imports ACSCorba where the "bad" function is executed.
#
# ACSCorba implements the getManager() function which calls
# getManagerCorbaloc() where the command line options
# "-managerReference" and "-m" are checked.

import optparse
import sys

parser = optparse.OptionParser()
parser.add_option("-m", "--max", dest="maxDist", default = 4.0,
type="float",
help="How far out to search [arcmin]. Default: %default arcmin.")

(options, args) = parser.parse_args()

# Need to add the program name back for the logger
sys.argv = [sys.argv[0]] + args

# This import triggers the creation of a _Client object.
# Moving it here will pick up the edited sys.argv
# rather than the original.
from Acspy.Clients.SimpleClient import PySimpleClient

simpleClient = PySimpleClient.getInstance("Bar")

print "Value of option maxDist = %f" % options.maxDist

simpleClient.disconnect()

### end of example

You get what you want, '-m' working as expected. As an added bonus, -managerReference is still available if needed.