forked from infinitystation/EuropaStation
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnudge.py
39 lines (37 loc) · 1.11 KB
/
nudge.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
import sys,pickle,socket, CORE_DATA
#def pack():
# path = "/home/ski/Nanotrasen/message.txt"
# ip = sys.argv[1]
# dictionary = {"ip":ip,"data":1}
# try:
# targetfile = open(path,"r")
# except IOError:
# targetfile = open(path,"w")
# pickle.dump(dictionary,targetfile)
# targetfile.close()
# nudge()
# else:
# targetfile.close() #Professionals, have standards.
# pass
def pack():
ip = sys.argv[1]
try:
data = sys.argv[2:] #The rest of the arguments is data
except:
data = "NO DATA SPECIFIED"
dictionary = {"ip":ip,"data":data}
pickled = pickle.dumps(dictionary)
nudge(pickled)
def nudge(data):
if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS:
pass
else:
HOST = "localhost"
PORT = 45678
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST,PORT))
s.send(data)
s.close()
if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument
pack()