import os import subprocess import ctypes import urllib # dir: string -> directory where installer exist # args: string -> which includes all parameters with space delimiter def spm_install(dir, args): os.chdir(dir) argslist = args.split() try: subprocess.check_call(argslist) print 'retcode' + str(0) + 'retcode' except subprocess.CalledProcessError as e: print 'retcode' + str(e.returncode) + 'retcode' # dir: string -> directory where installer exist # args: string -> which includes all parameters with space delimiter def spm_uninstall(dir, args): os.chdir(dir) argslist = args.split() try: subprocess.check_call(argslist) print 'retcode' + str(0) + 'retcode' except subprocess.CalledProcessError as e: print 'retcode' + str(e.returncode) + 'retcode' # dir: string -> directory where installer exist # args: string -> which includes all parameters with space delimiter def spm_update(dir, args): command = subprocess.Popen("wmic product get name",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) res,err=command.communicate() if err: print(err) else: val1 = res.splitlines() for i in val1: if i.strip() == "MDaemon Connector": command1 = subprocess.Popen('wmic product where name="MDaemon Connector" call uninstall /nointeractive',shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) res1,err1=command1.communicate() if err1: print(err1) else: print("MDaemon Connector old version uninstalled") break else: pass cmd = subprocess.Popen("shutdown /r",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) res_1,err_1=cmd.communicate() if err_1: print(err_1) else: pass os.chdir(dir) argslist = args.split() try: subprocess.check_call(argslist) print 'retcode' + str(0) + 'retcode' except subprocess.CalledProcessError as e: print 'retcode' + str(e.returncode) + 'retcode'