예제 #1
0
파일: command.py 프로젝트: kfaseela/ishell
    def run(self, line):
        if not self.childs:
            _print("Exec %s(line=%s), overwrite this method!" % (self.name, line))
            return

        print("\nIncomplete Command: %s\n" % line)
        self.print_childs_help()
예제 #2
0
    def run(self, line):
        if not self.childs:
            _print("Exec %s(line=%s), overwrite this method!" % (self.name, line))
            return

        print "\nIncomplete Command: %s\n" % line
        self.print_childs_help()
예제 #3
0
 def run(self, line):
     destination = line.split()[-1]
     import subprocess
     try:
         subprocess.call(['traceroute', '%s' % destination])
     except KeyboardInterrupt:
         _print("Traceroute canceled.")
         return
예제 #4
0
파일: cisco.py 프로젝트: SvenChmie/ishell
 def run(self, line):
     destination = line.split()[-1]
     import subprocess
     try:
         subprocess.call(['traceroute', '%s' % destination])
     except KeyboardInterrupt:
         _print("Traceroute canceled.")
         return
예제 #5
0
 def run(self, line):
     arg = line.split()[-1]
     if arg not in self.args():
         _print("%% Invalid argument: %s" % arg)
         _print("\tUse:")
         _print("\trunning-config -- Show RAM configuration")
         _print("\tstartup-config --  Show NVRAM configuration")
         return
     _print("Executing show %s..." % arg)
예제 #6
0
파일: cisco.py 프로젝트: SvenChmie/ishell
 def run(self, line):
     arg = line.split()[-1]
     if arg not in self.args():
         _print("%% Invalid argument: %s" % arg)
         _print("\tUse:")
         _print("\trunning-config -- Show RAM configuration")
         _print("\tstartup-config --  Show NVRAM configuration")
         return
     _print("Executing show %s..." % arg)
예제 #7
0
파일: command.py 프로젝트: atassumer/ishell
 def _next_command(self, state, buf=''):
     args = self.childs.keys()
     completions = [c + ' ' for c in args if c.startswith(buf)]
     completions = completions + [None]
     logger.debug('PossibleCompletions=>%s' % completions)
     if len(completions) > 2 and state == 0 and not buf:
         logger.debug("Showing all completions...")
         _print("Possible Completions:")
         for child in self.childs.keys():
             _print("  %s%s" % (child.ljust(16), self.childs[child].help))
         return None
     return completions[state]
예제 #8
0
파일: command.py 프로젝트: jamesduan/devops
 def _next_command(self, state, buf=''):
     args = self.childs.keys()
     completions = [c + ' ' for c in args if c.startswith(buf)]
     completions = completions + [None]
     logger.debug('PossibleCompletions=>%s' % completions)
     if len(completions) > 2 and state == 0 and not buf:
         logger.debug("Showing all completions...")
         _print("Possible Completions:")
         for child in self.childs.keys():
             _print("  %s%s" % (child.ljust(16), self.childs[child].help))
         return None
     return completions[state]
예제 #9
0
    def run(self, line):
        self.prompt = "RouterA"
        self.prompt_delim = "#"
        password = getpass.getpass()
        if password != 'python':
            _print("%% Invalid Password, access denied")
            return

        configure = Command("configure", help="Enter configure mode")
        terminal = ConfigureTerminal("terminal")
        configure.addChild(terminal)
        show = Show('show', help="Show configurations", dynamic_args=True)
        self.addChild(configure)
        self.addChild(show)
        self.loop()
예제 #10
0
파일: cisco.py 프로젝트: SvenChmie/ishell
    def run(self, line):
        self.prompt = "RouterA"
        self.prompt_delim = "#"
        password = getpass.getpass()
        if password != 'python':
            _print("%% Invalid Password")
            return

        configure = Command("configure", help="Enter configure mode")
        terminal = ConfigureTerminal("terminal")
        configure.addChild(terminal)
        show = Show('show', help="Show configurations", dynamic_args=True)
        self.addChild(configure)
        self.addChild(show)
        self.loop()
