Skip to content

Commit

Permalink
Do not exit when can't read worklogid, but notify to output. refs #22
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Sep 22, 2020
1 parent 401a818 commit c7d12c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ example_config
src/*.egg-info
htmlcov
**/__pycache__
venv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ develop-eggs
.installed.cfg
lib
lib64
venv

# Installer logs
pip-log.txt
Expand Down
29 changes: 18 additions & 11 deletions src/jira_timemachine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

import attr
import click
from click import ClickException
import arrow
import six
from jira import JIRA
import jira
import requests
from requests import HTTPError

__version__ = '0.0.0'

Expand Down Expand Up @@ -102,15 +104,21 @@ def get_worklogs(self, from_date, single_user=True):
for row in response_data['results']:
if single_user and row['author']['accountId'] != self.account_id:
continue
yield Worklog(
id=int(row['jiraWorklogId']),
tempo_id=int(row['tempoWorklogId']),
author=row['author']['accountId'],
started=arrow.get('{startDate} {startTime}'.format(**row)),
time_spent_seconds=int(row['timeSpentSeconds']),
issue=row['issue']['key'],
description=row['description'],
)
try:
yield Worklog(
id=int(row['jiraWorklogId']),
tempo_id=int(row['tempoWorklogId']),
author=row['author']['accountId'],
started=arrow.get('{startDate} {startTime}'.format(**row)),
time_spent_seconds=int(row['timeSpentSeconds']),
issue=row['issue']['key'],
description=row['description'],
)
except TypeError as exc:
msg = f'Encountered an error {exc} while processing a worklog entry {row}'
click.echo(msg, err=True)
continue

url = response_data['metadata'].get('next')

def update_worklog(self, worklog):
Expand Down Expand Up @@ -145,9 +153,8 @@ def post_worklog(self, worklog):
)
try:
res.raise_for_status()
except:
except HTTPError:
click.echo(res.content)
raise


class JIRAClient(object): # pylint:disable=too-few-public-methods
Expand Down

0 comments on commit c7d12c1

Please sign in to comment.