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


Python Manifest.instance_of_sample方法代码示例

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


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

示例1: wrap_manifest_file

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import instance_of_sample [as 别名]
    def wrap_manifest_file(self, file_path):
        """
        Generated manifest file
        """
        try:
            all_prs = self.get_all_related_prs(self.__repo, self.__merge_commit_sha, self.__pr_number)
            under_test_prs = self.get_under_test_prs()
            # instance of manifest template
            manifest = Manifest.instance_of_sample("manifest-pr-gate.json")

            # wrap with pr
            repo_url_list = [repo["repository"] for repo in manifest.repositories]
            for pr in all_prs:
                repo, sha1, _ = pr
                repo_url = "https://github.com/{0}.git".format(repo)
                # uniform the repo_url case, make sure the url is completely consistent with repo in the manifest
                repo_url = [url for url in repo_url_list if url.lower() == repo_url][0]
                if repo in under_test_prs:
                    manifest.update_manifest(repo_url, "", sha1, True)
                else:
                    manifest.update_manifest(repo_url, "", sha1, False)

            # fill in blank commit with latest commit sha
            for repo in manifest.repositories:
                if 'commit-id' in repo and repo['commit-id'] == "":
                    repo_name = "/".join(repo["repository"][:-4].split("/")[3:])
                    latest_commit = self.get_latest_commit(repo_name, self.__target_branch)
                    repo["commit-id"] = latest_commit

            manifest.validate_manifest()
            manifest.dump_to_json_file(file_path)

        except Exception as error:
            print "ERROR occured in parse manifest: {0}".format(error)
            sys.exit(1)
开发者ID:RackHD,项目名称:on-build-config,代码行数:37,代码来源:pr_parser.py

示例2: __init__

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import instance_of_sample [as 别名]
 def __init__(self, dest, builddir, git_credential=None, force=False, jobs=1):
     self._jenkins_author = config.gitbit_identity["username"]
     self._dest_manifest_file = dest
     self._builddir = builddir
     self._force = force
     self._jobs = jobs
     self._manifest = Manifest.instance_of_sample()
     self.repo_operator = RepoOperator(git_credential)
     self.check_builddir()
开发者ID:RackHD,项目名称:on-build-config,代码行数:11,代码来源:ManifestGenerator.py

示例3: download_manifest_file

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import instance_of_sample [as 别名]
    def download_manifest_file(self):
        """
        Download the manifest json files. Return that directory name which stores manifest. The directory
        is temporary and deleted in the cleanup_and_exit function
        :return: A string containing the name of the folder where the manifest file was download.
        """
        directory_name = tempfile.mkdtemp()

        if os.path.isdir(directory_name):
            pass
            # For now script of 'upload to bintray' is seperated from this script.
            # So before uploading this directory shouldn't be deleted'
            # The blow code snippet will be unfolded when involved bintray upload functions into this script.
            # self.__cleanup_directories.append(directory_name)
        else:
            self.cleanup_and_exit("Failed to make temporary directory for the repository: {0}".format(url), 1)
        try:
            url = "/".join([self.__manifest_download_url, self.__manifest_file])
            dest_dir = "/".join([directory_name, self.__manifest_file])
            if os.environ['BINTRAY_USERNAME'] and os.environ['BINTRAY_API_KEY']:
                print "Requests bintray with token"
                auth = (os.environ['BINTRAY_USERNAME'].strip(), os.environ['BINTRAY_API_KEY'].strip())
                resp = requests.get(url, auth=auth)
            else:
                print "Requests without token"
                resp = requests.get(url)
            if resp.ok:
                with open(dest_dir, "wb") as file_handle:
                    file_handle.write(resp.content)
            elif resp.status_code==404:
                # If there's no manifest file in bintray server, init an empty one
                print "can't find manifest in remote server, will use template manifest"
                Manifest.instance_of_sample().dump_to_json_file(dest_dir)
            else:
                print "Unknown error, {0}".format(resp.status_code) 
            return directory_name
        except RuntimeError as error:
            self.cleanup_and_exit(error, 1)
开发者ID:RackHD,项目名称:on-build-config,代码行数:40,代码来源:update_manifest.py

示例4: __init__

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import instance_of_sample [as 别名]
    def __init__(self, dest, branch, builddir, git_credential, force=False, jobs=1):
        """
        Generate a new manifest according to the manifest sample: manifest.json

        _dest_manifest_file: the path of new manifest
        _branch: the branch name
        _force: overwrite the destination if it exists.
        _builddir: the destination for checked out repositories.
        _jobs: number of parallel jobs to run. The number is related to the compute architecture, multi-core processors...
        :return: None
        """
        self._dest_manifest_file = dest
        self._branch = branch
        self._builddir = builddir
        self._force = force
        self._jobs = jobs
        self._manifest = Manifest.instance_of_sample()
        self.repo_operator = RepoOperator(git_credential)
        self.check_builddir()
开发者ID:PengTian0,项目名称:on-tools,代码行数:21,代码来源:ManifestGenerator.py


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