text stringlengths 0 828 |
|---|
help += '\nSee \'%s help COMMAND\' for help and information on a command' % self.parser.prog |
return help" |
1645,"def _print(self, helpstr, file=None): |
"""""". |
"""""" |
if file is None: |
file = sys.stdout |
encoding = self._get_encoding(file) |
file.write(helpstr.encode(encoding, ""replace""))" |
1646,"def run(self): |
"""""" |
Run the multiopt parser |
"""""" |
self.parser = MultioptOptionParser( |
usage=""%prog <command> [options] [args]"", |
prog=self.clsname, |
version=self.version, |
option_list=self.global_options, |
description=self.desc_short, |
commands=self.command_set, |
epilog=self.footer |
) |
try: |
self.options, self.args = self.parser.parse_args(self.argv) |
except Exception, e: |
print str(e) |
pass |
if len(self.args) < 1: |
self.parser.print_lax_help() |
return 2 |
self.command = self.args.pop(0) |
showHelp = False |
if self.command == 'help': |
if len(self.args) < 1: |
self.parser.print_lax_help() |
return 2 |
else: |
self.command = self.args.pop() |
showHelp = True |
if self.command not in self.valid_commands: |
self.parser.print_cmd_error(self.command) |
return 2 |
self.command_set[self.command].set_cmdname(self.command) |
subcmd_parser = self.command_set[self.command].get_parser(self.clsname, self.version, self.global_options) |
subcmd_options, subcmd_args = subcmd_parser.parse_args(self.args) |
if showHelp: |
subcmd_parser.print_help_long() |
return 1 |
try: |
self.command_set[self.command].func(subcmd_options, *subcmd_args) |
except (CommandError, TypeError), e: |
# self.parser.print_exec_error(self.command, str(e)) |
subcmd_parser.print_exec_error(self.command, str(e)) |
print |
# @TODO show command help |
# self.parser.print_lax_help() |
return 2 |
return 1" |
1647,"def list(self, community=None, hostfilter=None, host=None): |
"""""" |
Returns a list of SNMP information for a community, hostfilter or host |
:param snmpstring: A specific SNMP string to list |
:param hostfilter: Valid hostfilter or None |
:param host: t_hosts.id or t_hosts.f_ipaddr |
:return: [ [ record_id, ipaddr, hostname, community, access, version ] ... ] |
"""""" |
return self.send.snmp_list(community, hostfilter, host)" |
1648,"def add(self, host=None, f_community=None, f_access=None, f_version=None): |
"""""" |
Add an SNMP community string to a host |
:param host: t_hosts.id or t_hosts.f_ipaddr |
:param f_community: Community string to add |
:param f_access: READ or WRITE |
:param f_version: v1, v2c or v3 |
:return: (True/False, t_snmp.id/Error string) |
"""""" |
return self.send.snmp_add(host, f_community, f_access, f_version)" |
1649,"def delete_collection(db_name, collection_name, host='localhost', port=27017): |
""""""Almost exclusively for testing."""""" |
client = MongoClient(""mongodb://%s:%d"" % (host, port)) |
client[db_name].drop_collection(collection_name)" |
1650,"def ensure_table(self, cls): |
""""""Required functionality."""""" |
coll_name = cls.get_table_name() |
try: |
db = self.mongo_client.get_default_database() |
db.create_collection(coll_name) |
except CollectionInvalid: |
pass # Expected if collection already exists |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.