Example #1
0
File: cli.py Project: ksunden/h5cli
 def __init__(self):
     Cmd.shortcuts.update({'!': 'bang', '$': 'shell'})
     Cmd.__init__(self)
     self.abbrev = True
     self.prompt = '[] > '
     self.explorer = None
     self.dir_stack = list()
Example #2
0
 def __init__(self, url_root='http://localhost'):
     Cmd.__init__(self)
     self.allow_cli_args = False
     self._format_url_root(url_root)
     self.resource = ''
     self._set_prompt()
     self.response = None
Example #3
0
 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') + ') '
 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') + ') '
Example #5
0
 def __init__(self):
     Cmd.__init__(self)
     try:
         import readline
         readline.set_completer_delims(' \t\n"') # initially it was ' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?', but I dont want to break on too many
     except:
         pass
Example #6
0
    def __init__(self):
        """The class initializer"""

        Cmd.__init__(self, startup_script=config.STARTUP_SCRIPT)

        self.aliases.update({'exit': 'quit'})
        self.hidden_commands.extend(
            ['load', 'pyscript', 'set', 'shortcuts', 'alias', 'unalias', 'py'])

        self.current_victim = None
        self.mqtt_client = None
        self.current_scan = None

        self.t = Terminal()

        self.base_prompt = get_prompt(self)
        self.prompt = self.base_prompt

        categorize((
            BaseMixin.do_edit,
            BaseMixin.do_help,
            BaseMixin.do_history,
            BaseMixin.do_quit,
            BaseMixin.do_shell,
        ), BaseMixin.CMD_CAT_GENERAL)
Example #7
0
    def __init__(self, file_path):
        Cmd.__init__(self)
        self.prompt = 'saam > '

        self.shortcuts.remove(('@', 'load'))
        self.shortcuts.append(('@', 'adb_cmd'))
        self.shortcuts.remove(('@@', '_relative_load'))
        self.shortcuts.append(('$', 'adb_shell_cmd'))
        self.shortcuts.append(('qc', 'quit_and_clean'))

        self.apk_path = file_path
        self.apk = APK(self.apk_path)
        self.apk_out = os.path.basename(file_path) + ".out"
        self.smali_files = None
        self.smali_dir = None
        self.adb = None
        self.smali_method_descs = []
        self.java_files = []

        vsmali_action = CmdLineApp.vsmali_parser.add_argument(
            'sfile', help='smali file path')
        setattr(vsmali_action, argparse_completer.ACTION_ARG_CHOICES,
                ('delimiter_complete', {
                    'delimiter': '/',
                    'match_against': self.smali_method_descs
                }))

        vjava_action = CmdLineApp.vjava_parser.add_argument(
            'jfile', help='java file path')
        setattr(vjava_action, argparse_completer.ACTION_ARG_CHOICES,
                ('delimiter_complete', {
                    'delimiter': '/',
                    'match_against': self.java_files
                }))
 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()
Example #9
0
    def use_module(self,line):
        self.active_module = line.split()[1]
        self.active_payload = self.active_device = None
        # clear all settables
        for param_type in self.current_parameters:
                for x in self.current_parameters[param_type]:
                        Cmd.settable.pop(x)
        if len(self.modules[self.active_module].payload_actions)>0:
                self.current_parameters = {"module":["payload"], "device":[], "payload":[]}
                if "payload" not in Cmd.settable:
                        Cmd.settable.append("payload")
                #initialize parameters and payload
                if getattr(self.modules[self.active_module], "payload", None) is None:
                        self.modules[self.active_module].payload=""
                        self.modules[self.active_module].payload_custom=True
                self.payload = self.modules[self.active_module].payload
        else:
                self.current_parameters = {"module":[], "device":[], "payload":[]}

        for name,p in self.modules[self.active_module].parameters.iteritems():
                if "value" not in p:
                        p["value"]=p["default"]
                setattr(self,name,p["value"])
                self.current_parameters["module"].append(name)
                Cmd.settable.append(name)
        if not self.modules[self.active_module].payload_custom:
                self.use_payload("payload "+self.modules[self.active_module].loaded_payload)
        self.prompt = Cmd().colorize("HID [","green")+ \
                      Cmd().colorize(self.active_module,"red")+ \
                      "("+\
                      ( Cmd().colorize("custom","blue") if self.modules[self.active_module].payload_custom else Cmd().colorize(self.active_payload,"blue"))+\
                      ")"+ \
                      (" @ "+Cmd().colorize(self.active_device,"red") if self.active_device!=None else "")+ \
                      Cmd().colorize("] > ","green")
