Samo Penic
2018-06-22 4c9734b25313f93c6277189bcf792151370c7225
Added sending information of trisurf version to the server
1 files modified
13 ■■■■■ changed files
tsclient.py 13 ●●●●● patch | view | raw | blame | history
tsclient.py
@@ -10,6 +10,17 @@
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()
@@ -18,7 +29,7 @@
    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)