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


Python Utils.jsonread方法代码示例

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


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

示例1: verifyImageTypeAndConfig

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
def verifyImageTypeAndConfig(config_file, img_name):
    # All of the below combinations are supported
    # 1. make image IMG_NAME=<name>
    # 2. make image IMG_NAME=<name> CONFIG=<config_file_path>
    # 3. make image CONFIG=<config_file_path>
    config = None
    if img_name and img_name != '':
        # Verify there is a directory corresponding to image
        if img_name not in next(os.walk('.'))[1]:
            return (False, config)
        if config_file and config_file != '' and os.path.isfile(config_file):
            config = Utils.jsonread(config_file)
            if 'image_type' in config and config['image_type'] != img_name:
                return (False, config)
        else:
            config_file = img_name + "/config_" + img_name + ".json"
            if os.path.isfile(config_file):
                config = Utils.jsonread(config_file)
                if 'image_type' not in config:
                    config['image_type'] = img_name
            else:
                return (False, config)
        return (True, config)
    else:
        if not config_file or config_file == '':
            return (False, config)
        else:
            config = Utils.jsonread(config_file)
            if 'image_type' not in config:
                return (False, config)
            else:
                return (True, config)
开发者ID:frapposelli,项目名称:photon,代码行数:34,代码来源:imagebuilder.py

示例2: create_pkg_list_to_copy_to_iso

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
def create_pkg_list_to_copy_to_iso(build_install_option, output_data_path):
    option_list_json = Utils.jsonread(build_install_option)
    options_sorted = option_list_json.items()
    packages = []
    for install_option in options_sorted:
        if install_option[0] != "iso":
            file_path = os.path.join(output_data_path, install_option[1]["file"])
            package_list_json = Utils.jsonread(file_path)
            packages = packages + package_list_json["packages"]
    return packages
开发者ID:frapposelli,项目名称:photon,代码行数:12,代码来源:imagebuilder.py

示例3: runInstaller

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
def runInstaller(options, config):
    try:
        sys.path.insert(0, options.installer_path)
        from installer import Installer
        from packageselector import PackageSelector
    except:
        raise ImportError('Installer path incorrect!')
    config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file
    
    # Check the installation type
    option_list_json = Utils.jsonread(options.package_list_file)
    options_sorted = option_list_json.items()

    packages = []
    if 'type' in config:
        for install_option in options_sorted:
            if install_option[0] == config['type']:
                packages = PackageSelector.get_packages_to_install(install_option[1]['packagelist_file'],
                                                               options.generated_data_path)
                break
    else:
        if 'packagelist_file' in config:
            packages = PackageSelector.get_packages_to_install(config['packagelist_file'],
                                                               options.generated_data_path)
        if 'additional_packages' in config:
            packages = packages.extend(config['additional_packages'])

    config['packages'] = packages
    # Run the installer
    package_installer = Installer(config, rpm_path=options.rpm_path,
                                  log_path=options.log_path, log_level=options.log_level)
    return package_installer.install(None)
开发者ID:frapposelli,项目名称:photon,代码行数:34,代码来源:imagebuilder.py

示例4: create_additional_file_list_to_copy_in_iso

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
def create_additional_file_list_to_copy_in_iso(base_path, build_install_option):
    option_list_json = Utils.jsonread(build_install_option)
    options_sorted = option_list_json.items()
    file_list = []
    for install_option in options_sorted:
        if "additional-files" in install_option[1]:
            file_list = file_list + list(map(
                lambda filename: os.path.join(base_path, filename),
                install_option[1].get("additional-files")))
    return file_list
开发者ID:frapposelli,项目名称:photon,代码行数:12,代码来源:imagebuilder.py