Example #10
0
 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('omci {}'.format(device_id), 'green'),
         'bold') + ') '
Example #11
0
    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)
Example #12
0
    def __init__(self, *args, **kwargs):
        self.cutoff = None
        self.allow_cli_args = False

        self.titration = kwargs.get('titration')

        # environment attributes
        self.name = self.titration.name
        Cmd.__init__(self)
        self._set_prompt()

        # Exclude irrelevant cmds from help menu
        self.exclude_from_help += [
            'do__relative_load', 'do_cmdenvironment', 'do_edit', 'do_run'
        ]

        # Set path completion for save/load
        self.complete_save_job = self.path_complete
        self.complete_load_job = self.path_complete
        self.complete_add_step = self.path_complete
        self.complete_concentrations = self.path_complete
        self.complete_make_init = self.path_complete
        self.complete_init = self.path_complete
        self.complete_update = self.path_complete

        self.intro = "\n".join([
            "\n\n\tWelcome to Shift2Me !",
            "{summary}\n{intro}".format(summary=self.titration.summary,
                                        intro=self.intro)
        ])
Example #13
0
    def __init__(self, persistent_history_file=history_file):

        # self.settable.update({'row': 'Number of crossbar rows'})
        # self.settable.update({'col': 'Number of crossbar columns'})
        # self.settable.update({'dev': '1S1R or VTEAM'})
        super().__init__()
        Cmd.__init__(self)
Example #14
0
 def __init__(self, game):
     Cmd.__init__(self)
     self._transcript_files = None
     self.prompt = ">"
     self.game = game
     self.map = game.world.map
     self.player_loc = game.player_loc
	def __init__(self, namefile):
		Cmd.__init__(self)
		self.last = []
		self.last.append([])
		self.prompt = bcolors.PROMPT + "ForPCAP >>> " + bcolors.ENDC
		self.loadPcap(namefile)
		self.cmd = ""
Example #16
0
    def __init__(self):
        Cmd.__init__(self)

        # Disable CLI level arguments
        self.allow_cli_args = False

        # Enable debug - prints trace in case there is an issue
        self.debug = True

        # Remove the unused built-in commands from help
        self.exclude_from_help.append('do_edit')
        self.exclude_from_help.append('do_pyscript')
        self.exclude_from_help.append('do_load')
        self.exclude_from_help.append('do_py')
        self.exclude_from_help.append('do_shell')

        # Normal stuff
        self.gClient = None
        self.modelMap= { "wifi-mac": "wifi/mac/openconfig-wifi-mac.yang",
                         "wifi-phy": "wifi/phy/openconfig-wifi-phy.yang",
                         "wifi-system": "wifi/system/openconfig-system-wifi-ext.yang",
                         "vlan": "vlan/openconfig-vlan.yang",
                         "interfaces": "interfaces/openconfig-interfaces.yang",
                         "acl": "acl/openconfig-acl.yang",
                         }
 def __init__(self, workspace_path):
     Cmd.__init__(self)
     self.prompt = "> "
     self.intro = "Welcome to TEP solver console"
     self.tep_workspace = []  # type: TepSolverWorkspace
     self.open_workspace(workspace_path)
     self.timing = True
Example #18
0
    def __init__(self, config, server, sandbox, quiet=False):
        persistent_history_file = config.get('Shell Parameters',
                                             'persistent_history_file')

        # Prevents running of commands by abbreviation
        self.abbrev = False
        self.debug = True
        self.help_path = os.path.join(os.path.dirname(__file__), "shell_help/")
        self.psiturk_header = 'psiTurk command help:'
        self.super_header = 'basic CMD command help:'

        self.config = config
        self.quiet = quiet
        self.server = server

        self.sandbox = sandbox
        self.sandbox_hits = 0
        self.live_hits = 0

        Cmd.__init__(self, persistent_history_file=persistent_history_file)

        if not self.amt_services_wrapper:
            sys.exit()

        self.maybe_update_hit_tally()

        if not self.quiet:
            self.prompt = self.color_prompt()
            self.intro = self.get_intro_prompt()
        else:
            self.intro = ''