예제 #11
0
파일: command.py 프로젝트: atassumer/ishell
 def run(self, line):
     _print("Exec %s(line=%s), overwrite this method!" % (self.name, line))
예제 #12
0
    def run(self, line):
        args = line.split()

        if not len(args) == 2:
            self.respond('Please specify a tube')
            return False

        tube = args[-1]

        try:

            self.respond('Put a message onto tube "{0}":'.format(tube))

            if tube not in self.beanstalkd.tubes():
                self.respond(
                    '  tube {0} does not exist and will be created'.format(
                        tube))

            priority = self.request('  priority (default: {0}): '.format(
                2**31),
                                    default=None)

            delay = self.request('  delay (default: 0): ', default=0)

            ttr = self.request('  time-to-run (default: 120s): ', default=None)

            body = self.request(
                '  body (ctrl+d to continue):',
                default="",
                stream=True,
            )

            self.respond("""

Confirm job:
  tube: {tube}
  priority: {priority}
  delay: {delay}s
  ttr: {ttr}s
--body:--
{body}
---------
""".format(
                tube=tube,
                priority=priority,
                delay=delay,
                ttr=ttr if ttr else 120,
                body=body,
            ))

            if not self.user_wants_to_continue():
                return self.cancel()

            self.beanstalkd.use(tube)

            kwargs = {}

            if priority:
                kwargs['priority'] = priority

            if delay:
                kwargs['delay'] = int(delay)

            if ttr:
                kwargs['ttr'] = int(ttr)

            jid = self.beanstalkd.put(body, **kwargs)

            self.respond('Successfully created job: {0}'.format(jid))

        except KeyboardInterrupt:
            _print('Cancelling put operation.')
            return False
예제 #13
0
    def run(self, line):
        args = line.split()

        if not len(args) == 2:
            self.respond('Please specify a tube')
            return False

        tube = args[-1]

        try:

            self.respond('Put a message onto tube "{0}":'.format(tube))

            if tube not in self.beanstalkd.tubes():
                self.respond(
                    '  tube {0} does not exist and will be created'.format(tube)
                )

            priority = self.request(
                '  priority (default: {0}): '.format(2**31),
                default=None
            )

            delay = self.request(
                '  delay (default: 0): ',
                default=0
            )

            ttr = self.request(
                '  time-to-run (default: 120s): ',
                default=None
            )

            body = self.request(
                '  body (ctrl+d to continue):',
                default="",
                stream=True,
            )

            self.respond("""

Confirm job:
  tube: {tube}
  priority: {priority}
  delay: {delay}s
  ttr: {ttr}s
--body:--
{body}
---------
""".format(
    tube=tube,
    priority=priority,
    delay=delay,
    ttr=ttr if ttr else 120,
    body=body,
))

            if not self.user_wants_to_continue():
                return self.cancel()

            self.beanstalkd.use(tube)

            kwargs = {}

            if priority:
                kwargs['priority'] = priority

            if delay:
                kwargs['delay'] = int(delay)

            if ttr:
                kwargs['ttr'] = int(ttr)

            jid = self.beanstalkd.put(body, **kwargs)

            self.respond('Successfully created job: {0}'.format(jid))

        except KeyboardInterrupt:
            _print('Cancelling put operation.')
            return False
예제 #14
0
파일: command.py 프로젝트: jamesduan/devops
 def run(self, line):
     _print("Exec %s(line=%s), overwrite this method!" % (self.name, line))
예제 #15
0
파일: cisco.py 프로젝트: SvenChmie/ishell
 def run(self, line):
     _print("Route added!")
예제 #16
0
파일: cisco.py 프로젝트: SvenChmie/ishell
 def set_address(self, line):
     addr = line.split()[-1]
     _print("Setting interface %s address %s" % (self.interface, addr))
예제 #17
0
 def set_address(self, line):
     addr = line.split()[-1]
     _print("Setting interface %s address %s" % (self.interface, addr))
예제 #18
0
 def run(self, line):
     _print("Route added!")
예제 #19
0
 def emit(self, record):
     _print(self.format(record))
예제 #20
0
파일: log.py 프로젝트: SvenChmie/ishell
 def emit(self, record):
     _print(self.format(record))