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


Python utils.doCopy函数代码示例

本文整理汇总了Python中utils.doCopy函数的典型用法代码示例。如果您正苦于以下问题:Python doCopy函数的具体用法?Python doCopy怎么用?Python doCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: buildPKGAPP

def buildPKGAPP(build_json=None):
    LOG.info("+Building package APP ...")
    if utils.safelyGetValue(build_json, "apk-type") == "MANIFEST":
        if not os.path.exists(os.path.join(BUILD_ROOT_SRC, "manifest.json")):
            LOG.error("Not found manifest.json in suite folder, please check!")
            sys.exit(1)
        if not utils.doCopy(
            os.path.join(BUILD_ROOT_SRC, "manifest.json"), os.path.join(BUILD_ROOT_SRC_PKG_APP, "manifest.json")
        ):
            return False
    if not utils.doCopy(os.path.join(BUILD_ROOT_SRC, "icon.png"), os.path.join(BUILD_ROOT_SRC_PKG_APP, "icon.png")):
        return False

    hosted_app = False
    if utils.safelyGetValue(build_json, "hosted-app") == "true":
        hosted_app = True
    if not createIndexFile(os.path.join(BUILD_ROOT_SRC_PKG_APP, "index.html"), hosted_app):
        return False

    if not hosted_app:
        if "blacklist" not in build_json:
            build_json.update({"blacklist": []})
        build_json["blacklist"].extend(PKG_BLACK_LIST)
        if not buildSRC(BUILD_ROOT_SRC, BUILD_ROOT_PKG_APP, build_json):
            return False

        if "subapp-list" in build_json:
            for i_sub_app in build_json["subapp-list"].keys():
                if not buildSubAPP(i_sub_app, build_json["subapp-list"][i_sub_app], BUILD_ROOT_PKG_APP):
                    return False

    if not packAPP(build_json, BUILD_ROOT_SRC_PKG_APP, BUILD_ROOT_PKG, PKG_NAME):
        return False

    return True
开发者ID:wanghongjuan,项目名称:crosswalk-test-suite,代码行数:35,代码来源:pack.py

示例2: buildSRC

def buildSRC(src=None, dest=None, build_json=None):
    if not os.path.exists(src):
        LOG.info("+Src dir does not exist, skip build src process ...")
        return True

    if not utils.doCopy(src, dest):
        return False
    if "blacklist" in build_json:
        if build_json["blacklist"].count("") > 0:
            build_json["blacklist"].remove("")
        black_file_list = []
        for i_black in build_json["blacklist"]:
            black_file_list = black_file_list + glob.glob(os.path.join(dest, i_black))

        black_file_list = list(set(black_file_list))
        if not utils.doRemove(black_file_list):
            return False
    if "copylist" in build_json:
        for i_s_key in build_json["copylist"].keys():
            if i_s_key and build_json["copylist"][i_s_key]:
                (src_updated, dest_updated) = updateCopylistPrefix(src, dest, i_s_key, build_json["copylist"][i_s_key])
                if not utils.doCopy(src_updated, dest_updated):
                    return False

    return True
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:25,代码来源:pack.py

示例3: buildPKGAPP

def buildPKGAPP(build_json=None):
    LOG.info("+Building package APP ...")
    if not utils.doCopy(os.path.join(BUILD_ROOT_SRC, "icon.png"),
                  os.path.join(BUILD_ROOT_SRC_PKG_APP, "icon.png")):
        return False

    hosted_app = False
    if utils.safelyGetValue(build_json, "hosted-app") == "true":
        hosted_app = True
    if not createIndexFile(
            os.path.join(BUILD_ROOT_SRC_PKG_APP, "index.html"), hosted_app):
        return False

    if not hosted_app:
        if "blacklist" not in build_json:
            build_json.update({"blacklist": []})
        build_json["blacklist"].extend(PKG_BLACK_LIST)
        if not buildSRC(BUILD_ROOT_SRC, BUILD_ROOT_PKG_APP, build_json):
            return False

        if "subapp-list" in build_json:
            for i_sub_app in build_json["subapp-list"].keys():
                if not buildSubAPP(
                        i_sub_app, build_json["subapp-list"][i_sub_app],
                        BUILD_ROOT_PKG_APP):
                    return False

    if not packAPP(
            build_json, BUILD_ROOT_SRC_PKG_APP, BUILD_ROOT_PKG, PKG_NAME):
        return False

    return True
开发者ID:galeleo777,项目名称:crosswalk-test-suite,代码行数:32,代码来源:pack.py

示例4: prepareBuildRoot

