2023-03-21 23:58:22 +03:00
|
|
|
import argparse
|
|
|
|
import json
|
|
|
|
import requests
|
|
|
|
import os
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Videos to images')
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
'-d',
|
|
|
|
'--dir',
|
|
|
|
type=str,
|
|
|
|
default='dist',
|
|
|
|
help='Директоия билда'
|
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
'-fjs',
|
|
|
|
'--file_js',
|
|
|
|
type=str,
|
|
|
|
default='index.js',
|
|
|
|
help='Файл javascript билда'
|
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
'-fcss',
|
|
|
|
'--file_css',
|
|
|
|
type=str,
|
|
|
|
default='index.css',
|
|
|
|
help='Файл css билда'
|
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
'-f',
|
|
|
|
'--file',
|
|
|
|
type=str,
|
|
|
|
default='script.js',
|
|
|
|
help='Файл билда'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if os.path.exists("package.json"):
|
|
|
|
d = json.load(open("package.json", '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)
|
|
|
|
if os.path.exists(filepath):
|
|
|
|
file = {'file': open(filepath, 'rb')}
|
2023-03-23 00:36:10 +03:00
|
|
|
res = requests.post(url='https://cdn.itguild.info/uploadfile/',
|
2023-03-21 23:58:22 +03:00
|
|
|
files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file})
|
|
|
|
if res.ok:
|
|
|
|
print(f"Successfully uploaded {filepath}")
|
2023-03-23 00:36:10 +03:00
|
|
|
print(res.text)
|
2023-03-21 23:58:22 +03:00
|
|
|
else:
|
|
|
|
print("Wrong")
|
|
|
|
|
|
|
|
else:
|
|
|
|
print("package.json not found")
|