當前位置: 首頁>>代碼示例>>Python>>正文


Python Templates.init方法代碼示例

本文整理匯總了Python中crossbar.controller.template.Templates.init方法的典型用法代碼示例。如果您正苦於以下問題:Python Templates.init方法的具體用法?Python Templates.init怎麽用?Python Templates.init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在crossbar.controller.template.Templates的用法示例。


在下文中一共展示了Templates.init方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_command_init

# 需要導入模塊: from crossbar.controller.template import Templates [as 別名]
# 或者: from crossbar.controller.template.Templates import init [as 別名]
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'))))
開發者ID:bihicheng,項目名稱:crossbar,代碼行數:42,代碼來源:cli.py

示例2: run_command_init

# 需要導入模塊: from crossbar.controller.template import Templates [as 別名]
# 或者: from crossbar.controller.template.Templates import init [as 別名]
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'))))
開發者ID:josephwinston,項目名稱:crossbar,代碼行數:46,代碼來源:cli.py

示例3: run_command_init

# 需要導入模塊: from crossbar.controller.template import Templates [as 別名]
# 或者: from crossbar.controller.template.Templates import init [as 別名]
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")),
        )
開發者ID:v09-software,項目名稱:crossbar,代碼行數:46,代碼來源:cli.py


注:本文中的crossbar.controller.template.Templates.init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。