Beispiel #1
0
def run_command_templates(options):
    """
    Subcommand "crossbar templates".
    """
    from crossbar.controller.template import Templates

    templates = Templates()
    templates.help()
Beispiel #2
0
def run_command_templates(options):
   """
   Subcommand "crossbar templates".
   """
   from crossbar.controller.template import Templates

   templates = Templates()
   templates.help()
Beispiel #3
0
def run_command_init(options):
    """
    Subcommand "crossbar init".
    """
    from crossbar.controller.template import Templates

    templates = Templates()

    if options.template not in templates:
        print(
            "Huh, sorry. There is no template named '{}'. Try 'crossbar templates' to list the templates available."
            .format(options.template))
        sys.exit(1)

    if options.appdir is None:
        options.appdir = '.'
    else:
        if os.path.exists(options.appdir):
            raise Exception("app directory '{}' already exists".format(
                options.appdir))

        try:
            os.mkdir(options.appdir)
        except Exception as e:
            raise Exception(
                "could not create application directory '{}' ({})".format(
                    options.appdir, e))
        else:
            print("Crossbar.io application directory '{}' created".format(
                options.appdir))

    options.appdir = os.path.abspath(options.appdir)

    print("Initializing application template '{}' in directory '{}'".format(
        options.template, options.appdir))
    get_started_hint = templates.init(options.appdir, options.template)

    # try:
    #    templates.init(options.appdir, options.template)
    # except Exception as e:
    #    try:
    #       shutil.rmtree(options.appdir)
    #    except:
    #       pass
    #    raise e

    print("Application template initialized")
    if get_started_hint:
        print("\n{}\n".format(get_started_hint))
    else:
        print("\nTo start your node, run 'crossbar start --cbdir {}'\n".format(
            os.path.abspath(os.path.join(options.appdir, '.crossbar'))))
Beispiel #4
0
def run_command_init(options, **kwargs):
    """
    Subcommand "crossbar init".
    """
    log = make_logger()

    from crossbar.controller.template import Templates

    templates = Templates()

    if options.template not in templates:
        log.info(
            "Huh, sorry. There is no template named '{options.template}'. Try 'crossbar templates' to list the templates available.",
            options=options)
        sys.exit(1)

    if options.appdir is None:
        options.appdir = '.'
    else:
        if os.path.exists(options.appdir):
            raise Exception("app directory '{}' already exists".format(
                options.appdir))

        try:
            os.mkdir(options.appdir)
        except Exception as e:
            raise Exception(
                "could not create application directory '{}' ({})".format(
                    options.appdir, e))
        else:
            log.info(
                "Crossbar.io application directory '{options.appdir}' created",
                options=options)

    options.appdir = os.path.abspath(options.appdir)

    log.info(
        "Initializing application template '{options.template}' in directory '{options.appdir}'",
        options=options)
    get_started_hint = templates.init(options.appdir, options.template)

    log.info("Application template initialized")

    if get_started_hint:
        log.info("\n{}\n".format(get_started_hint))
    else:
        log.info(
            "\nTo start your node, run 'crossbar start --cbdir {cbdir}'\n",
            cbdir=os.path.abspath(os.path.join(options.appdir, '.crossbar')))
Beispiel #5
0
def run_command_init(options):
   """
   Subcommand "crossbar init".
   """
   from crossbar.controller.template import Templates

   templates = Templates()

   if not options.template in templates:
      print("Huh, sorry. There is no template named '{}'. Try 'crossbar templates' to list the templates available.".format(options.template))
      sys.exit(1)

   if options.appdir is None:
      options.appdir = '.'
   else:
      if os.path.exists(options.appdir):
         raise Exception("app directory '{}' already exists".format(options.appdir))

      try:
         os.mkdir(options.appdir)
      except Exception as e:
         raise Exception("could not create application directory '{}' ({})".format(options.appdir, e))
      else:
         print("Crossbar.io application directory '{}' created".format(options.appdir))

   options.appdir = os.path.abspath(options.appdir)

   print("Initializing application template '{}' in directory '{}'".format(options.template, options.appdir))
   get_started_hint = templates.init(options.appdir, options.template)

   # try:
   #    templates.init(options.appdir, options.template)
   # except Exception as e:
   #    try:
   #       shutil.rmtree(options.appdir)
   #    except:
   #       pass
   #    raise e

   print("Application template initialized")
   if get_started_hint:
      print("\n{}\n".format(get_started_hint))
   else:
      print("\nTo start your node, run 'crossbar start --cbdir {}'\n".format(os.path.abspath(os.path.join(options.appdir, '.crossbar'))))
Beispiel #6
0
def run_command_init(options, **kwargs):
    """
    Subcommand "crossbar init".
    """
    log = make_logger()

    from crossbar.controller.template import Templates

    templates = Templates()

    if options.template not in templates:
        log.info(
            "Huh, sorry. There is no template named '{options.template}'. Try 'crossbar templates' to list the templates available.",
            options=options,
        )
        sys.exit(1)

    if options.appdir is None:
        options.appdir = "."
    else:
        if os.path.exists(options.appdir):
            raise Exception("app directory '{}' already exists".format(options.appdir))

        try:
            os.mkdir(options.appdir)
        except Exception as e:
            raise Exception("could not create application directory '{}' ({})".format(options.appdir, e))
        else:
            log.info("Crossbar.io application directory '{options.appdir}' created", options=options)

    options.appdir = os.path.abspath(options.appdir)

    log.info("Initializing application template '{options.template}' in directory '{options.appdir}'", options=options)
    get_started_hint = templates.init(options.appdir, options.template)

    log.info("Application template initialized")

    if get_started_hint:
        log.info("\n{}\n".format(get_started_hint))
    else:
        log.info(
            "\nTo start your node, run 'crossbar start --cbdir {cbdir}'\n",
            cbdir=os.path.abspath(os.path.join(options.appdir, ".crossbar")),
        )
Beispiel #7
0
def run_command_init(options):
   """
   Subcommand "crossbar init".
   """
   from crossbar.controller.template import Templates

   templates = Templates()

   if not options.template in templates:
      raise Exception("no node template '{}' - use the command 'crossbar templates' to list templates available".format(options.template))

   if options.appdir is None:
      options.appdir = '.'
   else:
      if os.path.exists(options.appdir):
         raise Exception("app directory '{}' already exists".format(options.appdir))

      try:
         os.mkdir(options.appdir)
      except Exception as e:
         raise Exception("could not create application directory '{}' ({})".format(options.appdir, e))
      else:
         print("Crossbar.io application directory '{}' created".format(options.appdir))

   options.appdir = os.path.abspath(options.appdir)

   print("Initializing application template '{}' in directory '{}'".format(options.template, options.appdir))
   templates.init(options.appdir, options.template)

   # try:
   #    templates.init(options.appdir, options.template)
   # except Exception as e:
   #    try:
   #       shutil.rmtree(options.appdir)
   #    except:
   #       pass
   #    raise e

   print("Application template initialized")
   print("\nTo start your node, run 'crossbar start --cbdir {}'".format(os.path.abspath(os.path.join(options.appdir, '.crossbar'))))
Beispiel #8
0
def run_command_templates(options, **kwargs):
    """
    Subcommand "crossbar templates".
    """
    templates = Templates()
    templates.help()
Beispiel #9
0
def run_command_templates(options, **kwargs):
    """
    Subcommand "crossbar templates".
    """
    templates = Templates()
    templates.help()