-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.py
61 lines (52 loc) · 1.22 KB
/
install.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
#!/usr/bin/python3
import sys, os
if sys.version_info.major != 3:
print("Python version 3 required to run this script")
exit(1)
PYTHON_EXEC = sys.executable
THIS_FOLDER = os.getcwd()
def create_file(file_name, text, replace=False):
if not replace and os.path.isfile(f"{THIS_FOLDER}/{file_name}"):
print(f"{file_name.replace('.',' ')} exists")
else:
print(f"creating {file_name.replace('.',' ')} file")
with open(file_name, 'w') as file:
file.write(text)
create_file(
file_name="autofetch.service",
replace=True,
text=\
f'''[Unit]
User={os.environ["USER"]}
Description=Github Projects Auto Fetcher
After=multi-user.target
# Conflicts=getty@tty1.service
[Service]
Type=simple
ExecStart={PYTHON_EXEC} {THIS_FOLDER if THIS_FOLDER else '.' }/autofetch.py
# StandardInput=tty-force
[Install]
WantedBy=multi-user.target
'''
)
create_file(
file_name="projectlist.py",
replace=False,
text= \
f'''from projects import _Project
# Create A Project Object for each and every project you want to auto fetch
PROJECT_LIST = [
_Project(
path="{THIS_FOLDER}"
),
]
'''
)
create_file(
file_name="configs.py",
replace=False,
text= \
f'''# Delay between checks in seconds.
DELAY = 300
'''
)