Commit f6cf88c9 authored by André Anjos's avatar André Anjos 💬

[scripts] Add preliminary color support

parent 35f13db1
Pipeline #26967 passed with stage
in 9 minutes and 44 seconds
#!/usr/bin/env python
import os
import logging
logger = logging.getLogger(__name__)
import click
import gitlab
from . import bdt
from ..log import verbosity_option
from ..changelog import get_last_tag, parse_date
from ..release import get_gitlab_instance
from ..log import verbosity_option, get_logger, echo_normal, echo_warning
logger = get_logger(__name__)
@click.command(epilog='''
Examples:
......@@ -38,11 +39,16 @@ def lasttag(package):
gl = get_gitlab_instance()
# we lookup the gitlab package once
use_package = gl.projects.get(package)
logger.info('Found gitlab project %s (id=%d)',
use_package.attributes['path_with_namespace'], use_package.id)
tag = get_last_tag(use_package)
date = parse_date(tag.commit['committed_date'])
click.echo('Lastest tag for %s is %s (%s)' % \
(package, tag.name, date.strftime('%Y-%m-%d %H:%M:%S')))
try:
use_package = gl.projects.get(package)
logger.info('Found gitlab project %s (id=%d)',
use_package.attributes['path_with_namespace'], use_package.id)
tag = get_last_tag(use_package)
date = parse_date(tag.commit['committed_date'])
echo_normal('%s: %s (%s)' % \
(package, tag.name, date.strftime('%Y-%m-%d %H:%M:%S')))
except gitlab.GitlabGetError as e:
logger.warn('Gitlab access error - package %s does not exist?',
package)
echo_warning('%s: unknown' % (package,))
......@@ -6,13 +6,12 @@ import sys
import click
import gitlab
import logging
logger = logging.getLogger(__name__)
from . import bdt
from ..log import verbosity_option
from ..release import get_gitlab_instance
from ..log import verbosity_option, get_logger, echo_normal, echo_warning
logger = get_logger(__name__)
@click.command(epilog='''
Examples:
......@@ -48,12 +47,12 @@ def visibility(target, group):
# reads package list or considers name to be a package name
if os.path.exists(target) and os.path.isfile(target):
logger.info('Reading package names from file %s...', target)
logger.debug('Reading package names from file %s...', target)
with open(target, 'rt') as f:
packages = [k.strip() for k in f.readlines() if k.strip() and not \
k.strip().startswith('#')]
else:
logger.info('Assuming %s is a package name (file does not ' \
logger.debug('Assuming %s is a package name (file does not ' \
'exist)...', target)
packages = [target]
......@@ -66,11 +65,11 @@ def visibility(target, group):
# retrieves the gitlab package object
try:
use_package = gl.projects.get(package)
logger.info('Found gitlab project %s (id=%d)',
logger.debug('Found gitlab project %s (id=%d)',
use_package.attributes['path_with_namespace'], use_package.id)
click.echo('%s: %s' % (package,
echo_normal('%s: %s' % (package,
use_package.attributes['visibility'].lower()))
except gitlab.GitlabGetError as e:
logger.warn('Gitlab access error - package %s does not exist?',
package)
click.echo('%s: unknown' % (package,))
echo_warning('%s: unknown' % (package,))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment