Python optparse.OptionParser.__init__() Examples

The following are 10 code examples of optparse.OptionParser.__init__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module optparse.OptionParser , or try the search function .
Example #1
Source File: opt.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, usage, default_section, config_file = None):
        """This is an option parser that reads defaults from a config file.
           It also allows specification of types for each option (unlike our mess
           that is mainline BitTorrent), and is only a slight extension on the
           classes provided in the Python standard libraries (unlike the
           wheel reinvention in mainline).

           @param usage: usage string for this application.
           @param default_section: section in the config file containing configuration
             for this service.  This is a default that can be overriden for
             individual options by passing section as a kwarg to add_option.
        """
        self._default_section = default_section
        OptionParser.__init__(self,usage)
        RawConfigParser.__init__(self)
        if config_file:
            self.read(config_file) 
Example #2
Source File: opt.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, usage, default_section, config_file = None):
        """This is an option parser that reads defaults from a config file.
           It also allows specification of types for each option (unlike our mess
           that is mainline BitTorrent), and is only a slight extension on the
           classes provided in the Python standard libraries (unlike the
           wheel reinvention in mainline).

           @param usage: usage string for this application.
           @param default_section: section in the config file containing configuration
             for this service.  This is a default that can be overriden for
             individual options by passing section as a kwarg to add_option.
        """
        self._default_section = default_section
        OptionParser.__init__(self,usage)
        RawConfigParser.__init__(self)
        if config_file:
            self.read(config_file) 
Example #3
Source File: cbcmd.py    From CIRTKit with MIT License 5 votes vote down vote up
def __init__(self, hr):
        self.hr = hr 
Example #4
Source File: cbcmd.py    From CIRTKit with MIT License 5 votes vote down vote up
def __init__(self, usage=''):
        OptionParser.__init__(self, add_help_option=False, usage=usage)

        self.add_option('-h', '--help', action='store_true', help='Display this help message.') 
Example #5
Source File: cbcmd.py    From CIRTKit with MIT License 5 votes vote down vote up
def __init__(self, url, token, httpLog=None, verbose=False):
        cmd.Cmd.__init__(self)

        # global variables
        # apply regardless of session state
        self.token = token
        self.url = url
        self.verbose = verbose
        if httpLog is None:
            self.logfile = open('integrations/carbonblack/http_cblr.log', "a+")
        else:
            self.logfile = None

        # apply only if a session is attached
        self.session = None
        self.cwd = None
        self.keepaliveThread = None
        self.keepaliveEvent = None
        self.keepaliveSec = 0

        # we filter out stale sessions so that
        # we don't constantly display them to the user
        # when we start we'll grab the sessions and
        # store any "closed" sessions.
        self.stale_sessions = []
        sess = self._session_list(hideStale=False)
        for s in sess:
            if s['status'] == 'close' or s['status'] == 'timeout':
                self.stale_sessions.append(s['id']) 
Example #6
Source File: config.py    From landscape-client with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, unsaved_options=None):
        OptionParser.__init__(self, unsaved_options) 
Example #7
Source File: config.py    From landscape-client with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self._set_options = {}
        self._command_line_args = []
        self._command_line_options = {}
        self._config_filename = None
        self._config_file_options = {}
        self._parser = self.make_parser()
        self._command_line_defaults = self._parser.defaults.copy()
        # We don't want them mixed with explicitly given options,
        # otherwise we can't define the precedence properly.
        self._parser.defaults.clear() 
Example #8
Source File: cli.py    From apprise with MIT License 4 votes vote down vote up
def __init__(self):
		OptionParser.__init__(self, version="%%prog %s" % __version__)

		group = OptionGroup(self, "Network Options")
		group.add_option("-H", "--host",
			dest="host", default=config.get('gntp', 'hostname'),
			help="Specify a hostname to which to send a remote notification. [%default]")
		group.add_option("--port",
			dest="port", default=config.getint('gntp', 'port'), type="int",
			help="port to listen on [%default]")
		group.add_option("-P", "--password",
			dest='password', default=config.get('gntp', 'password'),
			help="Network password")
		self.add_option_group(group)

		group = OptionGroup(self, "Notification Options")
		group.add_option("-n", "--name",
			dest="app", default='Python GNTP Test Client',
			help="Set the name of the application [%default]")
		group.add_option("-s", "--sticky",
			dest='sticky', default=False, action="store_true",
			help="Make the notification sticky [%default]")
		group.add_option("--image",
			dest="icon", default=None,
			help="Icon for notification (URL or /path/to/file)")
		group.add_option("-m", "--message",
			dest="message", default=None,
			help="Sets the message instead of using stdin")
		group.add_option("-p", "--priority",
			dest="priority", default=0, type="int",
			help="-2 to 2 [%default]")
		group.add_option("-d", "--identifier",
			dest="identifier",
			help="Identifier for coalescing")
		group.add_option("-t", "--title",
			dest="title", default=None,
			help="Set the title of the notification [%default]")
		group.add_option("-N", "--notification",
			dest="name", default='Notification',
			help="Set the notification name [%default]")
		group.add_option("--callback",
			dest="callback",
			help="URL callback")
		self.add_option_group(group)

		# Extra Options
		self.add_option('-v', '--verbose',
			dest='verbose', default=0, action='count',
			help="Verbosity levels") 
