Commit fee022a8 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

MNT: package_status accepts username/password for accessing internal channel

parent 75a29ec5
......@@ -17,10 +17,11 @@ recipe in the gitlab fsl/conda/ space. The table contains columns for:
"""
import sys
import argparse
import itertools as it
import urllib.parse as urlparse
import sys
import argparse
import itertools as it
import urllib.parse as urlparse
import urllib.request as urlrequest
from fsl_ci.gitlab import (get_projects_in_namespace,
download_file,
......@@ -192,6 +193,9 @@ def parseArgs():
'token' :
'Gitlab API access token with read+write access',
'username' : 'Username to access internal conda channel',
'password' : 'Password to access internal conda channel',
'server' :
f'Gitlab server (default: {SERVER_URL})',
......@@ -219,6 +223,8 @@ def parseArgs():
help=helps['server'])
parser.add_argument('-t', '--token', required=True,
help=helps['token'])
parser.add_argument('-u', '--username', help=helps['username'])
parser.add_argument('-p', '--password', help=helps['password'])
parser.add_argument('-n', '--namespace',
help=helps['namespace'],
default=RECIPE_NAMESPACE)
......@@ -232,7 +238,7 @@ def parseArgs():
help=helps['output'])
parser.add_argument('-e', '--exclude',
help=helps['exclude'], action='append')
parser.add_argument('-p', '--platform',
parser.add_argument('-pl', '--platform',
help=helps['platform'],
default=PLATFORMS,
action='append')
......@@ -244,6 +250,21 @@ def parseArgs():
args.exclude.extend(EXCLUDE)
if (args.username is not None) and (args.password is None) or \
(args.username is None) and (args.password is not None):
parser.error('Both --username and --password must be specified')
# install auth handler to
# access internal channel
if args.username is not None:
pwdmgr = urlrequest.HTTPPasswordMgrWithDefaultRealm()
pwdmgr.add_password(
None, args.internal_url, args.username, args.password)
handler = urlrequest.HTTPBasicAuthHandler(pwdmgr)
opener = urlrequest.build_opener(handler)
opener.open(args.internal_url)
urlrequest.install_opener(opener)
return args
......@@ -333,14 +354,14 @@ def get_mnt_conda_divergence(project, server, token):
def main():
args = parseArgs()
internal = get_channel_packages(args.internal_url)
public = get_channel_packages(args.public_url)
projects = get_projects_in_namespace(args.namespace,
args.server,
args.token)
projects = filter_projects(projects, args.exclude)
projects = sort_projects(projects, args.server, args.token)
projects = filter_projects(projects, args.exclude)
projects = sort_projects(projects, args.server, args.token)
internal = get_channel_packages(args.internal_url)
public = get_channel_packages(args.public_url)
# Print a table containing the following columns
# package name, recipe version, project repo <- get_recipe_info
......
Supports Markdown
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