コード例 #1
0
ファイル: console.py プロジェクト: JuRogn/slapos.core
def console():
  description = textwrap.dedent("""\
    slapconsole allows you interact with slap API. You can play with the global
    "slap" object and with the global "request" method.

    examples :
    >>> # Request instance
    >>> request(kvm, "myuniquekvm")
    >>> # Request software installation on owned computer
    >>> supply(kvm, "mycomputer")
    >>> # Fetch instance informations on already launched instance
    >>> request(kvm, "myuniquekvm").getConnectionParameter("url")""")

  ap = argparse.ArgumentParser(description=description,
                               formatter_class=argparse.RawDescriptionHelpFormatter)

  ap.add_argument('-u', '--master_url',
                  default=None,
                  help='Url of SlapOS Master to use.')

  ap.add_argument('-k', '--key_file',
                  help="SSL Authorisation key file.")

  ap.add_argument('-c', '--cert_file',
                  help="SSL Authorisation certificate file.")

  ap.add_argument('configuration_file',
                  help='path to slapos.cfg')

  args = ap.parse_args()

  if not os.path.isfile(args.configuration_file):
    ap.error("%s: Not found or not a regular file." % args.configuration_file)

  configp = get_config_parser(args.configuration_file)
  conf = ClientConfig(args, configp)
  local = init(conf)
  do_console(local)
コード例 #2
0
ファイル: console.py プロジェクト: JuRogn/slapos.core
    def take_action(self, args):
        configp = self.fetch_config(args)
        conf = ClientConfig(args, configp)
        local = init(conf)

        if not any([args.python, args.ipython, args.bpython]):
            args.bpython = True

        if args.ipython:
            try:
                do_ipython_console(local)
            except ShellNotFound:
                self.app.log.info('IPython not available - using plain Python shell')
                do_console(local)
        elif args.bpython:
            try:
                do_bpython_console(local)
            except ShellNotFound:
                self.app.log.info('bpython not available - using plain Python shell')
                do_console(local)
        else:
            do_console(local)