本文整理汇总了Python中cmd2.Cmd.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Cmd.__init__方法的具体用法?Python Cmd.__init__怎么用?Python Cmd.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmd2.Cmd
的用法示例。
在下文中一共展示了Cmd.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, verbose=False):
Cmd.__init__(self)
self.pp = pprint.PrettyPrinter(indent=4)
try:
self.conn = boto.connect_dynamodb()
except Exception as e:
self.conn = None
print e
print "Cannot connect to dynamodb - Check your credentials in ~/.boto or use the 'login' command"
# by default readline thinks - and other characters are word delimiters :(
if readline:
readline.set_completer_delims(re.sub('[-~]', '', readline.get_completer_delims()))
path = os.path.join(os.environ.get('HOME', ''), HISTORY_FILE)
self.history_file = os.path.abspath(path)
else:
self.history_file = None
self.tables = []
self.table = None
self.consistent = False
self.consumed = False
self.verbose = verbose
self.next_key = None
self.schema = {}
if verbose:
self._onchange_verbose(None, verbose)
示例2: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self):
Cmd.__init__(self)
mixins.bootstrap.BootstrapMixin.__init__(self)
self._load_config()
if 'url' in self.config and self.config['url']:
self._init_stacks()
self._validate_auth()
示例3: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self):
Cmd.__init__(self)
try:
import readline
readline.set_completer_delims(' \t\n"') # initially it was ' \t\n`[email protected]#$^&*()=+[{]}\\|;:\'",<>?', but I dont want to break on too many
except:
pass
示例4: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, namefile):
Cmd.__init__(self)
self.last = []
self.last.append([])
self.prompt = bcolors.PROMPT + "ForPCAP >>> " + bcolors.ENDC
self.loadPcap(namefile)
self.cmd = ""
示例5: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, logical_device_id, get_stub):
Cmd.__init__(self)
self.get_stub = get_stub
self.logical_device_id = logical_device_id
self.prompt = '(' + self.colorize(
self.colorize('logical device {}'.format(logical_device_id), 'red'),
'bold') + ') '
示例6: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, session_obj):
Cmd.__init__(self)
self.my_session = session_obj
self.supported_namespaces = ['poortego', 'cmd2']
self.namespace = 'poortego'
self.no_namespace_commands = ['help', 'welcome', 'namespace', 'exit']
self.get_names_addendum = [] # list of additional class methods not returned from python dir() at runtime
self.prompt = self.my_session.my_conf.conf_settings['poortego_prompt'] + ' '
示例7: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user")
self.username = kwargs.pop("username")
self.passwd = kwargs.pop("passwd")
self.api_auth = HTTPBasicAuth(self.username, self.passwd)
self.site = Site.objects.get_current()
self.prompt = "Schemanizer(%s)> " % (self.username)
Cmd.__init__(self, *args, **kwargs)
示例8: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, device_id, get_stub):
Cmd.__init__(self)
self.get_stub = get_stub
self.device_id = device_id
self.prompt = '(' + self.colorize(
self.colorize('device {}'.format(device_id), 'red'), 'bold') + ') '
self.pm_config_last = None
self.pm_config_dirty = False
示例9: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self):
Cmd.__init__(self)
self.cli_parser = argparse.ArgumentParser()
subparsers = self.cli_parser.add_subparsers(help='internal commands')
publish_parser = subparsers.add_parser('publish', help='publish')
publish_parser.add_argument('--to', dest="to", metavar='PATH', type=str,
help='acoustic model directory', required=True)
示例10: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, **kwargs):
Cmd.__init__(self, **kwargs)
self.prompt = 'BES> '
#self.do_conf(None)
self.BES_ROOT_SERVER = None
self.BES_USER_NAME = None
self.BES_PASSWORD = None
self.bes_conn = None
示例11: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, parent):
Cmd.__init__(self)
self.parent = parent
self.prompt = self.parent.prompt[:-2] + "find:: "
self.machines = []
self.project = ""
self.locdata_dirs = []
self.project_dirs = []
self.record = self.parent.record
示例12: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self):
package = kolala.actions
for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
module = loader.find_module(name).load_module(name)
if getattr(module, 'main', None) is not None:
setattr(self, 'do_' + name, module.main)
if getattr(module, 'help', None) is not None:
setattr(self, 'help_' + name, module.help)
Cmd.__init__(self)
示例13: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, files, apk):
Binja.__init__(self)
self.t = Terminal()
self.logger = Logger()
self.files = files
self.apk = apk
self.libs = list()
self.rpc = None
self.target_library = None
self._init_binja()
示例14: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, silent, user, passwd):
self.base_cmds = ['exec', 'help', 'history','manual', 'quit', 'use', 'contexts', 'script']
base_cmd2 = ['li', 'load', 'pause', 'py', 'run', 'save', 'shortcuts', 'set', 'show', 'historysession']
self.base_cmds += base_cmd2
self._locals = {}
self._globals = {}
self.user = user
self.passwd = ""
self.passwdtype = "ldappass"
userCred = FGCredential(self.passwdtype,passwd)
if not self.check_simpleauth(userCred):
sys.exit()
#Load Config
self._conf = fgShellConf()
#Setup log
self._log = fgLog(self._conf.getLogFile(), self._conf.getLogLevel(), "FGShell", False)
self._log.debug("\nReading Configuration file from " + self._conf.getConfigFile() + "\n")
Cmd.__init__(self)
fgShellUtils.__init__(self)
#Context
self.env = ["repo", "hadoop", "image", "rain", ""]
self.text = {'image': 'Image Management',
'repo':'Image Repository',
'rain':'FG Dynamic Provisioning',
'hadoop':'Apache Hadoop'}
self._use = ""
self._requirements = []
self._contextOn = [] # initialized contexts
#Help
self._docHelp = []
self._undocHelp = []
self._specdocHelp = []
self.getDocUndoc("")
self.prompt = "fg> "
self.silent = silent
if self.silent:
self.intro = ""
else:
self.intro = self.loadBanner()
##Load History
self.loadhist("no argument needed")
示例15: __init__
# 需要导入模块: from cmd2 import Cmd [as 别名]
# 或者: from cmd2.Cmd import __init__ [as 别名]
def __init__(self, port, debug):
Cmd.__init__(self)
if readline:
path = os.path.join(os.environ.get('HOME', ''), HISTORY_FILE)
self.history_file = os.path.abspath(path)
else:
self.history_file = None
self.debug = debug
self.port = port
self.init_search()