summaryrefslogtreecommitdiff
path: root/roadmap/management/commands/roadmap_import.py
diff options
context:
space:
mode:
Diffstat (limited to 'roadmap/management/commands/roadmap_import.py')
-rw-r--r--roadmap/management/commands/roadmap_import.py54
1 files changed, 38 insertions, 16 deletions
diff --git a/roadmap/management/commands/roadmap_import.py b/roadmap/management/commands/roadmap_import.py
index 854ac30..bad3ef5 100644
--- a/roadmap/management/commands/roadmap_import.py
+++ b/roadmap/management/commands/roadmap_import.py
@@ -1,3 +1,20 @@
+# Copyright (C) 2013 Linaro
+#
+# This file is part of roadmap.
+#
+# roadmap is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# roadmap is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with roadmap. If not, see <http://www.gnu.org/licenses/>.
+
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from getpass import getpass
@@ -62,34 +79,34 @@ class Command(BaseCommand):
dest=VERBOSE,
action='store_true',
default=False,
- help='Enables verbose logging. Default: false.'
+ help='Enables verbose logging. Default: false.'
),
)
help = 'Imports current snapshot from Jira server'
def handle(self, *args, **options):
- if options[JIRA_SERVER] == None :
+ if options[JIRA_SERVER] == None:
raise CommandError("Option `--server=...` must be specified.")
- if options[JIRA_USER] == None :
+ if options[JIRA_USER] == None:
raise CommandError("Option `--username=...` must be specified.")
jira_password = getpass("JIRA password (%s):" % options[JIRA_USER])
- jira_options={
- 'server': options[JIRA_SERVER],
+ jira_options = {
+ 'server': options[JIRA_SERVER],
'verify': options[JIRA_VERIFY]}
jira = JIRA(
- options=jira_options,
- basic_auth=(options[JIRA_USER], jira_password))
+ options=jira_options,
+ basic_auth=(options[JIRA_USER], jira_password))
start = 0
if options[JIRA_KEY] == None:
issues = jira.search_issues(
- 'project="%s"' % settings.JIRA_PROJECT,
- startAt=start,
+ 'project="%s"' % settings.JIRA_PROJECT,
+ startAt=start,
expand="changelog")
else:
issues = jira.search_issues(
- 'key="%s"' % options[JIRA_KEY],
- startAt=start,
+ 'key="%s"' % options[JIRA_KEY],
+ startAt=start,
expand="changelog")
options.update({SINGLE_UPDATE: False})
@@ -97,17 +114,22 @@ class Command(BaseCommand):
while len(issues) > 0:
#allissues.extend(issues)
for index, issue in enumerate(issues, start=1):
- print "Processing %s/%s (%s/%s) %s" % (index + start, issues.total, index, len(issues), issue.key)
+ print "Processing %s/%s (%s/%s) %s" % (
+ index + start,
+ issues.total,
+ index,
+ len(issues),
+ issue.key)
create_or_update(issue, options, jira)
start = start + len(issues)
if options[JIRA_KEY] == None:
issues = jira.search_issues(
- 'project="%s"' % settings.JIRA_PROJECT,
- startAt=start,
+ 'project="%s"' % settings.JIRA_PROJECT,
+ startAt=start,
expand="changelog")
else:
issues = jira.search_issues(
- 'key="%s"' % options[JIRA_KEY],
- startAt=start,
+ 'key="%s"' % options[JIRA_KEY],
+ startAt=start,
expand="changelog")