def prepareBuildRoot():
    LOG.info("+Preparing build root folder ...")
    global BUILD_ROOT
    global BUILD_ROOT_SRC
    global BUILD_ROOT_SRC_PKG
    global BUILD_ROOT_SRC_PKG_APP
    global BUILD_ROOT_SRC_SUB_APP
    global BUILD_ROOT_PKG
    global BUILD_ROOT_PKG_APP

    while True:
        BUILD_ROOT = os.path.join("/tmp", utils.getRandomStr())
        if os.path.exists(BUILD_ROOT):
            continue
        else:
            break

    BUILD_ROOT_SRC = os.path.join(BUILD_ROOT, PKG_NAME)
    BUILD_ROOT_SRC_PKG = os.path.join(BUILD_ROOT, "pkg")
    BUILD_ROOT_SRC_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app")
    BUILD_ROOT_SRC_SUB_APP = os.path.join(BUILD_ROOT, "sub-app")
    BUILD_ROOT_PKG = os.path.join(BUILD_ROOT, "pkg", "opt", PKG_NAME)
    BUILD_ROOT_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app", "opt", PKG_NAME)

    if not utils.doCopy(BUILD_PARAMETERS.srcdir, BUILD_ROOT_SRC):
        return False
    else:
        utils.replaceUserString(BUILD_ROOT_SRC, "*", "TESTER-HOME-DIR", "/home/%s" % BUILD_PARAMETERS.user)

    if not utils.doRemove(glob.glob(os.path.join(BUILD_ROOT_SRC, "%s*.zip" % PKG_NAME))):
        return False

    return True
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:33,代码来源:pack.py

示例5: packIOS

