-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainProgram.py
More file actions
85 lines (67 loc) · 2.12 KB
/
mainProgram.py
File metadata and controls
85 lines (67 loc) · 2.12 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
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
# IFTTT: Allows Google Home integration with a computer
# Copyright (C) 2019 Anguianoewi
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
import os
import datetime
import sys
import os.path
import time
import subprocess
from shutil import copyfile
import configparser
import remStartup as rem
import runCommand as run
# Sets up settings reader
config = configparser.ConfigParser()
config.read('files.ini')
# Sets up save interval
saveMarker = 0
saveInt = int(config.get('MISC','SAVE_INTERVAL'))
runInt = int(config.get('MISC','SLEEP_TIME'))
licRead = int(config.get('MISC', "LICENSE_READ"))
if licRead == 0:
print('IFTTT: Allows Google Home integration with a computer'
'Copyright (C) 2019 Anguianoewi\n\n'
'You should have received a copy of the GNU General Public License\n'
'along with this program. If not, see <http://www.gnu.org/licenses/>\n\n'
'To get rid of this notification, modify files.ini [MISC] LICENSE_READ to 1\n')
else:
None
# Sets up save location
saveLoc = open('Log.txt', 'a+')
writeLog = saveLoc.write
# Writes separator and pushes text into file
writeLog('\n------------------------------------------------------------\n')
writeLog(datetime.datetime.now().isoformat(' ','seconds') + ': Log start date\n')
saveLoc.flush()
# Try creating backups, if specified.
try:
for i in range(100):
num = str(i)
copyfile('Log.txt',config.get('MISC','LOG_BACKUP_'
+ num))
# If error; ignore()
except:
pass
# Startup script runs
rem.rem()
# Infinite loop to keep system up and running
while True:
# Starts time interval between run check
time.sleep(runInt)
# Increases save token
saveMarker + 1
# Run commands script
run.run()
# checks to see if save token is equal to save integer
if saveMarker == saveInt:
#resets save token
saveMarker = 0
try:
for i in range(100):
num = str(i)
copyfile('Log.txt',config.get('MISC','LOG_BACKUP_'
+ num))
except:
pass