SchedulerScript.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:nzbget-dirwatch 作者: caronc 项目源码 文件源码
def get_task(self, taskid=None):
        """Returns a dictionary of task details identified by the id
        specified.  If no id is specified, then the current task is
        detected and returned.
        """
        if taskid is None:
            # assume default
            taskid = self.taskid

        if not isinstance(taskid, int):
            try:
                taskid = int(taskid)
            except (ValueError, TypeError):
                # can't be typecasted to an integer
                return {}

        if taskid <= 0:
            # No task defined
            return {}

        # Precompile Regulare Expression for Speed
        task_re = re.compile('^%s%s%d_([A-Z0-9_]+)$' % (
            SCHEDULER_ENVIRO_ID,
            TASK_ENVIRO_ID,
            taskid,
        ))

        self.logger.debug('Looking for %s%s%d_([A-Z0-9_]+)$' % (
            SCHEDULER_ENVIRO_ID,
            TASK_ENVIRO_ID,
            taskid,
        ))

        # Fetch Task related content
        return dict([(task_re.match(k).group(1), v.strip()) \
            for (k, v) in environ.items() if task_re.match(k)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号