def unistall(self, e): if e["action"] == "PERFORMED": if is_windows(): subprocess.call( ["native" + utils.path_sep + "dwaglnc.exe", "uninstall"]) elif is_linux(): sucmd = None if self._which("gksu"): sucmd = "gksu" elif self._which("kdesu"): sucmd = "kdesu" if sucmd is not None: osenv = os.environ libenv = {} for k in osenv: if k != "LD_LIBRARY_PATH": libenv[k] = osenv[k] subprocess.Popen([ sucmd, utils.path_absname("native" + utils.path_sep + "uninstall") ], env=libenv) else: dlg = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_OK, gdi.DIALOGMESSAGE_LEVEL_ERROR, self._app) dlg.set_title(self._get_message('monitorTitle')) dlg.set_message( self._get_message('monitorUninstallNotRun')) dlg.show() elif is_mac(): self._runproc( ["open", "-a", os.path.abspath("native/Uninstall.app")])
def start_guilnc(self): self._propguilnc_stop = False signal.signal(signal.SIGTERM, self._signal_handler) bload = False suid = str(os.getuid()) spid = str(os.getpid()) lnc = sharedmem.Property() prcs = [] try: while not self._propguilnc_stop and utils.path_exists( "guilnc.run"): if not bload: if lnc.exists("gui_launcher_" + suid): try: lnc.open("gui_launcher_" + suid) lnc.set_property("pid", spid) bload = True except: time.sleep(1) else: time.sleep(1) if bload: if lnc.get_property("state") == "LNC": popenar = [] popenar.append(sys.executable) popenar.append(u'agent.pyc') popenar.append(u'app=' + lnc.get_property("app")) for i in range(GUILNC_ARG_MAX): a = lnc.get_property("arg" + str(i)) if a == "": break popenar.append(a) libenv = os.environ libenv["LD_LIBRARY_PATH"] = utils.path_absname( "runtime/lib") #print "Popen: " + " , ".join(popenar) try: p = subprocess.Popen(popenar, env=libenv) prcs.append(p) #print "PID: " + str(p.pid) if p.poll() is None: lnc.set_property("state", str(p.pid)) else: lnc.set_property("state", "ERR") except: lnc.set_property("state", "ERR") time.sleep(0.2) #Pulisce processi prcs = [p for p in prcs if p.poll() is None] finally: if bload: lnc.close()
def unistall(self, e): if is_windows(): subprocess.call(["native" + utils.path_sep + "dwaglnc.exe" , "uninstall"]) elif is_linux(): sucmd=None if self._which("gksu"): sucmd="gksu" elif self._which("kdesu"): sucmd="kdesu" if sucmd is not None: subprocess.Popen([sucmd , utils.path_absname("native" + utils.path_sep + "uninstall")]) else: dlg = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_OK,gdi.DIALOGMESSAGE_LEVEL_ERROR,self._app) dlg.set_title(self._get_message('monitorTitle')) dlg.set_message(self._get_message('monitorUninstallNotRun')) dlg.show(); elif is_mac(): subprocess.Popen(["native/Uninstall.app/Contents/MacOS/Uninstall"])
def _init_process(self): if self._bdestroy: raise Exception("Process destroyed.") iretry=0; while True: try: self._appconsoleid=None iretry+=1 if agent.is_windows(): self._appconsoleid=self._get_osmodule().consoleSessionId(); if (self._get_osmodule().isWinXP()==1 or self._get_osmodule().isWin2003Server()==1) and self._appconsoleid>0: self._get_osmodule().winStationConnectW() time.sleep(1) self._destroy_internal() elif self._currentconsoleid!=None and self._appconsoleid!=self._currentconsoleid: self._destroy_internal() elif agent.is_mac(): self._appconsoleid=self._get_osmodule().consoleUserId(); if self._currentconsoleid!=None and self._appconsoleid!=self._currentconsoleid: self._destroy_internal() time.sleep(1) if self._sharedmem==None: self._sharedmem=sharedmem.Stream() def fix_perm(fn): if agent.is_mac() and self._appconsoleid!=None: utils.path_change_owner(fn, self._appconsoleid, -1) utils.path_change_permissions(fn, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP) fname = self._sharedmem.create(fixperm=fix_perm) #RUN PROCESS #if utils.path_exists("apps" + utils.path_sep + "desktop.py"): ##MI SERVE IN SVILUPPO # import compileall # compileall.compile_file("apps" + utils.path_sep + "desktop.py") if agent.is_windows(): runaselevatore=u"False" if self._get_osmodule().isUserInAdminGroup()==1: if self._get_osmodule().isRunAsAdmin()==1: if self._get_osmodule().isProcessElevated()==1: runaselevatore=u"True" #Gestito cosi perche' sys.executable creave problemi con percorsi unicode exep=sys.executable pyhome=u"" appth="native\\service.properties" if (utils.path_exists(appth)): f = utils.file_open(appth, 'r', encoding='utf-8') sprop = f.read() f.close() lns = sprop.splitlines() for line in lns: if line.startswith("pythonPath="): exep=line[11:] elif line.startswith("pythonHome="): pyhome=line[11:] appcmd=u"\"" + exep + u"\" -S -m agent app=desktop " + unicode(fname) + u" " + unicode(str(self._agent_main._agent_debug_mode)) + u" windows " + runaselevatore self._ppid = self._get_osmodule().startProcessAsUser(appcmd,pyhome) self._currentconsoleid=self._get_osmodule().consoleSessionId(); elif agent.is_linux(): libenv = os.environ if utils.path_exists("runtime"): libenv["LD_LIBRARY_PATH"]=utils.path_absname("runtime/lib") #for some distro linux command below don't works because missing runpy #self._process=subprocess.Popen([sys.executable, u'-S', u'-m', u'agent' , u'app=desktop', unicode(fname), unicode(str(self._agent_main._agent_debug_mode)),u'linux'], env=libenv) self._process=subprocess.Popen([sys.executable, u'agent.pyc', u'app=desktop', fname, str(self._agent_main._agent_debug_mode),u'linux'], env=libenv) ''' stat -c%U /dev/tty2 if my_args is None: my_args = sys.argv[1:] user_name, cwd = my_args[:2] args = my_args[2:] pw_record = pwd.getpwnam(user_name) user_name = pw_record.pw_name user_home_dir = pw_record.pw_dir user_uid = pw_record.pw_uid user_gid = pw_record.pw_gid env = os.environ.copy() env[ 'HOME' ] = user_home_dir env[ 'LOGNAME' ] = user_name env[ 'PWD' ] = cwd env[ 'USER' ] = user_name self._process=subprocess.Popen([sys.executable, u'agent.pyc', u'app=desktop', fname, str(self._agent_main._agent_debug_mode),u'linux'], env=libenv, preexec_fn=self._init_process_demote(1000, 1000)) ''' #GESTIRE IL RENICE elif agent.is_mac(): self._ppid = self._agent_main.get_osmodule().exec_guilnc(self._appconsoleid,"desktop",[fname, str(self._agent_main._agent_debug_mode),u'mac']) if self._ppid is not None: self._currentconsoleid=self._appconsoleid self._process = None else: self._currentconsoleid=None libenv = os.environ if utils.path_exists("runtime"): libenv["DYLD_LIBRARY_PATH"]=utils.path_absname("runtime/lib") #self._process=subprocess.Popen([sys.executable, u'agent.pyc', u'app=desktop', fname, str(self._agent_main._agent_debug_mode),u'mac'], env=libenv) self._process=subprocess.Popen([sys.executable, u'-S', u'-m', u'agent' , u'app=desktop', unicode(fname), unicode(str(self._agent_main._agent_debug_mode)),u'mac'], env=libenv) #GESTIRE IL RENICE self._appconsoleid=None #Attende che il processo si attiva bok=False for i in range(10): time.sleep(0.5) if self._process!=None: if self._process.poll() == None: bok=True break elif self._ppid!=None: if self._agent_main.get_osmodule().is_task_running(self._ppid): bok=True break else: break if bok: break else: raise Exception("Process not started.") else: break except Exception as e: time.sleep(1) self._destroy_internal() if iretry>=3: raise e