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


Python area.PTaskArea类代码示例

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


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

示例1: _complete

    def _complete(self, spec, relative_to=None):

        in_spec = self.spec.strip().strip(PTaskSpec.SEPARATOR)
        full_spec = PTaskSpec.get(in_spec, relative_to=relative_to)
        ptask_area = None

        # is the supplied spec a ptask area? if so, print sub directories
        # if not, get the parent spec and print its sub directories
        try:
            ptask_area = PTaskArea(full_spec)
        except PTaskAreaError:
            in_spec = PTaskSpec.parent(in_spec)
            full_spec = PTaskSpec.parent(full_spec)
            try:
                ptask_area = PTaskArea(full_spec)
            except PTaskAreaError:
                pass

        if not ptask_area:
            return

        # append the child name to the input spec and print them out for completion
        match_specs = []
        for area_dir in ptask_area.dirs(children=True, product_dirs=True):
            if in_spec:
                match_specs.append(in_spec + PTaskSpec.SEPARATOR + area_dir)
            else:
                match_specs.append(area_dir)

        return [m + PTaskSpec.SEPARATOR for m in match_specs]
开发者ID:chippey,项目名称:dpa-pipe,代码行数:30,代码来源:complete.py

示例2: _link_sub

    def _link_sub(self, sub, app):

        area = PTaskArea(self.ptask.spec, version=self.version)

        product_ver = sub.product_version

        try:
            product_ver_area = PTaskArea(product_ver.spec)
        except PTaskAreaError as e:
            raise ActionError(
                "Unable to locate product directory for: " + product_ver.spec
            )

        product_ver_path = product_ver_area.path

        product = product_ver.product

        product_ver_import_dir = os.path.join('import', app, product.name)
            
        try:
            area.provision(product_ver_import_dir)
        except PTaskAreaError as e:
            raise ActionError(
                "Failed to provision product import dir: " + str(e))
        
        link_name = os.path.join(area.path,
            product_ver_import_dir, product.category)

        print "Creating subscription {a} link for: {pv}".format(
            a=app, pv=product_ver.spec)

        os.symlink(product_ver_path, link_name)

        product_ver_area = PTaskArea(product_ver.spec)
开发者ID:chippey,项目名称:dpa-pipe,代码行数:34,代码来源:refresh.py

示例3: import_path

    def import_path(self, app="global"):
        product = self.product_version.product
        area = PTaskArea(self.ptask_version.ptask.spec)
        import_dir = area.dir(dir_name="import", verify=False, path=True)

        path = os.path.join(import_dir, app, product.name, product.category)

        if not os.path.exists(path):
            raise ProductSubscriptionError("Import path does not exist.")

        return path
开发者ID:liudger,项目名称:dpa-pipe,代码行数:11,代码来源:__init__.py

示例4: validate

    def validate(self):

        # current ptask/version
        try:
            area = PTaskArea.current()
            self._current_ptask = PTask.get(area.spec)
            self._current_ptask_version = self._current_ptask.latest_version
        except PTaskError:
            raise ActionError("Unable to find ptask: " + str(self._ptask))

        # source ptask
        if not isinstance(self._ptask, PTask):
            try:
                cur_spec = PTaskArea.current().spec
                full_spec = PTaskSpec.get(self._ptask, relative_to=cur_spec)
                self._ptask = PTask.get(full_spec)
            except PTaskError:
                raise ActionError("Unable to find ptask: " + str(self._ptask))

        # source ptask version
        if isinstance(self._version, PTaskVersion):
            pass
        elif self._version:
            matches = PTaskVersion.list(
                ptask=self._ptask.spec, number=self._version
            )
            if len(matches) != 1:
                raise ActionError(
                    "Unable to find ptask '{p}' at version '{v}'".format(
                        p=self._ptask.spec, v=self._version
                    )
                )
            else:
                self._version = matches[0]
        else:
            self._version = self._ptask.latest_version

        # source subs
        self._match_str = self._match_str.replace("%", ".*")

        all_subs = self._version.subscriptions
        self._subs_to_source = []
        for sub in all_subs:
            if re.search(self._match_str, sub.product_version_spec):
                self._subs_to_source.append(sub)

        if not self._subs_to_source:
            raise ActionAborted("No subscriptions to source.")
开发者ID:chippey,项目名称:dpa-pipe,代码行数:48,代码来源:source.py

示例5: queue_submit_cmd

def queue_submit_cmd(command, queue_name, output_file=None, id_extra=None,
    dt=None):
    """Create and submit a shell script with the given command."""
    
    ptask_area = PTaskArea.current()
    ptask_area.provision(QUEUE)
    script_dir = ptask_area.dir(dir_name=QUEUE)

    unique_id = get_unique_id(ptask_area.spec, id_extra=id_extra, dt=dt)

    script_name = unique_id + '.sh'
    log_name = unique_id + '.log'

    script_path = os.path.join(script_dir, script_name)
    log_path = os.path.join(script_dir, log_name)

    with open(script_path, "w") as script_file:
        script_file.write("#!/bin/bash\n")
        script_file.write(command + "\n") 
        script_file.write("chmod 660 " + output_file + "\n")

    os.chmod(script_path, 0770)

    create_queue_task(queue_name, script_path, unique_id, 
        output_file=output_file, submit=True, log_path=log_path)
开发者ID:chippey,项目名称:dpa-pipe,代码行数:25,代码来源:__init__.py

