当前位置: 首页>>代码示例>>Python>>正文


Python RemoteHelper.copy_app_to_host方法代码示例

本文整理汇总了Python中remote_helper.RemoteHelper.copy_app_to_host方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.copy_app_to_host方法的具体用法?Python RemoteHelper.copy_app_to_host怎么用?Python RemoteHelper.copy_app_to_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在remote_helper.RemoteHelper的用法示例。


在下文中一共展示了RemoteHelper.copy_app_to_host方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_app

# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import copy_app_to_host [as 别名]
  def upload_app(cls, options):
    """Uploads the given App Engine application into AppScale.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    """
    if cls.TAR_GZ_REGEX.search(options.file):
      file_location = LocalState.extract_app_to_dir(options.file,
        options.verbose)
      created_dir = True
    else:
      file_location = options.file
      created_dir = False

    app_id = AppEngineHelper.get_app_id_from_app_config(file_location)
    app_language = AppEngineHelper.get_app_runtime_from_app_config(
      file_location)
    AppEngineHelper.validate_app_id(app_id)

    acc = AppControllerClient(LocalState.get_login_host(options.keyname),
      LocalState.get_secret_key(options.keyname))
    userappserver_host = acc.get_uaserver_host(options.verbose)
    userappclient = UserAppClient(userappserver_host, LocalState.get_secret_key(
      options.keyname))

    if options.test:
      username = LocalState.DEFAULT_USER
    elif options.email:
      username = options.email
    else:
      username = LocalState.get_username_from_stdin(is_admin=False)

    if not userappclient.does_user_exist(username):
      password = LocalState.get_password_from_stdin()
      RemoteHelper.create_user_accounts(username, password, userappserver_host,
        options.keyname)

    if userappclient.does_app_exist(app_id):
      raise AppScaleException("The given application is already running in " + \
        "AppScale. Please choose a different application ID or use " + \
        "appscale-remove-app to take down the existing application.")

    app_admin = userappclient.get_app_admin(app_id)
    if app_admin is not None and username != app_admin:
      raise AppScaleException("The given user doesn't own this application" + \
        ", so they can't upload an app with that application ID. Please " + \
        "change the application ID and try again.")

    AppScaleLogger.log("Uploading {0}".format(app_id))
    userappclient.reserve_app_id(username, app_id, app_language)

    remote_file_path = RemoteHelper.copy_app_to_host(file_location,
      options.keyname, options.verbose)
    acc.done_uploading(app_id, remote_file_path)
    acc.update([app_id])

    # now that we've told the AppController to start our app, find out what port
    # the app is running on and wait for it to start serving
    AppScaleLogger.log("Please wait for your app to start serving.")
    serving_host, serving_port = userappclient.get_serving_info(app_id,
      options.keyname)
    RemoteHelper.sleep_until_port_is_open(serving_host, serving_port,
      options.verbose)
    AppScaleLogger.success("Your app can be reached at the following URL: " +
      "http://{0}:{1}".format(serving_host, serving_port))

    if created_dir:
      shutil.rmtree(file_location)
开发者ID:DrOctogon,项目名称:appscale-tools,代码行数:71,代码来源:appscale_tools.py

示例2: upload_app

# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import copy_app_to_host [as 别名]
  def upload_app(cls, options):
    """Uploads the given App Engine application into AppScale.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    Returns:
      A tuple containing the host and port where the application is serving
        traffic from.
    """
    if cls.TAR_GZ_REGEX.search(options.file):
      file_location = LocalState.extract_tgz_app_to_dir(options.file,
        options.verbose)
      created_dir = True
    elif cls.ZIP_REGEX.search(options.file):
      file_location = LocalState.extract_zip_app_to_dir(options.file,
        options.verbose)
      created_dir = True
    elif os.path.isdir(options.file):
      file_location = options.file
      created_dir = False
    else:
      raise AppEngineConfigException('{0} is not a tar.gz file, a zip file, ' \
        'or a directory. Please try uploading either a tar.gz file, a zip ' \
        'file, or a directory.'.format(options.file))

    try:
      app_id = AppEngineHelper.get_app_id_from_app_config(file_location)
    except AppEngineConfigException as config_error:
      AppScaleLogger.log(config_error)
      if 'yaml' in str(config_error):
        raise config_error

      # Java App Engine users may have specified their war directory. In that
      # case, just move up one level, back to the app's directory.
      file_location = file_location + os.sep + ".."
      app_id = AppEngineHelper.get_app_id_from_app_config(file_location)

    app_language = AppEngineHelper.get_app_runtime_from_app_config(
      file_location)
    AppEngineHelper.validate_app_id(app_id)

    if app_language == 'java':
      if AppEngineHelper.is_sdk_mismatch(file_location):
        AppScaleLogger.warn('AppScale did not find the correct SDK jar ' +
          'versions in your app. The current supported ' +
          'SDK version is ' + AppEngineHelper.SUPPORTED_SDK_VERSION + '.')

    login_host = LocalState.get_login_host(options.keyname)
    secret_key = LocalState.get_secret_key(options.keyname)
    acc = AppControllerClient(login_host, secret_key)

    if options.test:
      username = LocalState.DEFAULT_USER
    elif options.email:
      username = options.email
    else:
      username = LocalState.get_username_from_stdin(is_admin=False)

    if not acc.does_user_exist(username):
      password = LocalState.get_password_from_stdin()
      RemoteHelper.create_user_accounts(username, password,
        login_host, options.keyname, clear_datastore=False)

    app_exists = acc.does_app_exist(app_id)
    app_admin = acc.get_app_admin(app_id)
    if app_admin is not None and username != app_admin:
      raise AppScaleException("The given user doesn't own this application" + \
        ", so they can't upload an app with that application ID. Please " + \
        "change the application ID and try again.")

    if app_exists:
      AppScaleLogger.log("Uploading new version of app {0}".format(app_id))
    else:
      AppScaleLogger.log("Uploading initial version of app {0}".format(app_id))
      acc.reserve_app_id(username, app_id, app_language)

    # Ignore all .pyc files while tarring.
    if app_language == 'python27':
      AppScaleLogger.log("Ignoring .pyc files")

    remote_file_path = RemoteHelper.copy_app_to_host(file_location,
      options.keyname, options.verbose)

    acc.done_uploading(app_id, remote_file_path)
    acc.update([app_id])

    # now that we've told the AppController to start our app, find out what port
    # the app is running on and wait for it to start serving
    AppScaleLogger.log("Please wait for your app to start serving.")

    if app_exists:
      time.sleep(20)  # give the AppController time to restart the app

    # Makes a call to the AppController to get all the stats and looks
    # through them for the http port the app can be reached on.
    sleep_time = 2 * cls.SLEEP_TIME
    current_app = None
    for i in range(cls.MAX_RETRIES):
      try:
