-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
71 lines (51 loc) · 1.53 KB
/
Main.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
import os
import subprocess
import time
import json
from threading import Thread
null = open(os.devnull, 'w')
class Default(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
while True:
time.sleep(1)
subprocess.call(['python.exe', 'Client.py'])
def error_log(error):
with open("Resources/ErrorLog.txt", 'a') as file:
file.write(time.ctime() + "\n")
file.write(str(error) + "\n" + "\n")
def error_print(error_message, error):
print("SYSTEM ERROR - " + error_message + ": " + str(error))
def create_config():
if os.path.isfile("config.json"):
pass
else:
print("SYSTEM: Creating Config File...")
config = {"computer_name": "", "ip": "",
"backup": [], "backup_exclude": []}
with open('config.json', 'w') as f:
json.dump(config, f)
def create_name():
config = config_read()
if config['computer_name'] == "":
config['computer_name'] = input("What is the name of this computer: ")
config_write(config)
def create_ip():
config = config_read()
if config['ip'] == "":
config['ip'] = input("Please input IP address:")
config_write(config)
def config_read():
with open('config.json', 'r') as f:
return json.load(f)
def config_write(data):
with open('config.json', 'w') as f:
json.dump(data, f)
if __name__ == '__main__':
create_config()
create_name()
create_ip()
time.sleep(1)
a = Default()
a.start()