-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsgCLI.py
66 lines (53 loc) · 1.62 KB
/
msgCLI.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
"""MSG App CLI Module.
Written by {0}
Version {1}
Status: {2}
Licensed under {3}
URL: {4}
"""
AUTHOR = "mtech0 | /~https://github.com/mtech0"
LICENSE = "GNU-GPLv3 | https://www.gnu.org/licenses/gpl.txt"
VERSION = "0.4.0"
STATUS = "Development"
URL = ""
__doc__ = __doc__.format(AUTHOR, VERSION, STATUS, LICENSE, URL)
import threading
import queue
from tools import debug_msg, Thread_tools, main
class Printer(threading.Thread, Thread_tools):
"""Print Class."""
def __init__(self, print_queue, kill, debug=True, run=True, timeout=5.0):
threading.Thread.__init__(self)
self.print_queue = print_queue
self.kill = kill
self.debug = debug
self.is_autorun = run
self.timeout = timeout
Thread_tools.__init__(self)
def run(self):
while not self.kill.is_set():
try:
msg = self.print_queue.get(True, 5.0)
print(msg)
except queue.Empty:
pass
class Interface(threading.Thread, Thread_tools):
"""Interface class."""
def __init__(self, input_queue, kill, debug=True, run=True, timeout=5.0):
threading.Thread.__init__(self)
self.input_queue = input_queue
self.kill = kill
self.debug = debug
self.is_autorun = run
self.timeout = timeout
Thread_tools.__init__(self)
def run(self):
while not self.kill.is_set():
msg = input(">")
if msg == "!kill":
self.kill.set()
continue
self.input_queue.put(msg)
#time.sleep(0.05)
if __name__ == '__main__':
main(__doc__)