Add cli
This commit is contained in:
parent
9790c82ee5
commit
498c4b733e
14
README.md
14
README.md
@ -44,6 +44,20 @@ apt-get update
|
||||
```
|
||||
|
||||
|
||||
CLI
|
||||
---
|
||||
|
||||
Building on the rest endpoints above:
|
||||
|
||||
Apt:
|
||||
|
||||
* `rpcli -s http://localhost:8080 upload -y apt -f extpython-python3.6_3.6.7_amd64.deb_trusty -r exttest -p extpython-python3.6 -i 3.6.7 -a dist=trusty`
|
||||
|
||||
Python:
|
||||
|
||||
* `rpcli -s http://localhost:8080 upload -y pypi -f tensorflow-2.0.0a0-cp37-cp37m-manylinux1_x86_64.whl -r ttest2 -p tensorflow -i 2.0.0a0`
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
|
@ -1 +1 @@
|
||||
__version__ = "0.3.0"
|
||||
__version__ = "0.3.1"
|
||||
|
44
repobot/cli.py
Normal file
44
repobot/cli.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="package storage command line interface")
|
||||
parser.add_argument('-s', '--server', required=True, help="artifact server")
|
||||
|
||||
subparser_action = parser.add_subparsers(dest='action', help='action')
|
||||
|
||||
subparser_upload = subparser_action.add_parser('upload', help='upload package to repository')
|
||||
subparser_upload.add_argument('-y', '--provider', required=True, help="packaging provider")
|
||||
subparser_upload.add_argument('-f', '--file', required=True, help="file to upload")
|
||||
subparser_upload.add_argument('-r', '--repo', required=True, help="repo name")
|
||||
subparser_upload.add_argument('-p', '--package', required=True, help="package name")
|
||||
subparser_upload.add_argument('-i', '--package-version', required=True, help="package version")
|
||||
subparser_upload.add_argument('-a', '--args', nargs="+", help="extra args")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
params = {"provider": args.provider,
|
||||
"reponame": args.repo,
|
||||
"name": args.package,
|
||||
"version": args.package_version}
|
||||
|
||||
if args.args:
|
||||
for entry in args.args:
|
||||
key, value = entry.split('=', 1)
|
||||
if key in params:
|
||||
parser.error(f"duplicate parameter '{key}'")
|
||||
params[key] = value
|
||||
|
||||
endpoint = f'{args.server}/addpkg'
|
||||
resp = requests.post(endpoint, params=params, files={'f': open(args.file, 'rb')})
|
||||
|
||||
try:
|
||||
resp.raise_for_status()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
print(resp.text)
|
@ -3,11 +3,14 @@ asn1crypto==0.24.0
|
||||
backports.functools-lru-cache==1.5
|
||||
boto3==1.9.138
|
||||
botocore==1.12.138
|
||||
certifi==2019.3.9
|
||||
cffi==1.12.3
|
||||
chardet==3.0.4
|
||||
cheroot==6.5.4
|
||||
CherryPy==18.1.1
|
||||
cryptography==2.6.1
|
||||
docutils==0.14
|
||||
idna==2.8
|
||||
jaraco.functools==2.0
|
||||
Jinja2==2.10.1
|
||||
jmespath==0.9.4
|
||||
@ -22,6 +25,7 @@ PyMySQL==0.9.3
|
||||
python-dateutil==2.8.0
|
||||
python-gnupg==0.4.4
|
||||
pytz==2019.1
|
||||
requests==2.21.0
|
||||
s3transfer==0.2.0
|
||||
singledispatch==3.4.0.3
|
||||
six==1.12.0
|
||||
|
Loading…
Reference in New Issue
Block a user