-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlistpackages
More file actions
executable file
·74 lines (61 loc) · 2.49 KB
/
listpackages
File metadata and controls
executable file
·74 lines (61 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
"""List Packages"""
import argparse
import configparser
from Packagecloud import get_all_packages
from Packagecloud import show_packagelist
def configure():
"""Configure"""
parser = argparse.ArgumentParser()
parser.add_argument('--config', required=True,
help='Config file')
parser.add_argument('--srcrepo', required=True,
help='Source Repository')
parser.add_argument('--distro', required=False,
help='Filter selection by distro')
parser.add_argument('--version', required=False,
help='Filter selection by package version')
parser.add_argument('--name', required=False,
help='Filter selection by package name')
parser.add_argument('--type', required=False,
help='Filter selection by package type')
parser.add_argument('--match', required=False,
help='Filter selection by filename substring match')
parser.add_argument('--dlurl', required=False,
help='Display download URLs')
parser.add_argument('--wget', required=False,
help='Display wget commands')
parser.add_argument('--debug', action='store_true',
help='Print debug output')
args = parser.parse_args()
config = configparser.SafeConfigParser()
config.read(args.config)
token = config.get('packagecloud', 'token')
http_scheme = config.get('packagecloud', 'http_scheme')
api_domain = config.get('packagecloud', 'api_domain')
api_version = config.get('packagecloud', 'api_version')
conf = {
'domain_base': '{}://{}:@{}'.format(
http_scheme, token, api_domain),
'url_base': '{}://{}:@{}/api/{}'.format(
http_scheme, token, api_domain, api_version),
'repouser': config.get('packagecloud', 'repo_user'),
'srcrepo': args.srcrepo,
'debug': args.debug,
'distro': args.distro,
'version': args.version,
'name': args.name,
'type': args.type,
'match': args.match,
'args': args
}
return conf
def main():
"""Main"""
conf = configure()
packages = get_all_packages(conf['repouser'],
conf['srcrepo'], conf)
show_packagelist(conf['repouser'], conf['srcrepo'], packages,
conf['distro'], conf['version'], conf['name'],
conf['match'], conf['type'])
main()