Example #19
0
File: dupan.py Project: zTrix/dupan
 def __init__(self):
     Cmd.__init__(self)
     try:
         import readline
         readline.set_completer_delims(' \t\n"') # initially it was ' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?', but I dont want to break on too many
     except:
         pass
Example #20
0
    def __init__(self, *args, **kwargs):
        Cmd.__init__(self, *args, **kwargs)
        self.core = Core()
        self.t = Terminal()

        self.last_result = None
        self.args = None
        self.noninteractive = None
        self.config = None

        self.logdir = '.'
        self.piddir = '.'

        self.daemon = None
        self.running = True
        self.run_thread = None
        self.stop_event = threading.Event()
        self.local_data = threading.local()

        self.crawl_thread = None
        self.publish_thread = None
        self.publish_fb_thread = None

        self.db_config = None
        self.engine = None
        self.session = None

        self.api = None
        self.auth = None
        self.graph = None
Example #21
0
    def use_device(self, line):
        if not action_manager.filter_supported_modules(
                action_manager.device_map[line.split()[1]],
                {self.active_module: self.modules[self.active_module]}
        ):
            various.print_warning("device not supporting selected module")
            return
        self.active_device = line.split()[1]
        # clear settables
        for x in self.current_parameters["device"]:
            self.settable.pop(x)
        self.current_parameters["device"] = []
        for name, p in six.iteritems(action_manager.device_map[self.active_device].parameters):
            if "value" not in p:
                p["value"] = p["default"]
            setattr(self, name, p["value"])
            self.current_parameters["device"].append(name)
            self.settable[name] = ""

        self.prompt = Cmd().colorize("HID [", "green") + \
                      Cmd().colorize(self.active_module, "red") + \
                      ("(" + Cmd().colorize(self.active_payload, "blue") + ")" if self.active_payload != None else "") + \
                      " @ " + \
                      Cmd().colorize(self.active_device, "red") + \
                      Cmd().colorize("] > ", "green")
Example #22
0
    def __init__(self,
                 attempts=5,
                 threads=1,
                 state=None,
                 state_file=None,
                 config_file=None,
                 audit_file=None,
                 max_mem=None,
                 *args,
                 **kwargs):

        Cmd.__init__(self, *args, **kwargs)
        self.t = Terminal()

        self.args = None
        self.attempts = int(attempts)
        self.total = None
        self.terminate = False

        self.last_users_count = None
        self.user_lock = Lock()
        self.processed_user_set = set()
        self.processed_user_set_lock = Lock()
        self.orgs_loaded_set = set()
        self.orgs_loaded_lock = Lock()

        self.max_mem = max_mem
        self.state = state
        self.state_file_path = state_file
        self.rate_limit_reset = None
        self.rate_limit_remaining = None

        self.config = None
        self.config_file = config_file

        self.audit_file = audit_file
        self.audit_records_buffered = []
        self.audit_lock = Lock()

        self.stop_event = threading.Event()
        self.threads = int(threads)
        self.link_queue = Queue.PriorityQueue()  # Store links to download here
        self.worker_threads = []

        self.state_thread = None
        self.state_thread_lock = Lock()

        self.resources_list = []
        self.resources_queue = Queue.PriorityQueue()
        self.local_data = threading.local()

        self.new_users_events = EvtDequeue()
        self.new_keys_events = EvtDequeue()

        self.db_config = None
        self.engine = None
        self.session = None

        self.mem_tracker = None
