From b1fe46870255d9128a3156ba2dce6aea036c4bd1 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 13 Apr 2023 23:45:05 +0300 Subject: [PATCH] fix client --- cdncli.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/cdncli.py b/cdncli.py index b457262..ebc23a2 100644 --- a/cdncli.py +++ b/cdncli.py @@ -44,41 +44,27 @@ parser.add_argument( help='Стабильная версия' ) +parser.add_argument( + '-pj', + '--package', + default='package.json', + help='Путь к файлу package.json' +) if __name__ == '__main__': args = parser.parse_args() - if os.path.exists("package.json"): - d = json.load(open("package.json", 'rb')) + if os.path.exists(args.package): + d = json.load(open(args.package, 'rb')) print("package name: {name}".format(name=d['name'])) print("package version: {version}".format(version=d['version'])) - # filepath_js = "{dir}/{file}".format(dir=args.dir, file=args.file_js) - # if os.path.exists(filepath_js): - # file_js = {'file': open(filepath_js, 'rb')} - # res_js = requests.post(url='http://127.0.0.1:8000/uploadfile/', - # files=file_js, data={'package': d['name'], 'version': d['version'], 'type': 'js'}) - # if res_js.ok: - # print("Successfully uploaded index.js") - # else: - # print("Wrong") - # - # filepath_css = "{dir}/{file}".format(dir=args.dir, file=args.file_css) - # if os.path.exists(filepath_css): - # file_css = {'file': open(filepath_css, 'rb')} - # res_css = requests.post(url='http://127.0.0.1:8000/uploadfile/', - # files=file_css, data={'package': d['name'], 'version': d['version'], 'type': 'css'}) - # if res_css.ok: - # print("Successfully uploaded index.css") - # else: - # print("Wrong") - - filepath = "{dir}/{file}".format(dir=args.dir, file=args.file) + filepath = args.file if os.path.exists(filepath): file = {'file': open(filepath, 'rb')} res = requests.post(url='https://cdn.itguild.info/uploadfile/', - files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file, 'stable': args.stable}) + files=file, data={'package': d['name'], 'version': d['version'], 'filename': os.path.basename(args.file), 'stable': args.stable}) if res.ok: print(f"Successfully uploaded {filepath}") print(res.text)