當前位置: 首頁>>代碼示例>>Python>>正文


Python PTaskArea.current方法代碼示例

本文整理匯總了Python中dpa.ptask.area.PTaskArea.current方法的典型用法代碼示例。如果您正苦於以下問題:Python PTaskArea.current方法的具體用法?Python PTaskArea.current怎麽用?Python PTaskArea.current使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dpa.ptask.area.PTaskArea的用法示例。


在下文中一共展示了PTaskArea.current方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: validate

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:50,代碼來源:source.py

示例2: _import_mari_plugins

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
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,代碼行數:35,代碼來源:init.py

示例3: get_import_files

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:29,代碼來源:entity.py

示例4: setup_cl_args

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:30,代碼來源:env.py

示例5: queue_submit_cmd

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
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,代碼行數:27,代碼來源:__init__.py

示例6: ptask_area

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:9,代碼來源:session.py

示例7: execute

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:11,代碼來源:complete.py

示例8: get_default_product_name

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
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,代碼行數:11,代碼來源:nodes.py

示例9: validate

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:12,代碼來源:action.py

示例10: log_action

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    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,代碼行數:12,代碼來源:__init__.py

示例11: validate

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    def validate(self):

        if not self._message:
            raise ActionError("Message can not be empty.")

        try:
            self._sender = User.current()
        except UserError:
            raise ActionError("Could not identify current user.")

        # get ooto notification recipients from the configs
        ptask_area = PTaskArea.current()
        ooto_config = ptask_area.config(
            OOTO_CONFIG_PATH,
            composite_ancestors=True,
            composite_method="append",
        )

        ooto_notify = ooto_config.get('notify', [])
        self._to.extend(ooto_notify)

        # for all usernames specified, make sure they're a valid user,
        # get their email addresses.
        recipients = set()
        for recipient in self._to:
            
            # assume already a valid email address
            if "@" in recipient:
                recipients.add(recipient)
            else:
                try:
                    recipient = User.get(recipient)
                except UserError:
                    raise ActionError(
                        "Could not identify user: " + str(recipient)
                    )
                else:
                    recipients.add(recipient.email)

        if not recipients:
            recipients = [self._sender.email]

        self._to = recipients

        # tag the message with a signature, including the current ptask area
        # if there is one. 
        if ptask_area:
            self._message += "\n\nCurrent ptask: {p}".format(p=ptask_area.spec)
        self._message += "\n\n- {s}".format(s=self._sender.full_name)

        self._subject = "OOTO: {fn} ({un})".format(
            fn=self.sender.full_name,
            un=self.sender.username,
        )
開發者ID:chippey,項目名稱:dpa-pipe,代碼行數:56,代碼來源:ooto.py

示例12: __call__

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    def __call__(self, parser, namespace, in_spec, option_string=None):

        # assume the current ptask if not supplied
        if not in_spec:
            in_spec = "."

        cur_spec = PTaskArea.current().spec
        in_spec = in_spec.strip().strip(PTaskSpec.SEPARATOR)
        full_spec = PTaskSpec.get(in_spec, relative_to=cur_spec)

        setattr(namespace, self.dest, full_spec)
開發者ID:chippey,項目名稱:dpa-pipe,代碼行數:13,代碼來源:__init__.py

示例13: queue_submit_cmd

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
def queue_submit_cmd(command, queue_name, output_file=None, id_extra=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)

    now = datetime.datetime.now()

    if not id_extra:
        id_extra = now.strftime("%f")

    unique_id = "{u}_{t}_{s}_{e}".format(
        u=current_username(),
        t=now.strftime("%Y_%m_%d_%H_%M_%S"),
        s=ptask_area.spec.replace('=', '_'),
        e=id_extra,
    )
    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)

    # ---- submit to the queue

    from cheesyq import DPACheesyQ, DPADataLibrary, DPACheesyQTasks

    data_lib = DPADataLibrary.DjangoLibrary(None)

    render_task = DPACheesyQ.RenderTask()
    render_task.taskid = unique_id
    render_task.logFileName = log_path
    render_task.outputFileName = output_file

    data_lib.set(render_task.taskid, render_task)
    render_task.addTask(script_path)

    os.system("cqresubmittask {qn} {tid}".format(
        qn=queue_name,
        tid=render_task.taskid
    ))
        
    print "Submitted task: " + str(render_task.taskid)
開發者ID:DarkRoseAM,項目名稱:dpa-pipe,代碼行數:53,代碼來源:__init__.py

示例14: __init__

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    def __init__(self):

        ptask_area = PTaskArea.current()
        options_config = ptask_area.config(OOTO_OPTIONS_CONFIG,
            composite_ancestors=True)

        icon_path = IconFactory().disk_path(OOTO_ICON_URI)

        super(OotoDialog, self).__init__(
            title='Out Of The Office (OOTO)',
            options_config=options_config,
            icon_path=icon_path,
            action_button_text='Submit',
            modal=False,
        )
開發者ID:chippey,項目名稱:dpa-pipe,代碼行數:17,代碼來源:ooto.py

示例15: __init__

# 需要導入模塊: from dpa.ptask.area import PTaskArea [as 別名]
# 或者: from dpa.ptask.area.PTaskArea import current [as 別名]
    def __init__(self):

        ptask_area = PTaskArea.current()
        options_config = ptask_area.config(FAIL_OPTIONS_CONFIG,
            composite_ancestors=True)

        icon_path = IconFactory().disk_path(FAIL_ICON_URI)

        super(FailDialog, self).__init__(
            title='Failure Report',
            options_config=options_config,
            icon_path=icon_path,
            action_button_text='Submit',
            modal=False,
        )
開發者ID:chippey,項目名稱:dpa-pipe,代碼行數:17,代碼來源:fail.py


注:本文中的dpa.ptask.area.PTaskArea.current方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。