Example #23
0
 def do_help(self, arg):
     """Command to display help info"""
     self.stdout.write("\n%s Namespace Help\n" % self.namespace)
     
     # If we're just in the cmd2 namespace, return its help
     if (self.namespace == 'cmd2'):
         Cmd.do_help(arg)
         return
     else:  # Else, if we're in another namespace, try the following:
         if arg: # If getting help for a specific command in the namespace, try:
             # First see if the namespace command exists
             try:
                 do_func = getattr(self, 'do_' + self.namespace + "_" + arg)
             except AttributeError:
                 # Namespace function doesn't exist - see if there is a non-namespace / cmd2 command with arg name
                 try:
                     do_func = getattr(self, 'do_' + arg)
                     Cmd.do_help(arg)
                     return
                 except AttributeError:
                     self.stdout.write("[ERROR] Command does not exist in this or top-level namespace: %s\n" % arg)
                     return
             try:
                 # Next see if there is a help_<namespace>_<command> method is available to call
                 help_func = getattr(self, 'help_' + self.namespace + '_' + arg)
                 help_func()
                 return
             except AttributeError:
                 # If no help method for the command, get the __doc__ for the method if exists
                 try:
                     doc=getattr(self, 'do_' + self.namespace + '_' + arg).__doc__
                     if doc:
                         self.stdout.write("%s\n" % str(doc))
                         return
                 except AttributeError:
                     self.stdout.write("%s\n"%str(self.nohelp % (arg,)))
                     return
         # Otherwise display generic help
         else:
             #names = self.get_names() + self.get_names_addendum
             names = self.get_names()
             cmds_doc = []
             cmds_undoc = []
             cmds_cmd2_namespace = []
             for name in names:
                 if name.startswith('do_' + self.namespace):
                     cmd_prefix_length = len(self.namespace)+4
                     cmd=name[cmd_prefix_length:]
                     if getattr(self, name).__doc__:
                         cmds_doc.append(cmd)
                     else:
                         cmds_undoc.append(cmd)
                 elif name[:3] == 'do_':
                     cmd=name[3:]
                     cmds_cmd2_namespace.append(cmd)
             self.stdout.write("%s\n" % str(self.doc_leader))
             self.print_topics(self.doc_header,   cmds_doc,   15,80)
             self.print_topics(self.undoc_header, cmds_undoc, 15,80)
             self.print_topics("'cmd2' Namespace Commands", cmds_cmd2_namespace, 15, 80)
Example #24
0
 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'] + ' '
Example #25
0
 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)
Example #26
0
 def __init__(self, user, pswd, enable_pswd):
     Cmd.__init__(self)
     self.controller = DBController()
     self.runner = TestRunner(self.controller)
     self.user = user
     self.pswd = pswd
     self.enable_pswd = enable_pswd if enable_pswd else pswd
     self.current_results = {}
Example #27
0
 def __init__(self):
     Cmd.__init__(self)
     logging.basicConfig(filename='/tmp/darkdashboard.log', level=logging.INFO,\
                     format='%(asctime)s:%(name)s:%(levelname)s:%(message)s')
     self.logger = logging.getLogger("darkdashboard")
     self.prompt = 'dark> '
     self.rdb = redis_connection()
     print(self.bold(self.colorize('Welcome to DarkServer Dashboard', 'blue')))
Example #28
0
 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
Example #29
0
 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
    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)
Example #31
0
 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
Example #32
0
    def __init__(self):
        # Enable the optional ipy command if IPython is installed by setting use_ipython=True
        Cmd.__init__(self, use_ipython=True)
        self._set_prompt()
        self.autorun_on_edit = False
        self.intro = 'Happy 𝛑 Day.  Note the full Unicode support:  😇  (Python 3 only)  💩'

        # For option commands, pass a list of argument strings instead of a single argument string to the do_* methods
        set_use_arg_list(True)
Example #33
0
 def __init__(self, app: ShowtimeApp, dry_run=False) -> None:
     """Inits Showtime"""
     config = app.config_get()
     Cmd.__init__(
         self, persistent_history_file=config.get('History', 'Path'))
     self.app = app
     self.dry_run = dry_run
     self.output = Output(self.poutput, self.perror, self.pfeedback, self.ppaged)
     self.prompt = self._get_prompt('')
Example #34
0
 def __init__(self):
     Cmd.__init__(self)
     logging.basicConfig(filename='/tmp/darkdashboard.log', level=logging.INFO,\
                     format='%(asctime)s:%(name)s:%(levelname)s:%(message)s')
     self.logger = logging.getLogger("darkdashboard")
     self.prompt = 'dark> '
     self.rdb = redis_connection()
     print(
         self.bold(self.colorize('Welcome to DarkServer Dashboard',
                                 'blue')))
