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


Python JIRA.add_worklog方法代码示例

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


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

示例1: update_jira

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import add_worklog [as 别名]
def update_jira(username, password):
    """Update time logs in Jira

    Current implementation uses basic authentication,
    future version will have better auth. For simplicity
    the toggl log should have issue number as timelog
    description.

    *username* to use to connect to Jira
    *password* for Jira authentication

    """
    url = CONFIG.get('jira')['url']
    jira = JIRA(
        options={'server': url},
        basic_auth=(username, password))

    time_logs = toggl.Connect('jira')
    get_logs = time_logs.get_time_logs()

    for each_log in get_logs:
        issue_id = each_log.get('description')
        try:
            issue = jira.issue(issue_id)
        except JIRAError:
            logging.warning('Failed to find issue-id {0}'.format(issue_id))
            continue

        # Compute time in hours and round to two decimal places
        time_in_hours = round(each_log['duration']/(60*60), 2)
        jira.add_worklog(issue, time_in_hours, comment='Updated using Jira API')
开发者ID:skarbot,项目名称:utils,代码行数:33,代码来源:timelogs.py

示例2: Jira

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import add_worklog [as 别名]
class Jira(object):
    def __init__(self, url, user, password):
        self.jira = JIRA(url, auth=(user, password))

    def book_jira(self, bookings):
        for entry in bookings:
            if not ticket_pattern_jira.match(entry['issue_id']):
                continue
            rm_entry = entry.copy()

            rm_entry['hours'] = rm_entry['time'] / 60.
            del rm_entry['time']

            if 'description' in rm_entry:
                del rm_entry['description']
            if 'activity' in rm_entry:
                del rm_entry['activity']

            try:
                self.jira.add_worklog(
                    issue=entry['issue_id'],
                    timeSpent=entry['time'],
                    started=datetime.strptime(entry['spent_on'], '%Y-%m-%d'),
                    comment=entry['comments'],
                )
            except JIRAError as je:
                print(u'{0}: {1} ({2})'.format(
                    je.status_code, je.text, rm_entry['comments']))
开发者ID:reinhardt,项目名称:octodon,代码行数:30,代码来源:octodon.py

示例3: __init__

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import add_worklog [as 别名]

#.........这里部分代码省略.........
        if sprint_dates is None:
            raise RuntimeError('{} is not a proper sprint id.'.format(self.params['sprint_id']))

        return sprint_dates

    def __generate_date_list(self, start, end):
        start = datetime.strptime(start, '%Y-%m-%d')
        end = datetime.strptime(end, '%Y-%m-%d')
        dates = []
        for day in range(0, (end-start).days + 1):
            date = start + timedelta(days=day)
            if date.weekday() not in [5, 6] and date.strftime('%Y-%m-%d') not in helper.get_holidays_list().keys():
                dates.append(date.strftime('%Y-%m-%d'))

        return dates

    def __get_params_from_config(self):
        with open('sample.json') as data_file:
            try:
                data = json.load(data_file)
            except ValueError:
                raise RuntimeError("There was something wrong in you config.json. Please double check your input.")

        return data

    def __log_work_for_sprint(self):
        sprint_dates = self.__get_start_and_end_date_for_sprint()
        dates = self.__generate_date_list(sprint_dates[0], sprint_dates[1])

        # TODO: check if already logged. Maybe change logging per day instead.
        # TODO: check if exceeds time. Print warning before actually logging.

        print 'Logging work.'
        # self.__log_holidays(sprint_dates)
        # self.__log_leaves()
        self.__log_daily_work(dates)
        # self.__log_meetings()
        # self.__log_sprint_meetings(sprint_dates)
        # self.__log_trainings()
        # self.__log_reviews()
        # self.__log_other_tasks()

    def __log_holidays(self, sprint_dates):
        holidays = helper.get_holidays_list()
        print 'Logging holidays...'
        for holiday in holidays:
            if sprint_dates[0] <= holiday <= sprint_dates[1]:
                worklog = self.jira.add_worklog(self.params['holidays_id'], '8h', started=parser.parse(holiday + 'T08:00:00-00:00'), comment=holidays[holiday])
                if not isinstance(worklog, int):
                    raise RuntimeError('There was a problem logging your holidays.')

    def __log_leaves(self):
        # TODO: Support for not whole day leaves
        print 'Logging your leaves...'
        for leave in self.params['leaves']:
            worklog = self.jira.add_worklog(leave['id'], leave['timeSpent'], started=parser.parse(leave['started'] + 'T08:00:00-00:00'), comment=leave['comment'])
            print worklog
            if not isinstance(worklog, int):
                raise RuntimeError('There was a problem logging your leaves.')

    def __log_daily_work(self, dates):
        print 'Logging your daily tasks...'
        for task in self.params['daily_tasks']:
            for date in dates:
                worklog = self.jira.add_worklog(task['id'], task['timeSpent'], started=parser.parse(date + 'T08:00:00-00:00'), comment=task['comment'])
                if not isinstance(worklog, int):
                    raise RuntimeError('There was a problem logging your daily work.')

    def __log_meetings(self):
        print 'Logging your meetings...'
        for meeting in self.params['meetings']:
            worklog = self.jira.add_worklog(meeting['id'], meeting['timeSpent'], started=parser.parse(meeting['started'] + 'T08:00:00-00:00'), comment=meeting['comment'])
            if not isinstance(worklog, int):
                raise RuntimeError('There was a problem logging your meetings.')

    def __log_sprint_meetings(self, sprint_dates):
        print 'Logging your sprint meetings...'
        for sprint_meeting in self.params['sprint_meetings']:
            worklog = worklog = self.jira.add_worklog(sprint_meeting['id'], sprint_meeting['timeSpent'], started=parser.parse(sprint_meeting['started'] + 'T08:00:00-00:00'), comment=sprint_meeting['comment'])
            if not isinstance(worklog, int):
                raise RuntimeError('There was a problem logging your sprint meetings.')

    def __log_trainings(self):
        print 'Logging your trainings...'
        for training in self.params['trainings']:
            worklog = self.jira.add_worklog(training['id'], training['timeSpent'], started=parser.parse(training['started'] + 'T08:00:00-00:00'), comment=training['comment'])
            if not isinstance(worklog, int):
                raise RuntimeError('There was a problem logging your trainings.')

    def __log_reviews(self):
        # TODO: Find a way to automate this
        print 'Logging your reviews...'
        for review in self.params['reviews']:
            worklog = self.jira.add_worklog(self.params('reviews_id'), '{}h'.format(.5 * len(reviews[review])), started=parser.parse(review + 'T08:00:00-00:00'), comment='\n'.join(reviews[review]))
            if not isinstance(worklog, int):
                raise RuntimeError('There was a problem logging your reviews.')

    def __log_other_tasks(self):
        # TODO: Make this a filler task function.
        print "Not yet supported"
开发者ID:micodls,项目名称:jirautomatic,代码行数:104,代码来源:jira_main.py


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