-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
54 lines (46 loc) · 1.13 KB
/
server.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
import threading, socket, os, time
try:
import androidhelper
droid = androidhelper.Android()
except:
print "oops, not on android."
startWebserver = False
shutdown = False
indir = "/sdcard/Pictures/Screenshots/" # android paths
outdir = "/sdcard/pisentation/"
preexisting_files = os.listdir(indir)
def checkFileListUpdate():
current_files = os.listdir(indir)
for i in current_files:
if i not in preexisting_files:
try:
os.rename(indir + i, outdir + "i.png")
try:
droid.alert("Screen ready.")
except:
print "oopsies, no android."
except:
print "what did you even DO to cause an error here?"
shutdown = True
class ScreenshotMonitor(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
while True:
try:
if shutdown:
print "shutting down screenshot monitor thread"
break # can one exit() threads?
checkFileListUpdate()
time.sleep(0.25)
except: # some error
continue
screenShotMonitor = ScreenshotMonitor()
screenShotMonitor.start()
while True:
try:
pass
except KeyboardInterrupt:
shutdown = True
print "shutting down threads..."
quit()