#.........这里部分代码省略.........
开发者ID:eabyshev,项目名称:appscale-tools,代码行数:103,代码来源:appscale_tools.py

示例3: upload_app

# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import copy_app_to_host [as 别名]
    def upload_app(cls, options):
        """Uploads the given App Engine application into AppScale.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    Returns:
      A tuple containing the host and port where the application is serving
        traffic from.
    """
        if cls.TAR_GZ_REGEX.search(options.file):
            file_location = LocalState.extract_tgz_app_to_dir(options.file, options.verbose)
            created_dir = True
        elif cls.ZIP_REGEX.search(options.file):
            file_location = LocalState.extract_zip_app_to_dir(options.file, options.verbose)
            created_dir = True
        elif os.path.isdir(options.file):
            file_location = options.file
            created_dir = False
        else:
            raise AppEngineConfigException(
                "{0} is not a tar.gz file, a zip file, "
                "or a directory. Please try uploading either a tar.gz file, a zip "
                "file, or a directory.".format(options.file)
            )

        try:
            app_id = AppEngineHelper.get_app_id_from_app_config(file_location)
        except AppEngineConfigException:
            # Java App Engine users may have specified their war directory. In that
            # case, just move up one level, back to the app's directory.
            file_location = file_location + os.sep + ".."
            app_id = AppEngineHelper.get_app_id_from_app_config(file_location)

        app_language = AppEngineHelper.get_app_runtime_from_app_config(file_location)
        AppEngineHelper.validate_app_id(app_id)

        if app_language == "java":
            if AppEngineHelper.is_sdk_mismatch(file_location):
                AppScaleLogger.warn(
                    "AppScale did not find the correct SDK jar "
                    + "versions in your app. The current supported "
                    + "SDK version is "
                    + AppEngineHelper.SUPPORTED_SDK_VERSION
                    + "."
                )

        acc = AppControllerClient(
            LocalState.get_login_host(options.keyname), LocalState.get_secret_key(options.keyname)
        )
        userappclient = UserAppClient(
            LocalState.get_login_host(options.keyname), LocalState.get_secret_key(options.keyname)
        )

        if options.test:
            username = LocalState.DEFAULT_USER
        elif options.email:
            username = options.email
        else:
            username = LocalState.get_username_from_stdin(is_admin=False)

        if not userappclient.does_user_exist(username):
            password = LocalState.get_password_from_stdin()
            RemoteHelper.create_user_accounts(
                username, password, LocalState.get_login_host(options.keyname), options.keyname, clear_datastore=False
            )

        app_exists = userappclient.does_app_exist(app_id)
        app_admin = userappclient.get_app_admin(app_id)
        if app_admin is not None and username != app_admin:
            raise AppScaleException(
                "The given user doesn't own this application"
                + ", so they can't upload an app with that application ID. Please "
                + "change the application ID and try again."
            )

        if app_exists:
            AppScaleLogger.log("Uploading new version of app {0}".format(app_id))
        else:
            AppScaleLogger.log("Uploading initial version of app {0}".format(app_id))
            userappclient.reserve_app_id(username, app_id, app_language)

        # Ignore all .pyc files while tarring.
        if app_language == "python27":
            AppScaleLogger.log("Ignoring .pyc files")

        remote_file_path = RemoteHelper.copy_app_to_host(file_location, options.keyname, options.verbose)

        acc.done_uploading(app_id, remote_file_path)
        acc.update([app_id])

        # now that we've told the AppController to start our app, find out what port
        # the app is running on and wait for it to start serving
        AppScaleLogger.log("Please wait for your app to start serving.")

        if app_exists:
            time.sleep(20)  # give the AppController time to restart the app

        serving_host, serving_port = userappclient.get_serving_info(app_id, options.keyname)
        RemoteHelper.sleep_until_port_is_open(serving_host, serving_port, options.verbose)