示例6: ptask_area

    def ptask_area(self):
        """Return the current ptask area for this session."""

        if not hasattr(self, '_ptask_area'):
            self._ptask_area = PTaskArea.current()

        return self._ptask_area
开发者ID:chippey,项目名称:dpa-pipe,代码行数:7,代码来源:session.py

示例7: get_import_files

    def get_import_files(cls, session, name, category, representation,
        relative_to=None):

        ptask_area = PTaskArea.current()
        try:
            import_dir = ptask_area.dir(dir_name='import', path=True)
        except PTaskAreaError:
            raise EntityError("Could not find import directory!")

        import_dir = os.path.join(
            import_dir, 'global', name, category, representation.type, 
            representation.resolution
        )

        # get the file in the import_dir
        import_files = os.listdir(import_dir)
        import_files = [f for f in import_files 
            if f.endswith('.' + representation.type)]

        # prepend the import directory to get the full path
        import_files = [os.path.join(import_dir, f) for f in import_files]

        if relative_to:
            import_files = [
                os.path.relpath(f, relative_to) for f in import_files] 

        return import_files
开发者ID:chippey,项目名称:dpa-pipe,代码行数:27,代码来源:entity.py

示例8: _import_mari_plugins

def _import_mari_plugins():

    from dpa.ptask.area import PTaskArea

    # first, get the context
    ptask_area = PTaskArea.current()

    # get a list of mari plugin directories
    plugin_dirs = ptask_area.ancestor_paths(
        'plugins/mari', include_install=False)

    for plugin_dir in reversed(plugin_dirs):

        if not os.path.isdir(plugin_dir):
            continue
        
        file_names = os.listdir(plugin_dir)

        for file_name in file_names:

            # only python files
            if not file_name.endswith(".py"):
                continue
            
            full_path = os.path.join(plugin_dir, file_name)

            module_name = 'mari_plugin_' + file_name.replace(".", "_")

            try:
                module = imp.load_source(module_name, full_path)
            except Exception as e:
                print "Unable to load mari plugin: " + full_path    
                traceback.print_exc()                
开发者ID:chippey,项目名称:dpa-pipe,代码行数:33,代码来源:init.py

示例9: _create_area

 def _create_area(self):
     
     try:
         self._product_area = PTaskArea.create(self.product_repr)
     except PTaskAreaError as e:
         raise ActionError(
             "Unable to create product area on disk: " + str(e))
开发者ID:chippey,项目名称:dpa-pipe,代码行数:7,代码来源:create.py

示例10: setup_cl_args

    def setup_cl_args(cls, parser):

        parser.add_argument(
            "spec",
            nargs="?",
            default=PTaskArea.current().spec,
            help="The production task specification."
        )

        parser.add_argument(
            "-s", "--shell", 
            default=ShellFormatters.default().name,
            choices=sorted([f.name for f in ShellFormatters.all()]),
            help="Shell type env commands should target."
        )

        parser.add_argument(
            "-p", "--previous", 
            nargs="?", 
            const="list",
            help="Choose a previous ptask env."
        )

        parser.add_argument(
            "-v", "--version", 
            type=int,
            help="The version of the ptask to print info for."
        )
开发者ID:chippey,项目名称:dpa-pipe,代码行数:28,代码来源:env.py

示例11: _get_filter_rules

    def _get_filter_rules(self, ptask):

        ptask_area = PTaskArea(ptask.spec, validate=False) 
        filter_config = ptask_area.config(
            FILTER_RULES_CONFIG_PATH,
            composite_ancestors=True,
        )
        
        includes = []
        excludes = []

        if 'includes' in filter_config:
            includes = filter_config.includes

        if 'excludes' in filter_config:
            excludes = filter_config.excludes
    
        return (includes, excludes)
开发者ID:DarkRoseAM,项目名称:dpa-pipe,代码行数:18,代码来源:sync.py

示例12: get_default_product_name

def get_default_product_name():

    name = "Comp"

    ptask_area = PTaskArea.current()
    if ptask_area:
        name = PTaskSpec.name(ptask_area.spec) + name

    return name
开发者ID:chippey,项目名称:dpa-pipe,代码行数:9,代码来源:nodes.py

示例13: execute

    def execute(self):

        match_specs = self._complete(
            self.spec, 
            relative_to=PTaskArea.current().spec,
        )

        if match_specs:
            print " ".join([s for s in match_specs])
开发者ID:chippey,项目名称:dpa-pipe,代码行数:9,代码来源:complete.py

示例14: log_action

    def log_action(self):

        if not self.__class__.logging:
            return

        # log the command
        msg = "({s})".format(s=PTaskArea.current().spec)
        msg += " " + " ".join(sys.argv)

        self.logger.info(msg)
开发者ID:liudger,项目名称:dpa-pipe,代码行数:10,代码来源:__init__.py

示例15: validate

    def validate(self):

        if not isinstance(self._ptask, PTask):
            try:
                cur_spec = PTaskArea.current().spec
                full_spec = PTaskSpec.get(self._ptask, relative_to=cur_spec)
                self._ptask = PTask.get(full_spec)
            except PTaskError:
                raise ActionError("Could not determine ptask from: {p}".format(
                    p=self._ptask))
开发者ID:chippey,项目名称:dpa-pipe,代码行数:10,代码来源:action.py


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