def packIOS(build_json = None, app_src = None, app_dest = None, app_name = None):
    '''
    Build iOS ipa via crosswalk-app, currently crosswalk-pkg for iOS does not
    support yet.
    '''
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")

    package_id = 'org.xwalk.{app_name}'.format(
                            app_name = app_name.replace('-', ''))
    create_cmd = 'crosswalk-app create {package_id} --platform=ios'.format(
                                        package_id = package_id)

    orig_dir = os.getcwd()
    os.chdir(BUILD_ROOT)
    if not utils.doCMD(create_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    move_app_cmd =  'mv -fv {app_src}/* ' \
                    '{BUILD_ROOT}/{package_id}/app/'.format(
                        app_src = app_src,
                        BUILD_ROOT = BUILD_ROOT,
                        package_id = package_id)
    if not utils.doCMD(move_app_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    os.chdir(package_id)
    create_cmd = 'crosswalk-app build'
    if not utils.doCMD(create_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    ipa_files = glob.glob(os.path.join(BUILD_ROOT, package_id, "*.ipa"))
    if ipa_files:
        rename_app_name = app_name.replace('-', '_')
        if not utils.doCopy(ipa_files[0],
                            os.path.join(
                                app_dest,
                                "{app_name}.ipa".format(
                                    app_name = rename_app_name)
                            )):
            os.chdir(orig_dir)
            return False
    else:
        LOG.error("Fail to find the ipa file")
        os.chdir(orig_dir)
        return False

    return True
开发者ID:BruceDai,项目名称:crosswalk-test-suite,代码行数:50,代码来源:build_ios.py

示例6: packWGT

def packWGT(build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    if not utils.zipDir(app_src, os.path.join(app_dest, "%s.wgt" % app_name)):
        return False

    if BUILD_PARAMETERS.signature == True:
        if utils.safelyGetValue(build_json, "sign-flag") == "true":
            if not os.path.exists(os.path.join(BUILD_ROOT, "signing")):
                if not utils.doCopy(
                        os.path.join(BUILD_PARAMETERS.pkgpacktools, "signing"),
                        os.path.join(BUILD_ROOT, "signing")):
                    return False
            signing_cmd = "%s --dist platform %s" % (
                os.path.join(BUILD_ROOT, "signing", "sign-widget.sh"),
                os.path.join(app_dest, "%s.wgt" % app_name))
            if not utils.doCMD(signing_cmd, DEFAULT_CMD_TIMEOUT):
                return False

    return True
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:21,代码来源:build_tizen.py

示例7: packXPK

def packXPK(build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    pack_tool = os.path.join(BUILD_ROOT, "make_xpk.py")
    if not os.path.exists(pack_tool):
        if not utils.doCopy(
                os.path.join(BUILD_PARAMETERS.pkgpacktools, "make_xpk.py"),
                pack_tool):
            return False
    orig_dir = os.getcwd()
    os.chdir(BUILD_ROOT)
    if os.path.exists("key.file"):
        if not utils.doRemove(["key.file"]):
            os.chdir(orig_dir)
            return False

    key_file = utils.safelyGetValue(build_json, "key-file")
    if key_file == "key.file":
        LOG.error(
            "\"key.file\" is reserved name for default key file, "
            "pls change the key file name ...")
        os.chdir(orig_dir)
        return False
    if key_file:
        pack_cmd = "python make_xpk.py %s %s -o %s" % (
            app_src, key_file, os.path.join(app_dest, "%s.xpk" % app_name))
    else:
        pack_cmd = "python make_xpk.py %s key.file -o %s" % (
            app_src, os.path.join(app_dest, "%s.xpk" % app_name))
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    os.chdir(orig_dir)
    return True
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:36,代码来源:build_tizen.py

示例8: packDeb

def packDeb(build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    BUILD_ROOT_SRC = varshop.getValue("BUILD_ROOT_SRC")
    BUILD_TIME= varshop.getValue("BUILD_TIME")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    app_name = app_name.replace("-", "_")

    if '_' in app_name:
        app_name = app_name.replace('_', '')

    files = glob.glob(os.path.join(BUILD_ROOT, "*.deb"))
    if files:
        if not utils.doRemove(files):
            return False

    url_opt = ""
    pkg_opt = ""

    tmp_opt = utils.safelyGetValue(build_json, "apk-pkg-opt")
    if tmp_opt:
        pkg_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-url-opt")
    if tmp_opt:
        url_opt = "%s" % tmp_opt


    manifest_opt = {}
    manifest_opt["name"] = "%s" % app_name
    print app_name + "test"
    if pkg_opt:
        manifest_opt["xwalk_package_id"] = "org.xwalk.%s" % pkg_opt
    else:
        manifest_opt["xwalk_package_id"] = "org.xwalk.%s" % app_name
    if url_opt:
        manifest_opt["start_url"] = url_opt
    else:
        manifest_opt["start_url"] = "index.html"
    manifest_opt = json.JSONEncoder().encode(manifest_opt)

    if utils.safelyGetValue(build_json, "apk-type") == "MANIFEST":
        pack_cmd = "crosswalk-pkg -p deb %s" % app_src
    else:
        pack_cmd = "crosswalk-pkg --manifest='%s' -p deb %s" % (manifest_opt, app_src)

    orig_dir = os.getcwd()
    os.chdir(os.path.join(BUILD_ROOT))
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT * 1.5):
        os.chdir(orig_dir)
        return False

    files = glob.glob(os.path.join(BUILD_ROOT, "*.deb"))
    if files:
        rename_app_name = utils.safelyGetValue(build_json, "app-name")
        if not rename_app_name:
            rename_app_name = app_name

        if not utils.doCopy(files[0], os.path.join(app_dest, "%s.deb" % rename_app_name)):
            os.chdir(orig_dir)
            return False
    else:
        LOG.error("Fail to find the deb file")
        os.chdir(orig_dir)
        return False

    os.chdir(orig_dir)
    return True
开发者ID:BruceDai,项目名称:crosswalk-test-suite,代码行数:68,代码来源:build_deb.py

示例9: main


#.........这里部分代码省略.........
        if (
            BUILD_PARAMETERS.subversion == "4.x" and BUILD_PARAMETERS.packtype
        ) and not BUILD_PARAMETERS.packtype in CORDOVA_PACK_TYPES:
            LOG.error("cordova packtype can only be npm, local")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == "3.6" or not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.packtype:
            LOG.error("cordova packtype is only for cordova version 4.x")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == "3.6" or not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.pkgarch:
            LOG.error("Command -a is not for cordova version 3.6")
            sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "embeddingapi":
        if BUILD_PARAMETERS.packtype and not BUILD_PARAMETERS.packtype in PACK_TYPES:
            LOG.error("embeddingapi packtype can only be gradle, maven or ant")
            sys.exit(1)
        if BUILD_PARAMETERS.subversion:
            BUILD_PARAMETERS.pkgtype = BUILD_PARAMETERS.pkgtype + BUILD_PARAMETERS.subversion

    all_pkg_string = "".join(config_json["pkg-list"].keys())
    if parameters_type and parameters_type in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if parameters_type in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break
    elif BUILD_PARAMETERS.pkgtype in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if BUILD_PARAMETERS.pkgtype in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break

    if pkg_json == config_json["pkg-list"].get("apk") and BUILD_PARAMETERS.subversion is not None:
        pkg_json = config_json["pkg-list"][BUILD_PARAMETERS.subversion]

    if not pkg_json:
        LOG.error("Fail to read pkg json, exit ...")
        sys.exit(1)

    if not prepareBuildRoot():
        exitHandler(1)

    if "pkg-blacklist" in config_json:
        PKG_BLACK_LIST.extend(config_json["pkg-blacklist"])

    try:
        varshop.setValue("BUILD_PARAMETERS", BUILD_PARAMETERS)
        varshop.setValue("BUILD_ROOT", BUILD_ROOT)
        varshop.setValue("BUILD_ROOT_SRC", BUILD_ROOT_SRC)
        varshop.setValue("BUILD_TIME", BUILD_TIME)
        varshop.setValue("CROSSWALK_BRANCH", CROSSWALK_BRANCH)
        varshop.setValue("CROSSWALK_VERSION", CROSSWALK_VERSION)
        varshop.setValue("DEFAULT_CMD_TIMEOUT", DEFAULT_CMD_TIMEOUT)
        varshop.setValue("PKG_MODES", PKG_MODES)
        varshop.setValue("PKG_ARCHS", PKG_ARCHS)
    except Exception as e:
        LOG.error("Fail to set global vars: %s, exit ..." % e)
        sys.exit(1)

    if not buildPKG(pkg_json):
        exitHandler(1)

    LOG.info("+Building package ...")
    if BUILD_PARAMETERS.pkgtype == "apk-aio" or BUILD_PARAMETERS.pkgtype == "cordova-aio":
        pkg_file_list = os.listdir(os.path.join(BUILD_ROOT, "pkg"))
        for i_file in pkg_file_list:
            if not utils.doCopy(
                os.path.join(BUILD_ROOT, "pkg", i_file), os.path.join(BUILD_PARAMETERS.destdir, i_file)
            ):
                exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype == "embeddingapi" and BUILD_PARAMETERS.subversion:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s-%s.%s.zip"
            % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.subversion, BUILD_PARAMETERS.pkgtype),
        )

        LOG.info("pkg_file: %s" % pkg_file)
        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype.startswith("embeddingapi") and BUILD_PARAMETERS.packtype:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s.%s-%s.zip"
            % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.pkgtype, BUILD_PARAMETERS.packtype),
        )

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    else:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s.%s.zip" % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.pkgtype),
        )

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:101,代码来源:pack.py

