| | |
| | | import sys |
| | | import socket |
| | | from threading import Thread, Event |
| | | import re |
| | | |
| | | def getTrisurfVersion(): |
| | | p = subprocess.Popen('trisurf --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| | | lines=p.stdout.readlines() |
| | | version=re.findall(r'[0-9a-f]{7}(?:-dirty)?', lines[0].decode('ascii')) |
| | | p.wait() |
| | | if(len(version)): |
| | | return version[0] |
| | | else: |
| | | return "unknown version" |
| | | |
| | | def get_hostname(): |
| | | return socket.gethostname() |
| | |
| | | return ((([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0]) |
| | | |
| | | def get_client_id(addr, my_ip, my_hostname, subrun): |
| | | client_auth={'ip':my_ip,'hostname':my_hostname, 'subrun':subrun} |
| | | client_auth={'ip':my_ip,'hostname':my_hostname, 'subrun':subrun, 'trisurf_version':getTrisurfVersion() } |
| | | response=requests.post(addr+"/api/register/", data=client_auth) |
| | | if(response.status_code==200): |
| | | client_data=json.loads(response.text) |