def __init__(self, server): super().__init__() self.server = server self.prompt = "[+] " # setting options self.cmd_timeout = 30 self.zip_comp = 1 self.sock_timeout = 10 # adding some settings self.add_settable( cmd2.Settable("cmd_timeout", int, "clientside timeout before returning from a command", choices=range(0, 3600))) self.add_settable( cmd2.Settable("zip_comp", int, "compression level when creating zip file", choices=range(0, 9))) self.add_settable( cmd2.Settable("sock_timeout", int, "serverside timeout for receiving and sending data", choices=range(0, 3600))) # delete some builtins del cmd2.Cmd.do_py del cmd2.Cmd.do_run_pyscript del cmd2.Cmd.do_run_script del cmd2.Cmd.do_quit del cmd2.Cmd.do_shortcuts del cmd2.Cmd.do_alias del cmd2.Cmd.do_macro
def __init__(self): self.locals_in_py = True self.default_category = 'UniGDB Built-in Commands' super(CoreShell, self).__init__( persistent_history_file='/tmp/.unigdb_history', shortcuts={}, ) # load modules for cmdClass in unigdb.commands.__commands__: self.register_cmd_class(cmdClass(self)) self.intro = initial_message() self.aliases['q'] = 'quit' # Set enviroment variables self.mapping_size = 2 * 1024 * 1024 * 1024 self.mapping = 0x100000 self.add_settable(cmd2.Settable('arch', str, 'Target architecrute')) self.add_settable(cmd2.Settable('mapping', int, 'Memory start map address')) self.add_settable(cmd2.Settable('mapping_size', int, 'Memory mapping size in bytes')) # remove unneeded commands del cmd2.Cmd.do_shortcuts del cmd2.Cmd.do_macro del cmd2.Cmd._macro_create del cmd2.Cmd._macro_delete del cmd2.Cmd._macro_list del cmd2.Cmd.do_edit del cmd2.Cmd.do_run_pyscript self.async_update_prompt(unigdb.prompt.set_prompt())
def __init__(self): super().__init__() self.degrees_c = 22 self.sunny = False self.add_settable( cmd2.Settable('degrees_c', int, 'Temperature in Celsius', self, onchange_cb=self._onchange_degrees_c) ) self.add_settable(cmd2.Settable('sunny', bool, 'Is it sunny outside?', self))
def __init__(self): super().__init__() # Make datalake_name settable at runtime self.datalakename = 'mydatalake' self.add_settable( cmd2.Settable('datalakename', str, 'name of the datalake definition'))
def __init__(self): super().__init__( multiline_commands=['echo'], persistent_history_file='cmd2_history.dat', startup_script='scripts/startup.txt', use_ipython=True, ) # Prints an intro banner once upon application startup self.intro = style('Welcome to cmd2!', fg=fg.red, bg=bg.white, bold=True) # Show this as the prompt when asking for input self.prompt = 'myapp> ' # Used as prompt for multiline commands after the first line self.continuation_prompt = '... ' # Allow access to your application in py and ipy via self self.self_in_py = True # Set the default category name self.default_category = 'cmd2 Built-in Commands' # Color to output text in with echo command self.foreground_color = 'cyan' # Make echo_fg settable at runtime self.add_settable( cmd2.Settable('foreground_color', str, 'Foreground color to use with echo command', self, choices=fg.colors()) )
def __init__(self): shortcuts = cmd2.DEFAULT_SHORTCUTS shortcuts.update({'&': 'speak'}) super().__init__(multiline_commands=['orate'], shortcuts=shortcuts) # Make maxrepeats settable at runtime self.maxrepeats = 3 self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
def __init__(self): # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=True) self.maxrepeats = 3 # Make maxrepeats settable at runtime self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command')) # Should ANSI color output be allowed self.allow_style = ansi.STYLE_TERMINAL
def __init__(self): shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell super().__init__(allow_cli_args=False, include_ipy=True, multiline_commands=['orate'], shortcuts=shortcuts) self.self_in_py = True self.maxrepeats = 3 # Make maxrepeats settable at runtime self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
def __init__(self, *args, **kwargs): "Initialize this plugin." # code placed here runs before cmd2 initializes super().__init__(*args, **kwargs) # code placed here runs after cmd2 initializes # this is where you register any hook functions self.abbrev = False self.add_settable( cmd2.Settable('abbrev', bool, 'Accept command abbreviations')) self.register_postparsing_hook(self.cmd2_abbrev_hook)
def __init__(self): super().__init__() self.debug = True self.ssh = None self.tunnels = None self.log_file = None self.download_dir = f"{os.getcwd()}{os.path.sep}logs" self.add_settable( cmd2.Settable('download_dir', str, 'Default destination location of downloaded files'))
def __init__(self, card, rs, script=None): basic_commands = [Iso7816Commands(), PySimCommands()] super().__init__(persistent_history_file='~/.pysim_shell_history', allow_cli_args=False, use_ipython=True, auto_load_commands=False, command_sets=basic_commands, startup_script=script) self.intro = style('Welcome to pySim-shell!', fg=fg.red) self.default_category = 'pySim-shell built-in commands' self.card = card iccid, sw = self.card.read_iccid() self.iccid = iccid self.rs = rs self.py_locals = {'card': self.card, 'rs': self.rs} self.numeric_path = False self.add_settable( cmd2.Settable('numeric_path', bool, 'Print File IDs instead of names', onchange_cb=self._onchange_numeric_path)) self.conserve_write = True self.add_settable( cmd2.Settable('conserve_write', bool, 'Read and compare before write', onchange_cb=self._onchange_conserve_write)) self.update_prompt() self.json_pretty_print = True self.add_settable( cmd2.Settable('json_pretty_print', bool, 'Pretty-Print JSON output')) self.apdu_trace = False self.add_settable( cmd2.Settable('apdu_trace', bool, 'Trace and display APDUs exchanged with card', onchange_cb=self._onchange_apdu_trace))
def __init__(self, ip_addr=None, port=None, transcript_files=None): shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False, transcript_files=transcript_files, multiline_commands=['orate'], shortcuts=shortcuts) self.maxrepeats = 3 # Make maxrepeats settable at runtime self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command')) # Example of args set from the command-line (but they aren't being used here) self._ip = ip_addr self._port = port
def __init__(self): super().__init__() self.current_file = '' self.map_data = collections.OrderedDict() self.id2info = {} self.raw_data = {} self.rootnode = v_node.Node(name='Root', idmap=self.id2info) self.rolltables = collections.OrderedDict() # Make maxrepeats settable at runtime self.maxrepeats = 3 self.add_settable( cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
def __init__(self, ip_addr=None, port=None, transcript_files=None): shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) super().__init__(transcript_files=transcript_files, multiline_commands=['orate'], shortcuts=shortcuts) self.maxrepeats = 3 # Make maxrepeats settable at runtime self.add_settable( cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self)) # Example of args set from the command-line (but they aren't being used here) self._ip = ip_addr self._port = port
def __init__(self): """Initialize the base class as well as this one""" shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'~': 'sing'}) super().__init__(multiline_commands=['sing'], terminators=[MULTILINE_TERMINATOR, '...'], shortcuts=shortcuts) self.default_to_shell = True self.songcolor = 'blue' # Make songcolor settable at runtime self.add_settable(cmd2.Settable('songcolor', str, 'Color to ``sing``', choices=cmd2.ansi.fg.colors())) # prompts and defaults self.gold = 0 self.initial_gold = self.gold self.prompt = 'arrr> '
def __init__(self, command_sets: Optional[Iterable[CommandSet]] = None): shortcuts = cmd2.DEFAULT_SHORTCUTS shortcuts.update({'&': 'speak'}) super().__init__(multiline_commands=['orate'], shortcuts=shortcuts, command_sets=command_sets) #set banner self.intro = banner() #Add settables from external plugins add_settables_from_plugin(self) # Make maxrepeats settable at runtime self.maxrepeats = 3 self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command')) self.config = self._read_init()
def __init__(self, card, rs, script=None): basic_commands = [Iso7816Commands(), UsimCommands()] super().__init__(persistent_history_file='~/.pysim_shell_history', allow_cli_args=False, use_ipython=True, auto_load_commands=False, command_sets=basic_commands, startup_script=script) self.intro = style('Welcome to pySim-shell!', fg=fg.red) self.default_category = 'pySim-shell built-in commands' self.card = card self.rs = rs self.py_locals = {'card': self.card, 'rs': self.rs} self.numeric_path = False self.add_settable( cmd2.Settable('numeric_path', bool, 'Print File IDs instead of names', onchange_cb=self._onchange_numeric_path)) self.update_prompt()