示例10: packCordova_cli

def packCordova_cli(
        build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    CROSSWALK_BRANCH= varshop.getValue("CROSSWALK_BRANCH")
    CROSSWALK_VERSION= varshop.getValue("CROSSWALK_VERSION")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    app_name = app_name.replace("-", "_")
    project_root = os.path.join(BUILD_ROOT, app_name)

    output = commands.getoutput("cordova -v")
    output_version = int(output[0])
    if output_version < 5:
        LOG.error(
            "Cordova 4.x build requires the latest Cordova CLI, and must >= 5.0.0, install with command: '$ sudo npm install cordova -g'")
        return False

    plugin_tool = os.path.join(BUILD_ROOT, "cordova_plugins")
    plugin_source = os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins")
    if not os.path.exists(plugin_tool):
        if os.path.exists(plugin_source):
            if not utils.doCopy(
                    os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins"),
                    plugin_tool):
                return False
    extra_plugins = os.path.join(BUILD_ROOT, "extra_plugins")
    if os.path.exists(extra_plugins):
        if not utils.doCopy(extra_plugins, plugin_tool):
            return False

    orig_dir = os.getcwd()
    os.chdir(BUILD_ROOT)
    pack_cmd = "cordova create %s org.xwalk.%s %s" % (
        app_name, app_name, app_name)
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    # Set activity name as app_name
    utils.replaceUserString(
        project_root,
        'config.xml',
        '<widget',
        '<widget android-activityName="%s"' %
        app_name)
    # Workaround for XWALK-3679
    utils.replaceUserString(
        project_root,
        'config.xml',
        '</widget>',
        '    <allow-navigation href="*" />\n</widget>')

    if not utils.doRemove([os.path.join(project_root, "www")]):
        return False
    if not utils.doCopy(app_src, os.path.join(project_root, "www")):
        os.chdir(orig_dir)
        return False

    os.chdir(project_root)
    pack_cmd = "cordova platform add android"
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    pkg_mode_tmp = "shared"
    if BUILD_PARAMETERS.pkgmode == "embedded":
        pkg_mode_tmp = "core"

    xwalk_version = "%s" % CROSSWALK_VERSION
    if CROSSWALK_BRANCH == "beta":
        xwalk_version = "org.xwalk:xwalk_%s_library_beta:%s" % (pkg_mode_tmp, CROSSWALK_VERSION)

    webview_plugin_name = "cordova-plugin-crosswalk-webview"
    plugin_dirs = os.listdir(plugin_tool)
    for i_dir in plugin_dirs:
        install_variable_cmd = ""
        i_plugin_dir = os.path.join(plugin_tool, i_dir)
        plugin_crosswalk_source = i_plugin_dir
        if i_dir == webview_plugin_name:
            if BUILD_PARAMETERS.packtype == "npm":
                plugin_crosswalk_source = webview_plugin_name
            install_variable_cmd = "--variable XWALK_MODE=\"%s\" --variable XWALK_VERSION=\"%s\"" \
                    % (BUILD_PARAMETERS.pkgmode, xwalk_version)

        plugin_install_cmd = "cordova plugin add %s %s" % (plugin_crosswalk_source, install_variable_cmd)
        if not utils.doCMD(plugin_install_cmd, DEFAULT_CMD_TIMEOUT):
            os.chdir(orig_dir)
            return False

    ANDROID_HOME = "echo $(dirname $(dirname $(which android)))"
    os.environ['ANDROID_HOME'] = commands.getoutput(ANDROID_HOME)

    apk_name_arch = "armv7"
    pack_arch_tmp = "arm"
    if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch != "arm":
        apk_name_arch = BUILD_PARAMETERS.pkgarch
        if BUILD_PARAMETERS.pkgarch == "x86":
            pack_arch_tmp = "x86"
        elif BUILD_PARAMETERS.pkgarch == "x86_64":
            pack_arch_tmp = "x86 --xwalk64bit"
#.........这里部分代码省略.........
开发者ID:jennycao,项目名称:crosswalk-test-suite,代码行数:101,代码来源:build_cordova.py

示例11: packCordova

def packCordova(build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    pack_tool = os.path.join(BUILD_ROOT, "cordova")
    app_name = app_name.replace("-", "_")
    if not os.path.exists(pack_tool):
        if not utils.doCopy(
                os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova"),
                pack_tool):
            return False

    plugin_tool = os.path.join(BUILD_ROOT, "cordova_plugins")
    plugin_source = os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins")
    if not os.path.exists(plugin_tool):
        if os.path.exists(plugin_source):
            if not utils.doCopy(
                    os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins"),
                    plugin_tool):
                return False
    extra_plugins = os.path.join(BUILD_ROOT, "extra_plugins")
    if os.path.exists(extra_plugins):
        if not utils.doCopy(extra_plugins, plugin_tool):
            return False

    orig_dir = os.getcwd()
    os.chdir(pack_tool)

    if BUILD_PARAMETERS.pkgmode == "shared":
        pack_cmd = "bin/create %s org.xwalk.%s %s --xwalk-shared-library" % (
            app_name, app_name, app_name)
    else:
        pack_cmd = "bin/create %s org.xwalk.%s %s --shared" % (
            app_name, app_name, app_name)
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
        os.chdir(orig_dir)
        return False

    os.chdir(os.path.join(pack_tool, app_name))
    plugin_dirs = os.listdir(plugin_tool)
    for i_dir in plugin_dirs:
        i_plugin_dir = os.path.join(plugin_tool, i_dir)
        plugin_install_cmd = "plugman install --platform android --project " \
                             "./ --plugin %s" % i_plugin_dir
        if not utils.doCMD(plugin_install_cmd, DEFAULT_CMD_TIMEOUT):
            os.chdir(orig_dir)
            return False
    os.chdir(pack_tool)

    if not utils.doCopy(app_src, os.path.join(pack_tool, app_name, "assets", "www")):
        os.chdir(orig_dir)
        return False
    os.chdir(os.path.join(BUILD_ROOT, "cordova", app_name))
    ANDROID_HOME = "echo $(dirname $(dirname $(which android)))"
    os.environ['ANDROID_HOME'] = commands.getoutput(ANDROID_HOME)
    pack_cmd = "./cordova/build"

    if BUILD_PARAMETERS.subversion == '4.x':
        if BUILD_PARAMETERS.pkgarch == "x86":
            cordova_tmp_path = os.path.join(
                BUILD_ROOT,
                "cordova",
                app_name,
                "build",
                "outputs",
                "apk",
                "%s-x86-debug.apk" %
                app_name)
        else:
            cordova_tmp_path = os.path.join(
                BUILD_ROOT,
                "cordova",
                app_name,
                "build",
                "outputs",
                "apk",
                "%s-armv7-debug.apk" %
                app_name)
    else:
        cordova_tmp_path = os.path.join(
            BUILD_ROOT,
            "cordova",
            app_name,
            "bin",
            "%s-debug.apk" %
            app_name)
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
        pack_cmd = "ant debug"
        if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT):
            os.chdir(orig_dir)
            return False

    if not utils.doCopy(cordova_tmp_path,
                  os.path.join(app_dest, "%s.apk" % app_name)):
        os.chdir(orig_dir)
        return False
    os.chdir(orig_dir)
    return True
开发者ID:jennycao,项目名称:crosswalk-test-suite,代码行数:98,代码来源:build_cordova.py

示例12: packMsi

def packMsi(build_json=None, app_src=None, app_dest=None, app_name=None):

    if os.path.exists(os.path.join(app_src, "icon.png")):
        if not utils.doCopy(os.path.join(app_src, "icon.png"),
                os.path.join(app_src, "icon.ico")):
            return False

    pkg_name = "org.xwalk." + app_name.replace("-", "")

    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    BUILD_ROOT_SRC = varshop.getValue("BUILD_ROOT_SRC")
    BUILD_TIME= varshop.getValue("BUILD_TIME")
    CROSSWALK_VERSION = varshop.getValue("CROSSWALK_VERSION")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    PKG_MODES= varshop.getValue("PKG_MODES")
    PKG_ARCHS= varshop.getValue("PKG_ARCHS")
    get_real_arch = {"x86": "x86",
                     "x86_64": "x86_64",
                     "arm": "armeabi-v7a",
                     "arm64": "arm64-v8a"}

    windows_opt = ""
    ext_opt = []
    cmd_opt = ""
    url_opt = ""
    mode_opt = ""
    arch_opt = ""
    icon_opt = ""
    icons_opt = []
    version_opt = ""
    pkg_opt = ""
    version_code_opt = ""
    fullscreen_opt = ""
    orientation_opt = ""
    screenOn_opt = ""
    animatableView_opt = ""
    webp_opt = ""
    shortName_opt = ""
    permissions_opt = []

    tmp_opt = utils.safelyGetValue(build_json, "google-api-key")
    if tmp_opt:
        source_keys_file = os.path.join(BUILD_PARAMETERS.pkgpacktools, "resources", "keys", "crosswalk-app-tools-keys.json")
        userName = os.getenv("USERNAME")
        dest_keys_file = "C:\\Users\\%s\\.crosswalk-app-tools-keys.json" % userName
        if not utils.doCopy(
                source_keys_file,
                dest_keys_file):
            return False
        windows_opt = "-w google-api-key:%s" % tmp_opt

    common_opts = utils.safelyGetValue(build_json, "apk-common-opts")
    if common_opts is None:
        common_opts = " -r "
    else:
        common_opts_array = common_opts.split()
        if "-r" in common_opts_array:
            pass
        elif "--enable-remote-debugging" in common_opts_array:
            common_opts = common_opts.replace('--enable-remote-debugging', '')
        else:
            common_opts += " -r "
    #workaround for XWALK-4042
    #common_opts = common_opts.replace(' -r ','')

    tmp_opt = utils.safelyGetValue(build_json, "apk-ext-opt")
    if tmp_opt:
        ext_opt = tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-version-opt")
    if tmp_opt:
        version_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-fullscreen-opt")
    if tmp_opt:
        fullscreen_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-pkg-opt")
    if tmp_opt:
        pkg_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-cmd-opt")
    if tmp_opt:
        cmd_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-url-opt")
    if tmp_opt:
        url_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-orientation-opt")
    if tmp_opt:
        orientation_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-screenOn-opt")
    if tmp_opt:
        screenOn_opt = "%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-animatableView-opt")
    if tmp_opt:
