-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThingThatWillRunOnStartup.py
More file actions
37 lines (27 loc) · 1.16 KB
/
ThingThatWillRunOnStartup.py
File metadata and controls
37 lines (27 loc) · 1.16 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
import threading # for creating threads to run multiple tasks concurrently
import os # for running commands on the system
# class representing a single folder watcher
class Watcher:
location: str
def start(self):
os.system("python3 " + self.location + "/.NATracker/WatchThisFolder.py")
# class for managing all the watchers
class allWatchers:
watchers: list[Watcher]
# importing the watchers module from the ConfigStuff package
import ConfigStuff.Watchers as Watchers
def main():
# main function to initialize and start folder watchers.
# - loads watchers from the Watchers module.
# - creates and starts a thread for each watcher to run its start method concurrently.
watcherList = Watchers.loadWatchers() # load watchers from Watchers module
threadList = [] # list to keep track of threads for each watcher
# start all the watchers in separate threads
for watcher in watcherList.watchers:
thisThread = threading.Thread(target=watcher.start)
thisThread.start()
threadList.append(thisThread)
# infinite loop to keep the program running in the background
while True:
pass
main()