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


Python Manifest.validate_manifest方法代码示例

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


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

示例1: get_repo_commit

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import validate_manifest [as 别名]
def get_repo_commit(manifest_file):
    """
    build {repository:commit-id} dictionary, return the dict.
    """
    manifest = Manifest(manifest_file)
    manifest.validate_manifest()
    repo_commit_dict = {}
    for repo in manifest.repositories:
        repo_name = common.strip_suffix(os.path.basename(repo["repository"]), ".git")
        commit_id = repo["commit-id"]
        repo_commit_dict[repo_name] = commit_id
    print "[DEBUG] manifest repo_commit dict:", repo_commit_dict
    return repo_commit_dict
开发者ID:RackHD,项目名称:on-build-config,代码行数:15,代码来源:docker_version_check.py

示例2: validate_manifest_files

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import validate_manifest [as 别名]
 def validate_manifest_files(self, *args):
     """
     validate several manifest files
     For example: validate_manifest_files(file1, file2) or
                  validate_manifest_files(file1, file2, file3)
     """
     validate_result = True
     for filename in args:
         try:
             manifest = Manifest(filename)
             manifest.validate_manifest()
             print "manifest file {0} is valid".format(filename)
         except KeyError as error:
             print "Failed to validate manifest file {0}".format(filename)
             print "\nERROR: \n{0}".format(error.message)
             validate_result = False
     return validate_result
开发者ID:RackHD,项目名称:on-build-config,代码行数:19,代码来源:update_manifest.py

示例3: main

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import validate_manifest [as 别名]
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    try:
            manifest = Manifest(args.manifest)
            manifest.validate_manifest()
    except KeyError as error:
            print "Failed to create a Manifest instance for the manifest file {0} \nERROR:\n{1}"\
                  .format(args.manifest, error.message)
            sys.exit(1)


    if args.publish:
        if args.git_credential:
            repo_operator = RepoOperator(args.git_credential)
        else:
            print "Error occurs when get crendtail in update submodule"
            sys.exit(1)
    else:
        repo_operator = RepoOperator(args.git_credential)
    if os.path.isdir(args.build_dir):
        print args.build_dir
        for filename in os.listdir(args.build_dir):
            try:
                repo_dir = os.path.join(args.build_dir, filename)
                repo_operator.submodule_init(repo_dir)
                repo_operator.submodule_update(repo_dir) 
                submodules_list = repo_operator.get_current_submodule(repo_dir)
                if len(submodules_list)==0:
                    continue;
                for key in submodules_list:
                    commit_id = get_manifest_commit_id(key,manifest)
                    if commit_id != None:
                        sub_dir = repo_dir+"/"+key
                        repo_operator.checkout_to_commit(sub_dir,commit_id)
                if args.publish:
                    print "start to publish  update submodule in {0}".format(repo_dir)
                    commit_message = "update submodule for new commit {0}".format(args.version)
                    repo_operator.push_repo_changes(repo_dir, commit_message)
            except Exception,e:
                print "Failed to update submodule of {0} due to {1}".format(filename, e)
                sys.exit(1)
开发者ID:RackHD,项目名称:on-build-config,代码行数:44,代码来源:update_submodule.py