Example #35
0
 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'] + ' '
Example #36
0
    def __init__(self):
        self.multilineCommands = ['orate']
        self.maxrepeats = 3

        # Add stuff to settable and shortcuts before calling base class initializer
        self.settable['maxrepeats'] = 'max repetitions for speak command'
        self.shortcuts.update({'&': 'speak'})

        # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
        Cmd.__init__(self, use_ipython=False)
Example #37
0
    def __init__(self, data_store, spec):
        Cmd.__init__(self)
        self.data_store = data_store
        self.spec = spec

        self.print_header()
        self.similar_specs = data_store.find_similar(spec)
        print
        print self.colorize("Similar specs", 'green')
        self.do_print('similar_specs')
Example #38
0
    def __init__(self):
        Cmd.__init__(self)

        self.bin_loaded = False
        self.bin_running = False

        self.arm_dbg = None

        if DEBUG_MODE:
            import ipdb; ipdb.set_trace()
Example #39
0
 def __init__(self, log=None, ygg_browser=None, **kwargs):
     Cmd.__init__(self, **kwargs)
     self.log = log or yggscr.ylogging.init_default_logger()
     self.intro = "Welcome to Ygg Shell. Type help or ? to list commands.\n"
     self.prompt = "> "
     self.allow_redirection = False
     if ygg_browser is not None:
         self.ygg_browser = ygg_browser
     else:
         self.ygg_browser = yggscr.ygg.YggBrowser(self.log)
Example #40
0
 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()
Example #41
0
    def set(self, app: Cmd):
        """ Adds settings to cmd2 application"""

        #make sure there is not a setting collision
        if hasattr(app, 'special_setting'):
            raise SettingCollisionError

        app.special_setting = 33
        app.add_settable(Settable('special_setting', int, 
            'Special Setting'))
Example #42
0
    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)
Example #43
0
 def cmdloop(self):
     try:
         Cmd.cmdloop(self)
     except KeyboardInterrupt as e:
         self.__key_interrupt = self.__key_interrupt + 1
         if self.__key_interrupt > 1:
             print('^C')
             self.do_exit(self)
         else:
             print('Press Ctrl-C again to exit.')
             self.cmdloop()
Example #44
0
    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")
Example #45
0
    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()
Example #46
0
 def __init__(self, voltha_grpc, voltha_sim_rest, global_request=False):
     VolthaCli.voltha_grpc = voltha_grpc
     VolthaCli.voltha_sim_rest = voltha_sim_rest
     VolthaCli.global_request = global_request
     Cmd.__init__(self)
     self.prompt = '(' + self.colorize(
         self.colorize(self.prompt, 'blue'), 'bold') + ') '
     self.channel = None
     self.stub = None
     self.device_ids_cache = None
     self.device_ids_cache_ts = time()
     self.logical_device_ids_cache = None
     self.logical_device_ids_cache_ts = time()
Example #47
0
    def __init__(self):
        self.multilineCommands = ['orate']
        self.maxrepeats = 3

        # Add stuff to settable and shortcutgs before calling base class initializer
        self.settable['maxrepeats'] = 'max repetitions for speak command'
        self.shortcuts.update({'&': 'speak'})

        # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
        Cmd.__init__(self, use_ipython=False)

        # For option commands, pass a single argument string instead of a list of argument strings to the do_* methods
        set_use_arg_list(False)
Example #48
0
 def do_show(self, line):
     """show <subject>
     Show details on various subject types"""
     if not line:
         # hacky-hack to display settable values
         # called from cmd2's do_set() with no args
         Cmd.do_show(self, line)
     else:
         # Find all SHOW subjects
         if not self.show_command:
             self.show_command = PrimaryCommand(show_cmd)
             args = line.split()
         self.show_command._subjects[args[0]](args)
