forked from cybersecurity-team/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdater.py
More file actions
48 lines (45 loc) · 1.71 KB
/
Copy pathupdater.py
File metadata and controls
48 lines (45 loc) · 1.71 KB
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
"""
Module that facilitates the updating of the installed version of TorBot.
"""
import subprocess
def updateTor():
"""Currently updates Tor by calling terminal commands using subprocess.
Not a great method and will be replaced in the future.
"""
print("Checking for latest stable release")
isGit = subprocess.Popen(
["git", "branch"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output = isGit.stdout.read()
branch = output[2:8].decode("utf-8")
print(branch)
if branch == 'master':
update = subprocess.Popen(
["git", "pull", "origin", "master"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
update_out = update.stdout.read()
if update_out[90:109].decode("utf-8") == 'Already up to date.':
print("TorBot is already up-to-date.")
else:
print("TorBot has succesfully updated to latest stable version.")
else:
subprocess.Popen(
["git", "init"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
subprocess.Popen(
["git", "remote", "add", "origin",
"https://github.com/DedSecInside/TorBoT.git"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
update = subprocess.Popen(
["git", "pull", "origin", "dev"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
update_out = update.stdout.read()
if update_out[90:109].decode("utf-8") == 'Already up to date.':
print("TorBot is already up-to-date.")
else:
print("TorBot has succesfully updated to latest stable version.")