У меня есть вот такой код
import requests
import sys
import os
def install(package: str):
request = requests.get("http://api.com/v1.0/package?name="+package)
package_json = request.json()
print(request)
print("Package name: "+package_json["display_name"])
print("Description: "+package_json["description"])
print("Package ID: "+str(package_json["id"]))
downloads = "./downloads/{}.exe".format(package)
with open(downloads, "wb") as f:
response = requests.get(package_json["download_url"], stream=True, allow_redirects=True)
total = response.headers.get('content-length')
if total is None:
f.write(response.content)
else:
downloaded = 0
total = int(total)
for data in response.iter_content(chunk_size=max(int(total / 1000), 1024 * 1024)):
downloaded += len(data)
f.write(data)
done = int(50 * downloaded / total)
sys.stdout.write('\rDownloading: [{}{}] {}% Complete'.format('█' * done, '-' * (50 - done), done*2))
sys.stdout.flush()
print("\n\nRunning installer executable...")
os.startfile(os.path.dirname(os.path.abspath(__file__))+"\\downloads\\{}.exe".format(package))
if __name__ == '__main__':
try:
strg = str(sys.argv[1])
print(strg)
print(sys.argv)
strg_final = strg.replace(r"client://", "")
print(strg_final)
install(strg_final)
except KeyboardInterrupt:
print("\ncancled by user")
дело в том что в консоли все работает, но когда я запускаю программу через браузер аргументы передаються но постоянно выбивает вот такую ошибку
Как быть?