GUI development

This commit is contained in:
BarsTiger
2022-01-26 20:43:25 +02:00
parent 88be80a4af
commit 9872f20ad5
3 changed files with 98 additions and 76 deletions

View File

@@ -32,33 +32,33 @@ def install(package, is_gui=False):
if not os.path.exists('{1}apps/{0}'.format(r['name'], horsy_vars.horsypath)):
os.makedirs('{1}apps/{0}'.format(r['name'], horsy_vars.horsypath))
if not is_gui:
print(f"Downloading {r['url'].split('/')[-1]}")
# if not is_gui:
print(f"Downloading {r['url'].split('/')[-1]}")
chunk_size = 1024
file_r = requests.get(r['url'], stream=True)
with open('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath), "wb") as f:
pbar = tqdm(unit="B", unit_scale=True, total=int(file_r.headers['Content-Length']))
for chunk in file_r.iter_content(chunk_size=chunk_size):
if chunk:
pbar.update(len(chunk))
f.write(chunk)
pbar.close()
chunk_size = 1024
file_r = requests.get(r['url'], stream=True)
with open('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath), "wb") as f:
pbar = tqdm(unit="B", unit_scale=True, total=int(file_r.headers['Content-Length']))
for chunk in file_r.iter_content(chunk_size=chunk_size):
if chunk:
pbar.update(len(chunk))
f.write(chunk)
pbar.close()
print(f"Starting virustotal scan")
if not get_key():
print(f"[red]Virustotal api key not found[/]")
print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal")
else:
print(f"[green]Virustotal api key found[/]")
print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]"
f"[italic white] in terminal[/]")
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))
print(f"[green]Virustotal scan finished[/]")
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1],
horsy_vars.horsypath))
print(f"[green]You can see report by opening: [white]{analysis['link']}[/]")
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
print(f"Starting virustotal scan")
if not get_key():
print(f"[red]Virustotal api key not found[/]")
print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal")
else:
print(f"[green]Virustotal api key found[/]")
print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]"
f"[italic white] in terminal[/]")
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))
print(f"[green]Virustotal scan finished[/]")
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1],
horsy_vars.horsypath))
print(f"[green]You can see report by opening: [white]{analysis['link']}[/]")
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
print(f"[green][OK] Done[/]")
@@ -74,36 +74,36 @@ def install(package, is_gui=False):
if r['download']:
print(f"Found dependency")
if not is_gui:
print(f"Downloading {r['download'].split('/')[-1]}")
# if not is_gui:
print(f"Downloading {r['download'].split('/')[-1]}")
chunk_size = 1024
file_r = requests.get(r['download'], stream=True)
with open('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath),
"wb") as f:
pbar = tqdm(unit="B", unit_scale=True, total=int(file_r.headers['Content-Length']))
for chunk in file_r.iter_content(chunk_size=chunk_size):
if chunk:
pbar.update(len(chunk))
f.write(chunk)
pbar.close()
chunk_size = 1024
file_r = requests.get(r['download'], stream=True)
with open('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath),
"wb") as f:
pbar = tqdm(unit="B", unit_scale=True, total=int(file_r.headers['Content-Length']))
for chunk in file_r.iter_content(chunk_size=chunk_size):
if chunk:
pbar.update(len(chunk))
f.write(chunk)
pbar.close()
print(f"Starting virustotal scan")
if not get_key():
print(f"[red]Virustotal api key not found[/]")
print(f"You can add it by entering [italic white]horsy --vt \[your key][/] in terminal")
else:
print(f"[green]Virustotal api key found[/]")
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath))
print(f"[green]Virustotal scan finished[/]")
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1],
horsy_vars.horsypath))
print(f"[green]You can see report by opening: [white]{analysis['link']}[/]")
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
if analysis['detect']['malicious'] > 0:
print(f"[red]Dependency can be malicious. It may run now, if this added to installation "
f"config[/]")
input("Press enter if you want continue, or ctrl+c to exit")
print(f"Starting virustotal scan")
if not get_key():
print(f"[red]Virustotal api key not found[/]")
print(f"You can add it by entering [italic white]horsy --vt \[your key][/] in terminal")
else:
print(f"[green]Virustotal api key found[/]")
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath))
print(f"[green]Virustotal scan finished[/]")
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1],
horsy_vars.horsypath))
print(f"[green]You can see report by opening: [white]{analysis['link']}[/]")
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
if analysis['detect']['malicious'] > 0:
print(f"[red]Dependency can be malicious. It may run now, if this added to installation "
f"config[/]")
input("Press enter if you want continue, or ctrl+c to exit")
if r['install']:
print(f"Found install option")