#.........这里部分代码省略.........
开发者ID:BruceDai,项目名称:crosswalk-test-suite,代码行数:101,代码来源:build_msi.py

示例13: packAPK


#.........这里部分代码省略.........
    tmp_opt = utils.safelyGetValue(build_json, "apk-icon-opt")
    if tmp_opt:
        icon_opt = "%s" % tmp_opt
        icon_set = {}
        icon_set["src"] = icon_opt
        icon_set["sizes"] = "72x72"
        icons_opt = [icon_set]
    elif tmp_opt == "":
        pass
    else:
        icon_opt = "icon.png"
        icon_set = {}
        icon_set["src"] = icon_opt
        icon_set["sizes"] = "72x72"
        icons_opt = [icon_set]

    manifest_opt = {}
    manifest_opt["name"] = "%s" % app_name
    if pkg_opt:
        manifest_opt["xwalk_package_id"] = "org.xwalk.%s" % pkg_opt
    else:
        manifest_opt["xwalk_package_id"] = "org.xwalk.%s" % app_name
    if url_opt:
        manifest_opt["start_url"] = url_opt
    else:
        manifest_opt["start_url"] = "index.html"
    if ext_opt:
        manifest_opt["xwalk_extensions"] = ext_opt
    if cmd_opt:
        manifest_opt["xwalk_command_line"] = cmd_opt
    if fullscreen_opt:
        manifest_opt["display"] = fullscreen_opt
    if version_opt:
        manifest_opt["xwalk_app_version"] = version_opt
    if icons_opt and \
           utils.safelyGetValue(build_json, "apk-type") != "MANIFEST":
        manifest_opt["icons"] = icons_opt
    if orientation_opt:
        manifest_opt["orientation"] = orientation_opt
    if screenOn_opt:
        manifest_opt["xwalk_android_keep_screen_on"] = screenOn_opt
    if animatableView_opt:
        manifest_opt["xwalk_android_animatable_view"] = animatableView_opt
    if webp_opt:
        manifest_opt["xwalk_android_webp"] = webp_opt
    if shortName_opt:
        manifest_opt["short_name"] = shortName_opt
    if permissions_opt:
        manifest_opt["xwalk_android_permissions"] = permissions_opt 

    manifest_opt = json.JSONEncoder().encode(manifest_opt)

    crosswalk_version_opt = CROSSWALK_VERSION

    app_tools_dir = os.environ.get('CROSSWALK_APP_TOOLS_CACHE_DIR')
    if app_tools_dir:
        if "64" in arch_opt and os.path.exists(os.path.join(app_tools_dir,
                "crosswalk-%s-64bit.zip" % CROSSWALK_VERSION)):
            crosswalk_version_opt = os.path.join(app_tools_dir,
                    "crosswalk-%s-64bit.zip" % CROSSWALK_VERSION)
        elif os.path.exists(os.path.join(app_tools_dir,
                "crosswalk-%s.zip" % CROSSWALK_VERSION)):
            crosswalk_version_opt = os.path.join(app_tools_dir,
                    "crosswalk-%s.zip" % CROSSWALK_VERSION)
        else:
            crosswalk_version_opt = CROSSWALK_VERSION

    if utils.safelyGetValue(build_json, "apk-type") == "MANIFEST":
        pack_cmd = "crosswalk-pkg %s --crosswalk=%s " \
                   "-p android --targets=\"%s\" %s %s" % (
                       mode_opt, crosswalk_version_opt, arch_opt, common_opts,
                       app_src)
    else:
        pack_cmd = "crosswalk-pkg %s --crosswalk=%s --manifest='%s' " \
                   "-p android --targets=\"%s\" %s %s" % (
                       mode_opt, crosswalk_version_opt, manifest_opt, arch_opt,
                       common_opts, app_src)

    orig_dir = os.getcwd()
    os.chdir(os.path.join(BUILD_ROOT))
    if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT * 1.5):
        os.chdir(orig_dir)
        return False

    files = glob.glob(os.path.join(BUILD_ROOT, "*.apk"))
    if files:
        rename_app_name = utils.safelyGetValue(build_json, "app-name")
        if not rename_app_name:
            rename_app_name = getNameById(files[0])
        rename_app_name = rename_app_name.replace("-", "_")
        if not utils.doCopy(files[0], os.path.join(app_dest, "%s.apk" % rename_app_name)):
            os.chdir(orig_dir)
            return False
    else:
        LOG.error("Fail to find the apk file")
        os.chdir(orig_dir)
        return False

    os.chdir(orig_dir)
    return True
