-
Notifications
You must be signed in to change notification settings - Fork 0
/
runServerCommands.py
40 lines (31 loc) · 1.07 KB
/
runServerCommands.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
import sys
import fabric
from Hidden import password
# host = "raspberrypi.local"
host = "10.25.8.94"
def main():
args = sys.argv
c = fabric.Connection(host, port=22, user="raspberry", connect_kwargs={'password': password}, connect_timeout=10)
c.open()
print("Connected!")
if (args.__contains__('-k')):
print("Killing python processes . . .")
c.run("sudo pkill python", warn=True)
print("Finished killing processes.")
if (args.__contains__("-u")):
print("Uploading Files . . .")
c.put("jerry/Server.py", "Jerry/")
c.put("jerry/Classes.py", "Jerry/")
c.put("jerry/Gyro.py", "Jerry/")
print("Finished Upload.")
if (args.__contains__("-p")):
print("Attempting to start pigpiod daemon.")
c.run("sudo pigpiod")
if (args.__contains__("-r")):
with c.cd("~/Jerry/"):
print("Running Server . . .")
print("Python Output Below.\n")
c.run("python Server.py", pty=True, warn=True)
c.close()
if __name__ == "__main__":
main()