def update_status(self): bground = "" self.msgst = "" self.icofile = "" stateBtnEnDis = True msgBtnEnDis = "monitorDisable" appar = self.get_info() s = appar["state"] newst = "" if s == '0': #STATUS_OFFLINE newst = "OFFLINE" self.msgst = resources.get_message('monitorStatusOffline') bground = COLOR_OFFLINE self.icofile = "monitor_grey" elif s == '1': #STATUS_ONLINE newst = "ONLINE" self.msgst = resources.get_message('monitorStatusOnline') bground = COLOR_ONLINE self.icofile = "monitor_green" elif s == '3': #STATUS_DISABLE newst = "DISABLE" self.msgst = resources.get_message('monitorStatusDisabled') bground = COLOR_DISABLE msgBtnEnDis = "monitorEnable" self.icofile = "monitor_red" elif s == '10': #STATUS_UPDATING newst = "UPDATING" self.msgst = resources.get_message('monitorStatusUpdating') bground = COLOR_UPDATING self.icofile = "monitor_yellow" else: newst = "NOSERVICE" stateBtnEnDis = False self.msgst = resources.get_message('monitorStatusNoService') bground = COLOR_NOSERVICE self.icofile = "monitor_warning" if newst != self._cur_status or appar[ "connections"] != self._cur_connections: self._cur_status = newst self._cur_connections = appar["connections"] self.update_systray(self.icofile, self.msgst) self._img_status_top.set_background_gradient( bground, "ffffff", gdi.GRADIENT_DIRECTION_TOPBOTTON) self._img_status_bottom.set_background_gradient( bground, "ffffff", gdi.GRADIENT_DIRECTION_BOTTONTOP) apptx = [] apptx.append(resources.get_message("monitorStatus")) apptx.append(u": ") apptx.append(self.msgst) apptx.append(u"\n") apptx.append(resources.get_message("monitorConnections")) apptx.append(u": ") apptx.append(self._cur_connections) self._lbl_status.set_text(u"".join(apptx)) self._btconfig.set_enable(stateBtnEnDis) self._btends.set_text(resources.get_message(msgBtnEnDis)) self._btends.set_enable(stateBtnEnDis) gdi.add_scheduler(2, self.update_status)
def _guimode_start(self): self._app = gdi.Window(gdi.WINDOW_TYPE_NORMAL_NOT_RESIZABLE) self._app.set_title(U"DWAgent") self._app.set_size(_WIDTH, _HEIGHT) self._app.set_show_position(gdi.WINDOW_POSITION_CENTER_SCREEN) self._app.set_action(self._guimode_action) pnl_left = gdi.Panel() pnl_left.set_position(0, 0) pnl_left.set_size(_WIDTH_LEFT, _HEIGHT) pnl_left.set_background_gradient("83e5ff", "FFFFFF", gdi.GRADIENT_DIRECTION_LEFTRIGHT) self._app.add_component(pnl_left) pnl_bottom = gdi.Panel() pnl_bottom.set_position(0, _CONTENT_HEIGHT) pnl_bottom.set_size(_WIDTH, _HEIGHT_BOTTOM) self._app.add_component(pnl_bottom) wbtn = 140 hbtn = 36 self._btback = gdi.Button() self._btback.set_position(10, 10) self._btback.set_size(wbtn, hbtn) self._btback.set_text(resources.get_message('back')) self._btback.set_enable(False) self._btback.set_action(self._guimode_back) pnl_bottom.add_component(self._btback) self._btnext = gdi.Button() self._btnext.set_position(10 + wbtn + 5, 10) self._btnext.set_size(wbtn, hbtn) self._btnext.set_text(resources.get_message('next')) self._btnext.set_enable(False) self._btnext.set_action(self._guimode_next) pnl_bottom.add_component(self._btnext) self._btclose = gdi.Button() self._btclose.set_position(_WIDTH - wbtn - 10, 10) self._btclose.set_size(wbtn, hbtn) self._btclose.set_text(resources.get_message('close')) self._btclose.set_enable(False) self._btclose.set_action(self._guimode_close) pnl_bottom.add_component(self._btclose) self._pnlmain = None self._cur_step_ui = None self._step_init_run = False gdi.add_scheduler(0.1, self._guimode_step_init_start) #self._queue = Queue() #gdi.add_scheduler(0.1, self._guimode_update) gdi.loop(self._app, True)
def check_events(self): if self.check_stop(): self._app.destroy() return if self.check_update(): self._update = True self._app.destroy() return if self.check_show(): self._app.show() self.remove_show_file() gdi.add_scheduler(0.5, self.check_events)
def on_action(self, e): if e["action"] == "MOUSEBUTTONDOWN": if e["button"] == 1: self._move_y = e["y"] gdi.add_scheduler(0.1, self._move_y_timer) if e["action"] == "MOUSEBUTTONUP": self._move_y = None if e["action"] == "MOUSECLICK": if not self._skip_click: self._parent._app.show() self._parent._app.to_front() self._skip_click = False
def run(self): if self._cancel: return if self._first: self._first = False gdi.add_scheduler(4, self.run) else: cx = self._dlg.get_x() + 2 self._dlg.set_position(cx, self._dlg.get_y()) ar = gdi.get_screen_size() if cx >= ar["width"]: self._dlg.hide() else: gdi.add_scheduler(0.05, self.run)
def _move_y_timer(self): if self._move_y is not None: mp = gdi.get_mouse_position() ar = gdi.get_screen_size() if mp["x"] <= ar["width"] - self._dlg.get_width(): self._move_y = None else: ny = mp["y"] - self._move_y if ny >= 0 and ny <= ar["height"] - 120 and self._dlg.get_y( ) != ny: self._dlg.set_position(self._dlg.get_x(), ny) self._dlg_y_gap = ar["height"] - ny self._skip_click = True gdi.add_scheduler(0.1, self._move_y_timer)
def run(self): try: self._main._wait_ui = None self._main.wait_message(resources.get_message("waiting")) ret = self._func() except SystemExit: self._main._action = None gdi.add_scheduler(0.1, self._main.close) return except Exception as e: msg = e.__class__.__name__ if e.args is not None and len(e.args) > 0 and e.args[0] != '': msg = e.args[0] ret = ErrorDialog( resources.get_message('unexpectedError').format(msg)) self._main._guimode_execute(self._callback, ret)
def start(self, mode): self._semaphore = threading.Condition() self._sharedmemclient = None self._mode = mode self._monitor_tray_icon = False self._monitor_tray_obj = None self._monitor_desktop_notification = "visible" self._update = False if mode == "info": self.printInfo() else: if not self.lock(): if mode == "window": self.add_show_file() return while self.check_update() or self.check_stop(): time.sleep( 2 ) #Attende finché il server non cancella l'update file o lo stop file try: if 'monitor_desktop_notification' in self._properties: self._monitor_desktop_notification = self._properties[ 'monitor_desktop_notification'] except Exception: None #Carica Maschera self.prepare_window() if mode == "systray": self.prepare_systray() else: self._app.show() #Attiva Eventi gdi.add_scheduler(0.5, self.update_status) #self._event=None gdi.add_scheduler(1, self.check_events) gdi.loop() self.unlock() if self._update: self.run_update() if self._sharedmemclient is not None: self._sharedmemclient.close()
def check_events(self): if self.check_stop(): if self._notifyActivities is not None: self._notifyActivities.destroy() self._app.destroy() return if self.check_update(): self._update = True if self._notifyActivities is not None: self._notifyActivities.destroy() self._app.destroy() return if self.check_show(): self._app.show() self._app.to_front() self.remove_show_file() gdi.add_scheduler(0.5, self.check_events)
def start(self, mode): #GESTIONE PROVVISORIA MAC if mode == "systray" and is_mac(): while True: time.sleep(5) return self._semaphore = threading.Condition() self._sharedmemclient = None self._mode = mode self._monitor_tray_icon = False self._update = False if mode == "info": self.printInfo() else: if not self.lock(): if mode == "window": self.add_show_file() return while self.check_update() or self.check_stop(): time.sleep( 2 ) #Attende finché il server non cancella l'update file o lo stop file #Carica Maschera self.prepare_window() #Attiva Eventi gdi.add_scheduler(0.5, self.update_status) #self._event=None gdi.add_scheduler(1, self.check_events) bshow = True if mode == "systray": self.prepare_systray() bshow = False gdi.loop(self._app, bshow) self.unlock() if self._update: self.run_update() if self._sharedmemclient is not None: self._sharedmemclient.close()
def update_status(self): bground = "" self.msgst = "" self.icofile = "" stateBtnEnDis = True msgBtnEnDis = "monitorDisable" appar = self.get_info() s = appar["state"] newst = "" if s == '0': #STATUS_OFFLINE newst = "OFFLINE" self.msgst = self._get_message('monitorStatusOffline') bground = COLOR_OFFLINE self.icofile = "monitor_grey" elif s == '1': #STATUS_ONLINE newst = "ONLINE" self.msgst = self._get_message('monitorStatusOnline') bground = COLOR_ONLINE self.icofile = "monitor_green" elif s == '3': #STATUS_DISABLE newst = "DISABLE" self.msgst = self._get_message('monitorStatusDisabled') bground = COLOR_DISABLE msgBtnEnDis = "monitorEnable" self.icofile = "monitor_red" elif s == '10': #STATUS_UPDATING newst = "UPDATING" self.msgst = self._get_message('monitorStatusUpdating') bground = COLOR_UPDATING self.icofile = "monitor_yellow" else: newst = "NOSERVICE" stateBtnEnDis = False self.msgst = self._get_message('monitorStatusNoService') bground = COLOR_NOSERVICE self.icofile = "monitor_warning" curact = self.get_activities(appar["sessions_status"]) bchgact = False if self._cur_activities is None: bchgact = True else: for k in curact: if curact[k] != self._cur_activities[k]: bchgact = True break if newst != self._cur_status or bchgact is True: self._cur_status = newst self._cur_activities = curact self._reload_activities = False self.update_systray(self.icofile, self.msgst) self._img_status_top.set_background_gradient( bground, "ffffff", gdi.GRADIENT_DIRECTION_TOPBOTTOM) self._img_status_bottom.set_background_gradient( bground, "ffffff", gdi.GRADIENT_DIRECTION_BOTTONTOP) apptx = [] bexline = False if "group" in appar and appar["group"] != "": apptx.append(appar["group"]) apptx.append(u"\n") bexline = True if "name" in appar and appar["name"] != "": apptx.append(appar["name"]) apptx.append(u"\n") bexline = True if bexline is True: apptx.append(u"\n") apptx.append(self.msgst) self._lbl_status.set_text(u"".join(apptx)) if curact["sessions"] == 0: self._lbl_notificationsn.set_visible(True) self._lbl_notificationsl.set_text("") self._lbl_notificationsr.set_text("") else: apptxl = "" apptxr = "" apptxl += self._get_message('monitorSession') + ":" apptxr += self._get_message('monitorActive') + " (" + str( curact["sessions"]) + ")" if curact["screenCapture"] > 0: apptxl += "\n" + self._get_message( 'monitorScreenCapture') + ":" apptxr += "\n" + self._get_message( 'monitorActive') + " (" + str( curact["screenCapture"]) + ")" if curact["shellSession"] > 0: apptxl += "\n" + self._get_message( 'monitorShellSession') + ":" apptxr += "\n" + self._get_message( 'monitorActive') + " (" + str( curact["shellSession"]) + ")" if curact["downloads"] > 0: apptxl += "\n" + self._get_message('monitorDownload') + ":" apptxr += "\n" + self._get_message( 'monitorActive') + " (" + str( curact["downloads"]) + ")" if curact["uploads"] > 0: apptxl += "\n" + self._get_message('monitorUpload') + ":" apptxr += "\n" + self._get_message( 'monitorActive') + " (" + str(curact["uploads"]) + ")" self._lbl_notificationsn.set_visible(False) self._lbl_notificationsl.set_text(apptxl) self._lbl_notificationsr.set_text(apptxr) self._btconfig.set_enable(stateBtnEnDis) self._btends.set_text(self._get_message(msgBtnEnDis)) self._btends.set_enable(stateBtnEnDis) gdi.add_scheduler(2, self.update_status)
def _guimode_start(self): gdi.gdw_lib( ) #Se non è presente la libreria va in errore quindi in modalita console self._top_height = 0 if self._topimage is not None: self._top_height = gdi.getImageSize(self._topimage)["height"] elif self._topinfo is not None: self._top_height = (22 * len(self._topinfo.split("\n"))) + 10 self._app = gdi.Window(gdi.WINDOW_TYPE_NORMAL_NOT_RESIZABLE, logopath=self._logo) self._app.set_title(self._title) self._app.set_size(_WIDTH, _HEIGHT + self._top_height) self._app.set_show_position(gdi.WINDOW_POSITION_CENTER_SCREEN) self._app.set_action(self._guimode_action) pnl_left = gdi.Panel() pnl_left.set_position(0, self._top_height) pnl_left.set_size(_WIDTH_LEFT, _HEIGHT) if self._leftcolor is not None: pnl_left.set_background_gradient(self._leftcolor, "FFFFFF", gdi.GRADIENT_DIRECTION_LEFTRIGHT) else: pnl_left.set_background_gradient("83e5ff", "FFFFFF", gdi.GRADIENT_DIRECTION_LEFTRIGHT) self._app.add_component(pnl_left) if self._topimage is not None: pnl_top = gdi.ImagePanel() pnl_top.set_position(0, 0) pnl_top.set_filename(self._topimage) pnl_top.set_size(_WIDTH, self._top_height) self._app.add_component(pnl_top) elif self._topinfo is not None: pnl_top = gdi.Panel() pnl_top.set_position(0, 0) pnl_top.set_size(_WIDTH, self._top_height) pnl_top.set_background("d9d9d9") self._app.add_component(pnl_top) pnl_top_text = gdi.Label() pnl_top_text.set_position(10, 0) pnl_top_text.set_size(_WIDTH - (2 * 10), self._top_height) pnl_top_text.set_wordwrap(True) pnl_top_text.set_foreground("000000") pnl_top_text.set_text(self._topinfo) pnl_top.add_component(pnl_top_text) pnl_bottom = gdi.Panel() pnl_bottom.set_position(0, _CONTENT_HEIGHT + self._top_height) pnl_bottom.set_size(_WIDTH, _HEIGHT_BOTTOM) self._app.add_component(pnl_bottom) wbtn = 140 hbtn = 36 self._btback = gdi.Button() self._btback.set_position(10, 10) self._btback.set_size(wbtn, hbtn) self._btback.set_text(messages.get_message('back')) self._btback.set_enable(False) self._btback.set_action(self._guimode_back) pnl_bottom.add_component(self._btback) self._btnext = gdi.Button() self._btnext.set_position(10 + wbtn + 5, 10) self._btnext.set_size(wbtn, hbtn) self._btnext.set_text(messages.get_message('next')) self._btnext.set_enable(False) self._btnext.set_action(self._guimode_next) pnl_bottom.add_component(self._btnext) self._btclose = gdi.Button() self._btclose.set_position(_WIDTH - wbtn - 10, 10) self._btclose.set_size(wbtn, hbtn) self._btclose.set_text(messages.get_message('close')) self._btclose.set_enable(False) self._btclose.set_action(self._guimode_close) pnl_bottom.add_component(self._btclose) self._pnlmain = None self._cur_step_ui = None self._step_init_run = False gdi.add_scheduler(0.1, self._guimode_step_init_start) #self._queue = Queue() #gdi.add_scheduler(0.1, self._guimode_update) gdi.loop(self._app, True)
def close(self): self._closing = True if self._action is not None: self._action({"action": "CLOSE"}) if self._gui_enable is True: gdi.add_scheduler(0.1, self._app.destroy)