-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
98 lines (79 loc) · 3.45 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
print("#################")
print("STARTING SETUP.PY")
print("#################\n\n\n")
print("Importing nltk...")
import nltk
print("[+] Done (nltk import)\n")
print("Downloading nltk packages...")
nltk.download('averaged_perceptron_tagger')
nltk.download('wordnet')
nltk.download('punkt')
print("[+] Done (nltk packages)\n")
from Settings.jQuery import download as jq_download
print("Downloading jQuery...")
jq_download()
print("[+] Done (jQuery download)\n")
print("Importing git...")
try:
from git import Repo
except ImportError as err:
print("\n\n\n")
print(err)
print("\n\nTo solve this import error you must download git from"
" https://git-scm.com/downloads\n and ensure it is in"
" PATH (environment variable)")
exit(-1)
from os import getcwd, path, makedirs
print("[+] Done (git import)\n")
if(not path.exists(f"{getcwd()}//Structures//Sockets")):
print("Cloning from git...")
Repo.clone_from("https://github.com/saisua/Sockets",f"{getcwd()}//Structures//Sockets")
print("[+] Done (git clone)\n")
else:
print("[?] Sockets has already been downloaded")
print("Fetching to overwrite with the lastest version...")
local_repository = Repo(f"{getcwd()}//Structures//Sockets")
for remote in local_repository.remotes:
remote.fetch()
local_repository.git.reset("--hard")
print("[+] Done (git fetch)\n")
if(not path.exists(f"{getcwd()}//Extensions//duckduckgo-privacy-extension")):
print("Importing requests...")
from requests import get as GET
print("[+] Done (requests import)\n")
print("Downloading extension...")
response = GET("https://addons.mozilla.org/firefox/downloads/file/3560936/duckduckgo_privacy_essentials-2020.4.30-an+fx.xpi?src=dp-btn-primary")
if(not response.status_code == 200):
print("Error when downolading an extension")
exit(-1)
makedirs(f"{getcwd()}//Extensions//duckduckgo-privacy-extension//")
with open(f"{getcwd()}//Extensions//duckduckgo-privacy-extension//extension.xpi", "wb") as file:
file.write(response.content)
print("[+] Done (extension download)\n")
if(not path.isfile(f"{getcwd()}//geckodriver")):
print("Importing platform...")
import platform
print("[+] Done (platform import)\n")
print("Importing wget...")
import wget
print("[+] Done (wget import)\n")
system = (f"{'linux' if platform.system() == 'Linux' else 'win'}"
f"{'64' if '64' in platform.machine() else '32'}"
f"{'.tar.gz' if platform.system() == 'Linux' else '.zip'}")
print(f"Downloading geckodriver ({system})...")
wget.download(f"https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-{system}",
out=f"{getcwd()}//geckodriver-{system}")
if(system.endswith("zip")):
print("Importing zipfile...")
import zipfile
print("[+] Done (zipfile import)\n")
print(f"Extracting geckodriver-{system}... (not tested)")
zipfile.ZipFile(f"{getcwd()}//geckodriver-{system}").extractall()
print(f"[+] Done (extraction)")
else:
print("Importing tarfile...")
import tarfile
print("[+] Done (tarfile import)\n")
print(f"Extracting geckodriver-{system}...")
tarfile.open(f"{getcwd()}//geckodriver-{system}").extractall()
print(f"[+] Done (extraction)")