开发者ID:crosswalk-project,项目名称:demo-express,代码行数:101,代码来源:build_android.py

示例14: copy_resource

def copy_resource(pkgtype):
    try:
        json_file = os.path.join(ROOT_DIR, "suite.json")
        if not os.path.exists(json_file):
            print "%s does not exist" % json_file
            sys.exit(1)

        print ">>>> suite.json: %s" % json_file
        print ">>>>   pkg type: %s" % pkgtype

        suite_json = None
        pkg_json = None
        try:
            with open(json_file, "rt") as suite_json_file:
                suite_json_raw = suite_json_file.read()
                suite_json_file.close()
                suite_json = json.loads(suite_json_raw)
        except Exception as e:
            print "Fail to read json file: %s, exit ..." % json_file
            sys.exit(1)

        all_pkg_string = suite_json["pkg-list"].keys()
        for i_pkg in all_pkg_string:
            i_pkg_list = i_pkg.strip().split(",")
            if pkgtype in i_pkg_list:
                pkg_json = suite_json["pkg-list"][i_pkg]
        if pkg_json is None:
            print "No %s type config in %s" % (pkgtype, json_file)

        # package copylist
        if "copylist" in pkg_json:
            main_copylist = pkg_json["copylist"]
            for i_s_key in main_copylist.keys():
                src_path = os.path.join(ROOT_DIR, i_s_key).replace("PACK-TOOL-ROOT", "../../tools")
                dest_path = os.path.join(ROOT_DIR, main_copylist[i_s_key])
                utils.doCopy(src_path, dest_path)

        # pkg-app copylist
        if "pkg-app" in pkg_json:
            pkg_app_json = pkg_json["pkg-app"]
            if "copylist" in pkg_app_json:
                pkg_app_copylist = pkg_app_json["copylist"]
                for i_s_key in pkg_app_copylist.keys():
                    src_path = os.path.join(ROOT_DIR, i_s_key).replace("PACK-TOOL-ROOT", "../../tools")
                    dest_path = os.path.join(ROOT_DIR, pkg_app_copylist[i_s_key])
                    utils.doCopy(src_path, dest_path)

        # subapp-list copylist
        if "subapp-list" in pkg_json:
            subapp_list_json = pkg_json["subapp-list"]
            for subapp_str in subapp_list_json.keys():
                subapp_json = subapp_list_json[subapp_str]
                subapp_path = os.path.join(ROOT_DIR, subapp_str)
                if "copylist" in subapp_json and os.path.exists(subapp_path):
                    subapp_copylist = subapp_json["copylist"]
                    for i_s_key in subapp_copylist.keys():
                        src_path = os.path.join(subapp_path, i_s_key).replace("PACK-TOOL-ROOT", "../../tools")
                        dest_path = os.path.join(subapp_path, subapp_copylist[i_s_key])
                        utils.doCopy(src_path, dest_path)
    except Exception as e:
        print "Get Exception: %s, exit ..." % e
        sys.exit(1)
