import os import subprocess # 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) try: task=os.popen('Tasklist |findstr "hamachi"').read() task=task.split() kill=os.popen("Taskkill /IM "+task[0]+".exe /F").read() except: pass 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): #It uninstalls the older version which will match with the registry os.chdir(dir) argslist = args.split() try: try: task=os.popen('Tasklist |findstr "hamachi"').read() task=task.split() for i in task: if "hamachi" in i: kill=os.popen("Taskkill /IM "+i+" /F").read() else: pass except: pass subprocess.check_call(argslist) try: task=os.popen('Tasklist |findstr "hamachi"').read() task=task.split() for i in task: if "hamachi" in i: kill=os.popen("Taskkill /IM "+i+" /F").read() else: pass except: pass print 'retcode' + str(0) + 'retcode' except subprocess.CalledProcessError as e: print 'retcode' + str(e.returncode) + 'retcode'