def plexconnect_control(control): global controlsupport if control == "install" or control == "uninstall" or control == "remove": if sys.platform.startswith('darwin'): #OSX specific command = Popen("./support/OSX/"+control+".bash", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] time.sleep(2) # actions may still be in progress else: if sys.platform.startswith('win32') and control == "remove": call(plexconnectpath+"stop", shell=True) time.sleep(3) call(plexconnectpath+control, shell=True) print("win "+plexconnectpath+":"+control) else: call(plexconnectpath+control, shell=True) else: if os.name == "posix": # OSX / Linux flavors command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] else: # win 32 if controlsupport == False and control == "stop": cmdShutdown() shutdown() time.sleep(2) command = Popen("taskkill /FI \"IMAGENAME eq pythonw.exe\" /F", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] call("echo PlexConnect is not running > plexconnect_status.txt",shell=True) if controlsupport == False and control == "start": proc = Popen(["start.bat"],shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) time.sleep(2) call("echo PlexConnect is running > plexconnect_status.txt",shell=True) if controlsupport == True and control == "start": output = Popen("sc query PlexConnect-service", shell=True, stdout=PIPE).communicate()[0] if output.find("FAILED") > 0: command = Popen(plexconnectpath+" install", shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] time.sleep(3) command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] time.sleep(3) else: command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] else: command = Popen(plexconnectpath+control, shell=True, stderr=PIPE,stdout=PIPE).communicate()[0] call("echo PlexConnect is not running > plexconnect_status.txt",shell=True) time.sleep(2) set_platform() # update all proper programfile & paths time.sleep(2) plexconnect_status(localIP)
def sighandler_shutdown(signum, frame): signal.signal(signal.SIGINT, signal.SIG_IGN) # we heard you! cmdShutdown()