summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <eduard.bartosh@intel.com>2014-04-07 16:12:48 +0300
committerEd Bartosh <eduard.bartosh@intel.com>2014-04-11 12:49:02 +0300
commite4b2169b87f427df6fd9efda821573165f86e631 (patch)
tree284e1dfb14d92ba3b14cb8bc031ae6145678f636
parent4f8cc49fe95acda1004fa5b794c86f0b34349b64 (diff)
downloadrepa-e4b2169b87f427df6fd9efda821573165f86e631.tar.gz
repa-e4b2169b87f427df6fd9efda821573165f86e631.tar.bz2
repa-e4b2169b87f427df6fd9efda821573165f86e631.zip
Implemented --showurls option
Some users want to see urls in repa list output. It's inconvenient for them to use repa info for every submission to see the urls. Fixes: #1789 Change-Id: I7cc31bc327fc9593ab21efdd85fe4fe6accfd544 Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r--repa.115
-rw-r--r--repa/common.py26
-rwxr-xr-xrepa/info.py28
-rwxr-xr-xrepa/list.py26
4 files changed, 63 insertions, 32 deletions
diff --git a/repa.1 b/repa.1
index b0b6aa5..d438e12 100644
--- a/repa.1
+++ b/repa.1
@@ -87,7 +87,7 @@ Turn on colorized output
.\"
.\" The "list" command description
.\"
-.SS \fBlist\fR [\-\-help] [\-\-processes <processes>]
+.SS \fBlist\fR [\-\-help] [\-\-processes <processes>] [\-\-showurls]
.RS 2
List submissions in the following format:
@@ -128,9 +128,16 @@ PROCESSES
.RS 2
Use PROCESSES to specify the amount of python processes to run in parallel. Usage of this option can significantly speed up repa list.
Note, that this parameter can also be specified in \fIrepa\fR configuration file.
+.RE
+.PP
+.B \-\-showurls
+.RS 2
+Show OBS and download urls in the output. It's switched off by default.
+Note, that this parameter can also be specified in \fIrepa\fR configuration file.
.RE
+
.PP
.\"
.\" The "info" command description
@@ -319,13 +326,17 @@ project = Tizen:IVI
.RS 2
color = off
.RE
+.RS 2
+showurls = off
+.RE
+
.RS 2
Mandatory options: apiurl, apiuser, apipasswd and project
.RE
.RS 2
-Some options (project, processes, colorize) can be overridden by commandline options (--project, --processes, --colorize)
+Some options (project, processes, colorize, showurls) can be overridden by commandline options (--project, --processes, --colorize, --showurls)
.RE
.SH BUGS
diff --git a/repa/common.py b/repa/common.py
index 622b47e..79d6ed7 100644
--- a/repa/common.py
+++ b/repa/common.py
@@ -30,6 +30,7 @@ Common functions, classes, exceptions.
"""
import sys
+import os
import time
import json
from functools import wraps, partial
@@ -180,3 +181,28 @@ class Colorizer:
else:
return text
+def get_download_url(meta):
+ """Get download url from meta."""
+ if 'download_url' in meta:
+ return meta['download_url']
+ # Guess url from image url if download_url is not in the meta
+ if 'images' not in meta:
+ return
+ for img in meta['images']:
+ if 'url' in img:
+ return img['url'].split('images')[0]
+
+
+def get_obs_url(meta, buildurl='https://build.tizen.org'):
+ """Get obs project url from meta."""
+ if 'obs_url' in meta:
+ return meta['obs_url']
+ # Make it from git tag and obs_target_prj if obs_url is not in the meta
+ if 'obs_target_prj' not in meta:
+ return
+ if 'name' not in meta and 'git_tag' not in meta:
+ return
+ name = meta.get('git_tag') or meta.get('name')
+ return os.path.join(buildurl, 'project/show?project=home:prerelease:%s:%s'
+ % (meta['obs_target_prj'], name.replace('/', ':')))
+
diff --git a/repa/info.py b/repa/info.py
index 7de8739..267d8e3 100755
--- a/repa/info.py
+++ b/repa/info.py
@@ -34,7 +34,7 @@ import os
from collections import defaultdict
-from repa.common import get_project_by_name
+from repa.common import get_project_by_name, get_download_url, get_obs_url
from repa.obs import OBS
from repa.main import sub_main
@@ -52,32 +52,6 @@ def get_status(results):
return status
-def get_download_url(meta):
- """Get download url from meta."""
- if 'download_url' in meta:
- return meta['download_url']
- # Guess url from image url if download_url is not in the meta
- if 'images' not in meta:
- return
- for img in meta['images']:
- if 'url' in img:
- return img['url'].split('images')[0]
-
-
-def get_obs_url(meta, buildurl='https://build.tizen.org'):
- """Get obs project url from meta."""
- if 'obs_url' in meta:
- return meta['obs_url']
- # Make it from git tag and obs_target_prj if obs_url is not in the meta
- if 'obs_target_prj' not in meta:
- return
- if 'name' not in meta and 'git_tag' not in meta:
- return
- name = meta.get('git_tag') or meta.get('name')
- return os.path.join(buildurl, 'project/show?project=home:prerelease:%s:%s'
- % (meta['obs_target_prj'], name.replace('/', ':')))
-
-
def info(obs, name, target):
"""Print detailed info about submission or submitgroup."""
is_group = name.startswith('submitgroup/')
diff --git a/repa/list.py b/repa/list.py
index 4f358bd..ace70e9 100755
--- a/repa/list.py
+++ b/repa/list.py
@@ -32,7 +32,8 @@ Get list of submissions.
import sys
import json
-from repa.common import OBS_PROJECT_PREFIX, Colorizer
+from repa.common import (OBS_PROJECT_PREFIX, Colorizer,
+ get_download_url, get_obs_url)
from repa.obs import OBS
from repa.main import sub_main
@@ -65,7 +66,19 @@ def get_status(meta, colorizer, build_results=None):
return colorizer.green('ready')
-def list_submissions(obs, target, processes, is_colorize=False):
+def show_urls(meta):
+ """Print OBS and download urls."""
+ download_url = get_download_url(meta)
+ if download_url:
+ print ' download url: ', download_url
+ obs_url = get_obs_url(meta)
+ if obs_url:
+ print ' obs url: ', obs_url
+ print
+
+
+def list_submissions(obs, target, processes, is_colorize=False,
+ showurls=False):
"""List submissions and groups."""
colorizer = Colorizer(is_colorize)
# submissions
@@ -80,12 +93,16 @@ def list_submissions(obs, target, processes, is_colorize=False):
projects = [project.split('/')[-1] for project in meta['projects']]
print '%-37s %-37s %s' % (meta['git_tag'], \
get_status(meta, colorizer, build_results), ','.join(projects))
+ if showurls:
+ show_urls(meta)
# groups
if groups:
print
for meta in groups:
print '%-37s %-37s' % (meta['name'], get_status(meta, colorizer))
+ if showurls:
+ show_urls(meta)
class List(object):
@@ -104,13 +121,16 @@ class List(object):
parser.add_argument('--processes', type=int,
help='amount of parallel processes to use',
default=config.get('processes'))
+ parser.add_argument('--showurls', action='store_true',
+ help='show OBS and download urls',
+ default=config.get('showurls', '').lower() == 'on')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main"""
obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
return list_submissions(obs, argv.project, argv.processes,
- argv.colorize)
+ argv.colorize, argv.showurls)
if __name__ == '__main__':