开发者ID:BruceDai,项目名称:crosswalk-test-suite,代码行数:62,代码来源:resource_only.py

示例15: packAPK

def packAPK(build_json=None, app_src=None, app_dest=None, app_name=None):
    BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS")
    BUILD_ROOT = varshop.getValue("BUILD_ROOT")
    BUILD_ROOT_SRC = varshop.getValue("BUILD_ROOT_SRC")
    BUILD_TIME= varshop.getValue("BUILD_TIME")
    DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT")
    PKG_MODES= varshop.getValue("PKG_MODES")
    PKG_ARCHS= varshop.getValue("PKG_ARCHS")
    app_name = app_name.replace("-", "_")

    if not os.path.exists(os.path.join(BUILD_ROOT, "crosswalk")):
        if not utils.doCopy(
                os.path.join(BUILD_PARAMETERS.pkgpacktools, "crosswalk"),
                os.path.join(BUILD_ROOT, "crosswalk")):
            return False

    files = glob.glob(os.path.join(BUILD_ROOT, "crosswalk", "*.apk"))
    if files:
        if not utils.doRemove(files):
            return False

    ext_opt = ""
    cmd_opt = ""
    url_opt = ""
    mode_opt = ""
    arch_opt = ""
    icon_opt = ""
    version_opt = ""
    pkg_opt = ""
    version_code_opt = ""
    fullscreen_opt = ""

    common_opts = utils.safelyGetValue(build_json, "apk-common-opts")
    if common_opts is None:
        common_opts = ""

    tmp_opt = utils.safelyGetValue(build_json, "apk-ext-opt")
    if tmp_opt:
        ext_opt = "--extensions='%s'" % os.path.join(BUILD_ROOT_SRC, tmp_opt)

    tmp_opt = utils.safelyGetValue(build_json, "apk-version-opt")
    if tmp_opt:
        version_opt = "--app-version='%s'" % ''.join([tmp_opt, BUILD_TIME])
        version_code_opt = "--app-versionCode='%s'" % ''.join(
            ['6', BUILD_TIME])

    tmp_opt = utils.safelyGetValue(build_json, "apk-fullscreen-opt")
    if tmp_opt:
        ext_opt = "--%s" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-pkg-opt")
    if tmp_opt:
        pkg_opt = "--package='org.xwalk.%s'" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-cmd-opt")
    if tmp_opt:
        cmd_opt = "--xwalk-command-line='%s'" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-url-opt")
    if tmp_opt:
        url_opt = "--app-url='%s'" % tmp_opt

    tmp_opt = utils.safelyGetValue(build_json, "apk-mode-opt")
    if tmp_opt:
        if tmp_opt in PKG_MODES:
            mode_opt = "--mode=%s" % tmp_opt
        else:
            LOG.error("Got wrong app mode: %s" % tmp_opt)
            return False
    else:
        mode_opt = "--mode=%s" % BUILD_PARAMETERS.pkgmode

    tmp_opt = utils.safelyGetValue(build_json, "apk-arch-opt")
    if tmp_opt:
        if tmp_opt in PKG_ARCHS:
            arch_opt = "--arch=%s" % tmp_opt
        else:
            LOG.error("Got wrong app arch: %s" % tmp_opt)
            return False
    else:
        arch_opt = "--arch=%s" % BUILD_PARAMETERS.pkgarch

    tmp_opt = utils.safelyGetValue(build_json, "apk-icon-opt")
    if tmp_opt:
        icon_opt = "--icon=%s" % tmp_opt
    elif tmp_opt == "":
        icon_opt = ""
    else:
        icon_opt = "--icon=%s/icon.png" % app_src

    if utils.safelyGetValue(build_json, "apk-type") == "MANIFEST":
        pack_cmd = "python make_apk.py --package=org.xwalk.%s " \
            "--manifest=%s/manifest.json  %s %s %s %s %s %s %s %s %s" % (
                app_name, app_src, mode_opt, arch_opt,
                ext_opt, cmd_opt, common_opts, version_opt, pkg_opt, version_code_opt, fullscreen_opt)
    elif utils.safelyGetValue(build_json, "apk-type") == "HOSTEDAPP":
        if not url_opt:
            LOG.error(
                "Fail to find the key \"apk-url-opt\" for hosted APP packing")
            return False
#.........这里部分代码省略.........
开发者ID:astojilj,项目名称:crosswalk-test-suite,代码行数:101,代码来源:build_android.py


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