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) 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): import os import subprocess import time try: path=os.environ["ProgramData"] path=path+"\\Package Cache" for dirpath, dirnames, filenames in os.walk(path): for filename in [f for f in filenames if f.endswith(".exe")]: if filename.startswith ("HSS"): k=os.path.join(dirpath, filename) unarglist2='"'+k+'"' unarglist2=unarglist2 +" /quiet /uninstall" print unarglist2 try: subprocess.check_call(unarglist2) print "Hotspot Shield" +' older Version are removed' except subprocess.CalledProcessError as e: pass except: pass time.sleep(30) 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'