import subprocess import os import lliurex.net import threading import time class EpoptesClient: def startup(self,options): if options["controlled"]: if options["boot"]: self.grab_epoptes_certificate_thread() self.disable_wol_thread() #def startup def grab_epoptes_certificate_thread(self): t=threading.Thread(target=self._grab_epoptes_certificate) t.daemon=True t.start() #def epoptes_daemon def _grab_epoptes_certificate(self): if os.system("host server > /dev/null")==0: # This class is defined in core.py sp=SystemProcess() sp.get_process_list() execute=False try: if not sp.find_process("epoptes-client -c"): execute=True except: execute=False if execute: ip=self.get_server_ip() p=subprocess.Popen(["epoptes-client -c %s"%ip],shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) p.communicate() #def _grab_epoptes_certificate def disable_wol_thread(self): t=threading.Thread(target=self._disable_wol) t.daemon=True t.start() #def disable_wol_thread def _disable_wol(self): devices=lliurex.net.get_devices_info() for dev in devices: os.system("ethtool -s %s wol g"%dev["name"]) #def _disable_wol def get_server_ip(self): tries=4 for x in range(0,tries): ip=objects["VariablesManager"].get_variable("SRV_IP") if ip!=None: break time.sleep(1) if ip==None: ip="server" return ip #def get_server_ip #class EpoptesClient