Example #9
Source File: cli.py    From bazarr with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
		OptionParser.__init__(self, version="%%prog %s" % __version__)

		group = OptionGroup(self, "Network Options")
		group.add_option("-H", "--host",
			dest="host", default=config.get('gntp', 'hostname'),
			help="Specify a hostname to which to send a remote notification. [%default]")
		group.add_option("--port",
			dest="port", default=config.getint('gntp', 'port'), type="int",
			help="port to listen on [%default]")
		group.add_option("-P", "--password",
			dest='password', default=config.get('gntp', 'password'),
			help="Network password")
		self.add_option_group(group)

		group = OptionGroup(self, "Notification Options")
		group.add_option("-n", "--name",
			dest="app", default='Python GNTP Test Client',
			help="Set the name of the application [%default]")
		group.add_option("-s", "--sticky",
			dest='sticky', default=False, action="store_true",
			help="Make the notification sticky [%default]")
		group.add_option("--image",
			dest="icon", default=None,
			help="Icon for notification (URL or /path/to/file)")
		group.add_option("-m", "--message",
			dest="message", default=None,
			help="Sets the message instead of using stdin")
		group.add_option("-p", "--priority",
			dest="priority", default=0, type="int",
			help="-2 to 2 [%default]")
		group.add_option("-d", "--identifier",
			dest="identifier",
			help="Identifier for coalescing")
		group.add_option("-t", "--title",
			dest="title", default=None,
			help="Set the title of the notification [%default]")
		group.add_option("-N", "--notification",
			dest="name", default='Notification',
			help="Set the notification name [%default]")
		group.add_option("--callback",
			dest="callback",
			help="URL callback")
		self.add_option_group(group)

		# Extra Options
		self.add_option('-v', '--verbose',
			dest='verbose', default=0, action='count',
			help="Verbosity levels") 
Example #10
Source File: cli.py    From Tautulli with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
		OptionParser.__init__(self, version="%%prog %s" % __version__)

		group = OptionGroup(self, "Network Options")
		group.add_option("-H", "--host",
			dest="host", default=config.get('gntp', 'hostname'),
			help="Specify a hostname to which to send a remote notification. [%default]")
		group.add_option("--port",
			dest="port", default=config.getint('gntp', 'port'), type="int",
			help="port to listen on [%default]")
		group.add_option("-P", "--password",
			dest='password', default=config.get('gntp', 'password'),
			help="Network password")
		self.add_option_group(group)

		group = OptionGroup(self, "Notification Options")
		group.add_option("-n", "--name",
			dest="app", default='Python GNTP Test Client',
			help="Set the name of the application [%default]")
		group.add_option("-s", "--sticky",
			dest='sticky', default=False, action="store_true",
			help="Make the notification sticky [%default]")
		group.add_option("--image",
			dest="icon", default=None,
			help="Icon for notification (URL or /path/to/file)")
		group.add_option("-m", "--message",
			dest="message", default=None,
			help="Sets the message instead of using stdin")
		group.add_option("-p", "--priority",
			dest="priority", default=0, type="int",
			help="-2 to 2 [%default]")
		group.add_option("-d", "--identifier",
			dest="identifier",
			help="Identifier for coalescing")
		group.add_option("-t", "--title",
			dest="title", default=None,
			help="Set the title of the notification [%default]")
		group.add_option("-N", "--notification",
			dest="name", default='Notification',
			help="Set the notification name [%default]")
		group.add_option("--callback",
			dest="callback",
			help="URL callback")
		self.add_option_group(group)

		# Extra Options
		self.add_option('-v', '--verbose',
			dest='verbose', default=0, action='count',
			help="Verbosity levels")