示例4: ManifestActions

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import validate_manifest [as 别名]
class ManifestActions(object):

    """
    valid actions:
    checkout: check out a set of repositories to match the manifest file
    """

    valid_actions = ["checkout"]

    def __init__(self, manifest_path, builddir):
        """
        __force - Overwrite a directory if it exists
        __git_credential - url, credentials pair for the access to github repos
        __manifest - Repository manifest contents
        __builddir - Destination for checked out repositories
        __jobs - Number of parallel jobs to run
        __actions -Supported actions
        :return:
        """
        self._force = False
        self._git_credentials = None
        self._builddir = builddir
        self._manifest = None
        self.handle_manifest(manifest_path)
        self._jobs = 1
        self.actions = []

        self.repo_operator = RepoOperator()

    def set_force(self, force):
        """
        Standard setter for force
        :param force: if true, overwrite a directory if it exists
        :return: None
        """
        self._force = force

    def get_force(self):
        """
        Standard getter for git_credentials
        :return: force
        """
        return force

    def set_git_credentials(self, git_credential):
        """
        Standard setter for git_credentials
        :param git_credential: url, credentials pair for the access to github repos
        :return: None
        """
        self._git_credentials = git_credential
        self.repo_operator.setup_gitbit(credentials=self._git_credentials)

    def get_manifest(self):
        """
        Standard getter for manifest
        :return: an instance of Manifest
        """
        return self._manifest

    def add_action(self, action):
        """
        Add action to actions
        :param action: a string, just like: checkout
        :return: None
        """
        if action not in self.valid_actions:
            print "Unknown action '{0}' requested".format(action)
            print "Valid actions are:"
            for op in self.valid_actions:
                print "  {0}".format(op)
            sys.exit(1)
        else:
            self.actions.append(action)

    def set_jobs(self, jobs):
        """
        Standard setter for jobs
        :param jobs: number of parallel jobs to run
        :return: None
        """
        self._jobs = jobs
        if self._jobs < 1:
            print "--jobs value must be an integer >=1"
            sys.exit(1)

    def handle_manifest(self, manifest_path):
        """
        initial manifest and validate it
        :param manifest_path: the path of manifest file
        :return: None
        """
        try:
            self._manifest = Manifest(manifest_path)
            self._manifest.validate_manifest()
        except KeyError as error:
            print "Failed to create a Manifest instance for the manifest file {0} \nERROR:\n{1}".format(
                manifest_path, error.message
            )
            sys.exit(1)
#.........这里部分代码省略.........
开发者ID:sunnyqianzhang,项目名称:on-tools,代码行数:103,代码来源:reprove.py

示例5: ManifestActions

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import validate_manifest [as 别名]

#.........这里部分代码省略.........
        :return: None
        """
        if action not in self.valid_actions:
            print "Unknown action '{0}' requested".format(action)
            print "Valid actions are:"
            for op in self.valid_actions:
                print "  {0}".format(op)
            sys.exit(1)
        else:
            if action in ['branch', 'tag'] and self._git_credentials == None:
                print "Must Specify git_credentials when try to write repository"
                sys.exit(1)
            self.actions.append(action)

    def set_jobs(self, jobs):
        """
        Standard setter for jobs
        :param jobs: number of parallel jobs to run
        :return: None
        """
        self._jobs = jobs
        if self._jobs < 1:
            print "--jobs value must be an integer >=1"
            sys.exit(1)

    def handle_manifest(self, manifest_path):
        """
        initial manifest and validate it
        :param manifest_path: the path of manifest file
        :return: None
        """
        try:
            self._manifest = Manifest(manifest_path)
            self._manifest.validate_manifest()
        except KeyError as error:
            print "Failed to create a Manifest instance for the manifest file {0} \nERROR:\n{1}"\
                  .format(manifest_path, error.message)
            sys.exit(1)
         
        for repo in self._manifest.repositories:
            repo['directory-name'] = self.directory_for_repo(repo)

    def check_builddir(self):
        """
        Checks the given builddir name and force flag. 
        Deletes exists directory if one already exists and --force is set
        :return: None
        """
        if os.path.exists(self._builddir):
            if self._force:
                shutil.rmtree(self._builddir)
                print "Removing existing data at {0}".format(self._builddir)
            else:
                print "Unwilling to overwrite destination builddir of {0}".format(self._builddir)
                sys.exit(1)

        os.makedirs(self._builddir)

    def get_repositories(self):
        """
        Issues checkout commands to dictionaries within a provided manifest
        :return: None
        """
        repo_list = self._manifest.repositories
        try:
            self.repo_operator.clone_repo_list(repo_list, self._builddir, jobs=self._jobs)
开发者ID:RackHD,项目名称:on-build-config,代码行数:70,代码来源:reprove.py


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