示例5: create_rpm_list_to_be_copied_to_iso

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
def create_rpm_list_to_be_copied_to_iso(pkg_to_rpm_map_file, build_install_option, copy_flags,
                                        output_data_path):
    packages = []
    if build_install_option is None:
        packages = []
    else:
        packages = create_pkg_list_to_copy_to_iso(build_install_option, output_data_path)

    rpm_list = []
    pkg_to_rpm_map = Utils.jsonread(pkg_to_rpm_map_file)
    for k in pkg_to_rpm_map:
        if build_install_option is None or k in packages:
            if not pkg_to_rpm_map[k]['rpm'] is None and bool(copy_flags & 1):
                filename = pkg_to_rpm_map[k]['rpm']
                rpm_list.append(get_file_name_with_last_folder(filename))
            if not pkg_to_rpm_map[k]['debugrpm'] is None and bool(copy_flags & 2):
                filename = pkg_to_rpm_map[k]['debugrpm']
                rpm_list.append(pkg_to_rpm_map[k]['debugrpm'])
            if not pkg_to_rpm_map[k]['sourcerpm'] is None and bool(copy_flags & 4):
                rpm_list.append(pkg_to_rpm_map[k]['sourcerpm'])
    return rpm_list
开发者ID:frapposelli,项目名称:photon,代码行数:23,代码来源:imagebuilder.py

示例6: ArgumentParser

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
    usage = "Usage: %prog [options]"
    parser = ArgumentParser(usage)

    parser.add_argument("-r", "--raw-image-path", dest="raw_image_path")
    parser.add_argument("-c", "--vmdk-config-path", dest="vmdk_config_path")
    parser.add_argument("-w", "--working-directory", dest="working_directory")
    parser.add_argument("-m", "--mount-path", dest="mount_path")
    parser.add_argument("-a", "--additional-rpms-path", dest="additional_rpms_path")
    parser.add_argument("-i", "--image-name", dest="image_name")
    parser.add_argument("-t", "--tools-bin-path", dest="tools_bin_path")
    parser.add_argument("-b", "--build-scripts-path", dest="build_scripts_path")
    parser.add_argument("-s", "--src-root", dest="src_root")

    options = parser.parse_args()
    utils = Utils()
    config = utils.jsonread(options.vmdk_config_path)
    print(options)

    disk_device = (utils.runshellcommand(
        "losetup --show -f {}".format(options.raw_image_path))).rstrip('\n')
    disk_partitions = utils.runshellcommand("kpartx -as {}".format(disk_device))
    device_name = disk_device.split('/')[2]

    if not os.path.exists(options.mount_path):
        os.mkdir(options.mount_path)
    loop_device_path = "/dev/mapper/{}p2".format(device_name)

    try:
        print("Generating PARTUUID for the loop device ...")
        partuuidval = (utils.runshellcommand(
            "blkid -s PARTUUID -o value {}".format(loop_device_path))).rstrip('\n')
开发者ID:TiejunChina,项目名称:photon,代码行数:33,代码来源:customize_cloud_image.py

示例7: createOutputArtifact

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import jsonread [as 别名]
        Utils.runshellcommand("kpartx -d {}".format(disk_device))
        Utils.runshellcommand("losetup -d {}".format(disk_device))

        shutil.rmtree(mount_path)
        createOutputArtifact(raw_image_path, config, src_root, tools_bin_path)
    
if __name__ == '__main__':
    parser = ArgumentParser()

    parser.add_argument("-r", "--raw-image-path", dest="raw_image_path")
    parser.add_argument("-c", "--config-path", dest="config_path")
    parser.add_argument("-a", "--additional-rpms-path", dest="additional_rpms_path")
    parser.add_argument("-t", "--tools-bin-path", dest="tools_bin_path")
    parser.add_argument("-s", "--src-root", dest="src_root")

    options = parser.parse_args()
    if config_path:
        config = Utils.jsonread(options.config_path)
    else:
        raise Exception("No config file defined")

    generateImage(
                options.raw_image_path,
                options.working_directory,
                options.additional_rpms_path,
                options.tools_bin_path,
                options.src_root,
                config
                )

开发者ID:frapposelli,项目名称:photon,代码行数:31,代码来源:imagegenerator.py


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