Example #49
0
    def __init__(self, config_path="config/config.yaml"):
        self.config_path = config_path
        conf = Confiture("config/templates/general.yaml")
        # Parse configuration file and get result
        self.config = conf.check_and_get(config_path)
        # Before we checked the config, it is considered KO
        self.config_ok = False
        # Set the log directory
        self.log_dir = self.config["log"]["path"]

        # Available pintools
        self.__pintools = dict()
        for pintool in self.config["pintool"]:
            # Check the needed two arguments
            req = ["src", "obj"]
            for r in req:
                if r not in self.config["pintool"][pintool].keys():
                    #TODO
                    raise Exception
            src = self.config["pintool"][pintool]["src"]
            obj = self.config["pintool"][pintool]["obj"]
            # Check potential extra argument
            if "prev_step" in self.config["pintool"][pintool].keys():
                prev_step = self.config["pintool"][pintool]["prev_step"]
            else:
                prev_step = None
            # Create pintool object
            pintool_obj = Pintool(
                                    name=pintool,
                                    src_path=src,
                                    obj_path=obj,
                                    pinconf=self.config["pin"],
                                    stdout=self.out,
                                    stderr=self.out,
                                    log_dir=self.log_dir,
                                    prev_step=prev_step,
                                )
            self.__pintools[pintool] = pintool_obj

        # Create a test object
        # Testing options
        kwargs = dict()
        kwargs["log"] = self.out
        if "test" in self.config.keys() and "proto" in self.config["test"]:
            kwargs["proto"] = self.config["test"]["proto"]
        self.test = ScatTest(**kwargs)

        # Init shell
        Cmd.__init__(self, completekey='tab')
Example #50
0
 def precmd(self, line):
     self.api.set_position(
         self.location['latitude'],
         self.location['longitude'],
         self.location['altitude']
     )
     return Cmd.precmd(self, line)
Example #51
0
    def __init__(self, *args, **kwargs):        
        Cmd.__init__(self, *args, **kwargs)
        self.intro = '''\
        \n ----\n Welcome to the NXOS type shell for tac-pac. \
        \n ----\n'''

        self.file = '/tmp/nxos_shell'
        # build time lists
        self.all_module_cmds = [[] for i in xrange(20)]
        self.offset_tuple_list = [[] for i in xrange(20)]
        self.module_s_list = []
        self.module_e_list = []
        #run time locals
        self.local_mod = []
        self.s=[]
        self.cmd_dict = {}
        self.attach_mod_dict = {}
Example #52
0
 def onecmd(self, s):
     try:
         return Cmd.onecmd(self, s)
     except NotImplementedError as e:
         print(e.message)
     except:
         traceback.print_exc()
     return False
Example #53
0
 def cmdloop(self):
     while True:
         stop = Cmd._cmdloop(self) 
         if not stop:
             self.intro = ''
             self.color_prompt()
             print "^C"
         else:
             break
Example #54
0
 def __init__(self, ROOT_DIR):
     Lobotomy.__init__(self)
     self.ROOT_DIR = ROOT_DIR
     self.t = Terminal()
     self.logger = Logger()
     self.util = Util()
     self.apk = None
     self.package = None
     self.vm = None
     self.vmx = None
     self.gmx = None
     self.components = None
     self.dex = None
     self.strings = None
     self.permissions = None
     self.permissions_details = None
     self.files = None
     self.attack_surface = None
    def parseline(self, line):
        '''
        Overrride the parse line, allowing the implementation
        of plugins to receive piped valus
        '''
        if '|' in line:
            self._out('piped', line)

        return Cmd.parseline(self, line)
    def preloop(self, *args):
        '''
        Add the context object to the command line scope
        '''
        _plugins.create(self)
        self.create_root(*args)

        self.set_prompt(self._cwd())
        return Cmd.preloop(self, *args)
Example #57
0
    def __init__(self, config, server, quiet=False):
        Cmd.__init__(self)
        self.config = config
        self.server = server

        # Prevents running of commands by abbreviation
        self.abbrev = False
        self.debug = True
        self.help_path = os.path.join(os.path.dirname(__file__), "shell_help/")
        self.psiturk_header = 'psiTurk command help:'
        self.super_header = 'basic CMD command help:'
        
        if not self.quiet:
            self.color_prompt()
            self.intro = self.get_intro_prompt()
        else:
            self.intro = ''

        self.already_prelooped = False