forked from blawar/nut
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnut_server.py
More file actions
60 lines (47 loc) · 1.25 KB
/
nut_server.py
File metadata and controls
60 lines (47 loc) · 1.25 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import threading
import time
import urllib3
import nut
import Server
from nut import Usb
from nut import Hook
import nut.Watcher
def usbThread():
Usb.daemon()
def nutThread():
Server.run()
def run():
urllib3.disable_warnings()
print(r' ,;:;;,')
print(r' ;;;;;')
print(r' .=\', ;:;;:,')
print(r' /_\', "=. \';:;:;')
print(r' @=:__, \,;:;:\'')
print(r' _(\.= ;:;;\'')
print(r' `"_( _/="`')
print(r' `"\'')
nut.initTitles()
nut.initFiles()
nut.scan()
Hook.init()
print("Starting file watcher...")
nut.Watcher.start()
print("File watcher started.")
threads = []
threads.append(threading.Thread(target=usbThread, args=[]))
threads.append(threading.Thread(target=nutThread, args=[]))
for t in threads:
t.daemon = True
t.start()
try:
while True:
time.sleep(10) # Sleep for 10 seconds
print("nut_server.py: Server still running...")
except KeyboardInterrupt:
print('Exiting...')
if __name__ == '__main__':
run()
Hook.call("exit")