#.........这里部分代码省略.........
开发者ID:lmandres,项目名称:appscale-tools-raspberry-pi,代码行数:103,代码来源:appscale_tools.py

示例4: upload_app

# 需要导入模块: from remote_helper import RemoteHelper [as 别名]
# 或者: from remote_helper.RemoteHelper import copy_app_to_host [as 别名]
  def upload_app(cls, options):
    """Uploads the given App Engine application into AppScale.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    Returns:
      A tuple containing the host and port where the application is serving
        traffic from.
    """
    start_time = time.time()
    if cls.TAR_GZ_REGEX.search(options.file):
      file_location = LocalState.extract_tgz_app_to_dir(options.file,
        options.verbose)
      created_dir = True
    elif cls.ZIP_REGEX.search(options.file):
      file_location = LocalState.extract_zip_app_to_dir(options.file,
        options.verbose)
      created_dir = True
    elif os.path.isdir(options.file):
      file_location = options.file
      created_dir = False
    else:
      raise AppEngineConfigException('{0} is not a tar.gz file, a zip file, ' \
        'or a directory. Please try uploading either a tar.gz file, a zip ' \
        'file, or a directory.'.format(options.file))

    try:
      app_id = AppEngineHelper.get_app_id_from_app_config(file_location)
    except AppEngineConfigException:
      # Java App Engine users may have specified their war directory. In that
      # case, just move up one level, back to the app's directory.
      file_location = file_location + os.sep + ".."
      app_id = AppEngineHelper.get_app_id_from_app_config(file_location)

    app_language = AppEngineHelper.get_app_runtime_from_app_config(
      file_location)
    AppEngineHelper.validate_app_id(app_id)
    
    if app_language == 'java':
      if AppEngineHelper.is_sdk_mismatch(file_location):
        AppScaleLogger.warn('AppScale did not find the correct SDK jar ' + 
          'versions in your app. The current supported ' + 
          'SDK version is ' + AppEngineHelper.SUPPORTED_SDK_VERSION + '.')

    acc = AppControllerClient(LocalState.get_login_host(options.keyname),
      LocalState.get_secret_key(options.keyname))
    userappserver_host = acc.get_uaserver_host(options.verbose)
    userappclient = UserAppClient(userappserver_host, LocalState.get_secret_key(
      options.keyname))

    if options.test:
      username = LocalState.DEFAULT_USER
    elif options.email:
      username = options.email
    else:
      username = LocalState.get_username_from_stdin(is_admin=False)

    if not userappclient.does_user_exist(username):
      password = LocalState.get_password_from_stdin()
      RemoteHelper.create_user_accounts(username, password, userappserver_host,
        options.keyname, clear_datastore=False)

    app_exists = userappclient.does_app_exist(app_id)
    app_admin = userappclient.get_app_admin(app_id)
    if app_admin is not None and username != app_admin:
      raise AppScaleException("The given user doesn't own this application" + \
        ", so they can't upload an app with that application ID. Please " + \
        "change the application ID and try again.")

    eager_app = None
    eager_enabled = not options.disable_eager
    t1 = t2 = t3 = t4 = 0
    if eager_enabled:
      t1 = time.time()
      eager_app = EagerHelper.get_application_info(username, app_language, file_location)
      valid = EagerHelper.perform_eager_validation(eager_app, options.keyname)
      if valid:
        AppScaleLogger.success('EAGER validation was successful. Continuing with the deployment.')
      else:
        AppScaleLogger.warn('EAGER validation failed. Aborting app deployment!')
        end_time = time.time()
        AppScaleLogger.log("Time elapsed: {0} ms".format((end_time - start_time) * 1000))
        AppScaleLogger.log("Time spent on EAGER: {0} ms".format((end_time - t1) * 1000))
        return
      t2 = time.time()

    if app_exists:
      AppScaleLogger.log("Uploading new version of app {0}".format(app_id))
    else:
      AppScaleLogger.log("Uploading initial version of app {0}".format(app_id))
      userappclient.reserve_app_id(username, app_id, app_language)

    remote_file_path = RemoteHelper.copy_app_to_host(file_location,
      options.keyname, options.verbose)

    acc.done_uploading(app_id, remote_file_path)
    acc.update([app_id])

    # now that we've told the AppController to start our app, find out what port
#.........这里部分代码省略.........
开发者ID:UCSB-CS-RACELab,项目名称:eager-appscale-tools,代码行数:103,代码来源:appscale_tools.py


注:本文中的remote_helper.RemoteHelper.copy_app_to_host方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。