-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
96 lines (67 loc) · 1.98 KB
/
demo.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Script: pysubtask/demo.py Module
#
# Author V1: David Jacobson ([email protected])
# https://github.com/djacobson/pysubtask
import demo_config as config
def get_commands(master):
finished = False
kbd_input = ''
while not finished:
try:
kbd_input = input("Enter cmd (x | r | a | c | 0-n):\n").strip().lower()
except KeyboardInterrupt:
# CTRL+C exit
kbd_input = 'x'
if kbd_input != '':
print("cmd = [{}]".format(kbd_input))
if kbd_input == 'x':
# Exit
print("Exiting.")
finished = True
break
elif kbd_input == 'r':
# Reset subtask
master.reset()
elif kbd_input == 'a':
# Notify subtask of all files and directories
# having ready data
master.notify_all_files()
elif kbd_input == 'c':
# Check for pending data from ending on a Burst
master.check_pending_notifications()
elif kbd_input.isdigit():
# Notify subtask of specific file in list (by index *file* num)
master.notify_file_by_index(int(kbd_input))
else:
print('ERROR: [{}] Unknown cmd!'.format(kbd_input))
return
def run_app():
watchfilesdirs = [
{'file': 'logs/test1.mrk'}, # Regular, no burstmode
{'file': 'logs/test1.csv', 'burstmode': True},
{'dir': 'logs/watch_all_in_here'}
]
master = None
# Use line below to dynamically change the heartbeat
# file name to something other than default = hostname
# config.base.HeartbeatName = 'SomethingElse'
if config.ftp.UseFTP:
# Use S/FTP
from pysubtask.ftp import FTPTaskMaster
master = FTPTaskMaster(watchfilesdirs, config, LogToConsole=True)
elif config.dropbox.UseDropbox:
# Use DropBox
from pysubtask.dropbox import DropboxTaskMaster
master = DropboxTaskMaster(watchfilesdirs, config, LogToConsole=True)
else:
return
# Pre-archive old data & pre-copy and upload previous residual data, then Start
master.start(precleanup_old_files=True)
get_commands(master)
master.stop(forcekill=False)
return
def main():
run_app()
if __name__ == "__main__":
main()