コード例 #1
0
 def step_menu_agent(self, ui):
     try:
         self._install_code.set("")
         key = self.get_config("key")
         if key == "":
             return self.step_menu_agent_install_key_selected(ui)
         else:
             chs = user_interface.Chooser()
             chs.set_message(
                 resources.get_message('configureChooseOperation'))
             chs.add("configureChangeInstallKey",
                     resources.get_message('configureChangeInstallKey'))
             if self.is_agent_enable():
                 chs.add("configureDisableAgent",
                         resources.get_message('configureDisableAgent'))
             else:
                 chs.add("configureEnableAgent",
                         resources.get_message('configureEnableAgent'))
             chs.set_variable(self._agent_menu_sel)
             chs.prev_step(self.step_menu_main)
             chs.next_step(self.step_menu_agent_selected)
             return chs
     except:
         return user_interface.ErrorDialog(
             resources.get_message('configureErrorConnection'))
コード例 #2
0
 def step_configure_proxy_info(self, ui):
     if ui.get_variable().get(
     ) == 'HTTP' or ui.get_variable().get() == 'SOCKS4' or ui.get_variable(
     ).get() == 'SOCKS4A' or ui.get_variable().get() == 'SOCKS5':
         ipt = user_interface.Inputs()
         ipt.set_key(ui.get_key())
         ipt.set_message(resources.get_message('proxyInfo'))
         ipt.add('proxyHost', resources.get_message('proxyHost'),
                 self._proxy_host, True)
         ipt.add('proxyPort', resources.get_message('proxyPort'),
                 self._proxy_port, True)
         ipt.add('proxyAuthUser', resources.get_message('proxyAuthUser'),
                 self._proxy_user, False)
         ipt.add('proxyAuthPassword',
                 resources.get_message('proxyAuthPassword'),
                 self._proxy_password, False)
         ipt.prev_step(self.step_configure_proxy_type)
         ipt.next_step(self.step_configure_proxy_set)
         return ipt
     else:
         self._proxy_host.set("")
         self._proxy_port.set("")
         self._proxy_user.set("")
         self._proxy_password.set("")
         return self.step_configure_proxy_set(ui)
コード例 #3
0
    def _enable_disable_action_pwd(self, e):
        pwd = ""
        for c in e["window"].get_components():
            if c.get_name() == "txtPassword":
                pwd = c.get_text()

        e["window"].destroy()
        val = "false"
        mess_ok = 'monitorAgentDisabled'
        if self._cur_status == "DISABLE":
            val = "true"
            mess_ok = 'monitorAgentEnabled'
        if not self.check_auth(pwd):
            self.set_config(pwd, "enabled", val)
            dlg = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_OK,
                                    gdi.DIALOGMESSAGE_LEVEL_INFO, self._app)
            dlg.set_title(resources.get_message('monitorTitle'))
            dlg.set_message(resources.get_message(mess_ok))
            dlg.show()
        else:
            dlg = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_OK,
                                    gdi.DIALOGMESSAGE_LEVEL_ERROR, self._app)
            dlg.set_title(resources.get_message('monitorTitle'))
            dlg.set_message(resources.get_message('monitorInvalidPassword'))
            dlg.show()
コード例 #4
0
 def step_config_password_procede(self, ui):
     if ui.get_key() is not None and ui.get_key() == 'set_password':
         if self._change_pwd.get() == self._change_repwd.get():
             try:
                 self.change_pwd(self._change_pwd.get())
                 self._password = self._change_pwd.get()
                 msg = user_interface.Message(
                     resources.get_message('configurePasswordUpdated'))
                 msg.next_step(self.step_menu_main)
                 return msg
             except:
                 return user_interface.ErrorDialog(
                     resources.get_message('configureErrorConnection'))
         else:
             return user_interface.ErrorDialog(
                 resources.get_message('configurePasswordErrNoMatch'))
     elif ui.get_key() is not None and ui.get_key() == 'remove_password':
         if ui.get_variable().get() == 'yes':
             try:
                 self.change_pwd("")
                 self._password = ""
                 msg = user_interface.Message(
                     resources.get_message('configurePasswordUpdated'))
                 msg.next_step(self.step_menu_main)
                 return msg
             except:
                 return user_interface.ErrorDialog(
                     resources.get_message('configureErrorConnection'))
コード例 #5
0
    def _window_action(self, e):
        if e["action"] == u"ONCLOSE":
            if self._monitor_tray_icon:
                e["source"].hide()
                e["cancel"] = True
        if e["action"] == u"NOTIFYICON_ACTIVATE":
            e["source"].show()
            e["source"].to_front()
        elif e["action"] == u"NOTIFYICON_CONTEXTMENU":
            pp = gdi.PopupMenu()
            pp.set_show_position(gdi.POPUP_POSITION_TOPLEFT)
            if not self._app.is_show():
                pp.add_item("show", resources.get_message('monitorShow'))
            else:
                pp.add_item("hide", resources.get_message('monitorHide'))

            if self._cur_status != "NOSERVICE":
                if self._cur_status == "DISABLE":
                    pp.add_item("enable",
                                resources.get_message('monitorEnable'))
                else:
                    pp.add_item("disable",
                                resources.get_message('monitorDisable'))
                pp.add_item("configure",
                            resources.get_message('monitorConfigure'))
            pp.set_action(self._actions_systray)
            pp.show()
コード例 #6
0
 def step_menu_agent_install_key_selected(self, ui):
     ipt = user_interface.Inputs()
     ipt.set_message(resources.get_message('enterInstallCode'))
     ipt.add('code', resources.get_message('code'), self._install_code,
             True)
     ipt.prev_step(self.step_menu_agent)
     ipt.next_step(self.step_check_install_code)
     return ipt
コード例 #7
0
 def step_password(self, ui):
     self._ins_pwd = user_interface.VarString("", True)
     ipt = user_interface.Inputs()
     ipt.set_key("insert_password")
     ipt.set_message(resources.get_message('configureInsertPassword'))
     ipt.add('password', resources.get_message('password'), self._ins_pwd,
             True)
     ipt.next_step(self.step_check_password)
     return ipt
コード例 #8
0
    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)
コード例 #9
0
 def step_menu_monitor(self, ui):
     chs = user_interface.Chooser()
     chs.set_message(resources.get_message('configureChooseOperation'))
     chs.add("configureTrayIconVisibility",
             resources.get_message('configureTrayIconVisibility'))
     chs.set_variable(
         user_interface.VarString("configureTrayIconVisibility"))
     chs.prev_step(self.step_menu_main)
     chs.next_step(self.step_menu_monitor_selected)
     return chs
コード例 #10
0
 def step_menu_agent_disable(self, ui):
     chs = user_interface.Chooser()
     chs.set_message(resources.get_message('configureDisableAgentQuestion'))
     chs.add("yes", resources.get_message('yes'))
     chs.add("no", resources.get_message('no'))
     chs.set_variable(user_interface.VarString("no"))
     chs.set_accept_key("yes")
     chs.prev_step(self.step_menu_agent)
     chs.next_step(self.step_menu_agent_disable_procede)
     return chs
コード例 #11
0
 def step_menu_agent_install_key(self, ui):
     chs = user_interface.Chooser()
     chs.set_message(resources.get_message('configureUninstallKeyQuestion'))
     chs.add("yes", resources.get_message('yes'))
     chs.add("no", resources.get_message('no'))
     chs.set_variable(user_interface.VarString("no"))
     chs.set_accept_key("yes")
     chs.prev_step(self.step_menu_agent)
     chs.next_step(self.step_menu_agent_remove_key_selected)
     return chs
コード例 #12
0
 def _clmode_back(self):
     try:
         self.wait_message(resources.get_message("waiting"))
         ret = self._cur_step_ui.fire_prev_step()
     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._op_complete(ret)
コード例 #13
0
 def step_menu_password(self, ui):
     chs = user_interface.Chooser()
     chs.set_message(resources.get_message('configureChooseOperation'))
     chs.add("configureSetPassword",
             resources.get_message('configureSetPassword'))
     chs.add("configureRemovePassword",
             resources.get_message('configureRemovePassword'))
     chs.set_variable(self._password_menu_sel)
     chs.prev_step(self.step_menu_main)
     chs.next_step(self.step_config_password)
     return chs
コード例 #14
0
    def enable_disable(self, e):
        msg = resources.get_message('monitorDisableAgentQuestion')
        if self._cur_status == "DISABLE":
            msg = resources.get_message('monitorEnableAgentQuestion')

        dlg = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_YESNO,
                                gdi.DIALOGMESSAGE_LEVEL_INFO, self._app)
        dlg.set_title(resources.get_message('monitorTitle'))
        dlg.set_message(msg)
        dlg.set_action(self._enable_disable_action)
        dlg.show()
コード例 #15
0
 def step_menu_agent_remove_key_selected(self, ui):
     if ui.get_variable().get() == 'yes':
         try:
             self._uinterface.wait_message(
                 resources.get_message('configureUninstallationKey'), 0)
             self.uninstall_key()
         except:
             return user_interface.ErrorDialog(
                 resources.get_message('configureErrorConnection'))
         return self.step_menu_agent_install_key_selected(ui)
     else:
         return self.step_menu_agent(ui)
コード例 #16
0
 def step_menu_monitor_procede(self, ui):
     try:
         if ui.get_variable().get() == 'yes':
             self.set_config("monitor_tray_icon", "True")
         else:
             self.set_config("monitor_tray_icon", "False")
         msg = user_interface.Message(
             resources.get_message('configureTrayIconOK'))
         msg.next_step(self.step_menu_main)
         return msg
     except:
         return user_interface.ErrorDialog(
             resources.get_message('configureErrorConnection'))
コード例 #17
0
 def step_menu_agent_disable_procede(self, ui):
     if ui.get_variable().get() == 'yes':
         try:
             self.set_config("enabled", "False")
             msg = user_interface.Message(
                 resources.get_message('configureAgentDisabled'))
             msg.next_step(self.step_menu_main)
             return msg
         except:
             return user_interface.ErrorDialog(
                 resources.get_message('configureErrorConnection'))
     else:
         return self.step_menu_agent(ui)
コード例 #18
0
    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)
コード例 #19
0
 def step_check_install_code(self, ui):
     if ui.get_key() is not None and ui.get_key() == 'tryAgain':
         if ui.get_variable().get() == 'configureLater':
             return self.step_menu_main(ui)
         elif ui.get_variable().get() == 'configProxy':
             ui.set_key("installCode")
             return self.step_configure_proxy_type(ui)
         elif ui.get_variable().get() == 'reEnterCode':
             return self.step_menu_agent_install_key_selected(ui)
     msg = resources.get_message('checkInstallCode')
     self._uinterface.wait_message(msg)
     key = self._install_code.get()
     try:
         self.install_key(key)
         msg = user_interface.Message(
             resources.get_message('configureKeyInstalled'))
         msg.next_step(self.step_menu_main)
         return msg
     except Exception as e:
         s = str(e)
         if s == "INVALID_CODE":
             chs = user_interface.Chooser()
             chs.set_key("tryAgain")
             chs.set_message(resources.get_message('errorInvalidCode'))
             chs.add("reEnterCode", resources.get_message('reEnterCode'))
             chs.add("configureLater",
                     resources.get_message('configureLater'))
             chs.set_variable(user_interface.VarString("reEnterCode"))
             chs.prev_step(self.step_menu_agent_install_key_selected)
             chs.next_step(self.step_check_install_code)
             return chs
         elif s == "CONNECT_ERROR":
             chs = user_interface.Chooser()
             chs.set_key("tryAgain")
             chs.set_message(
                 resources.get_message('errorConnectionQuestion'))
             chs.add("configProxy", resources.get_message('yes'))
             chs.add("noTryAgain", resources.get_message('noTryAgain'))
             chs.add("configureLater",
                     resources.get_message('configureLater'))
             chs.set_variable(user_interface.VarString("noTryAgain"))
             chs.prev_step(self.step_menu_agent_install_key_selected)
             chs.next_step(self.step_check_install_code)
             return chs
         elif s == "REQUEST_TIMEOUT":
             return user_interface.ErrorDialog(
                 resources.get_message('configureErrorConnection'))
         else:
             return user_interface.ErrorDialog(s)
コード例 #20
0
 def step_check_password(self, ui):
     try:
         if ui.get_key() is not None and ui.get_key() == 'insert_password':
             self._password = self._ins_pwd.get()
         if not self.check_auth():
             if ui.get_key() is not None and ui.get_key(
             ) == 'insert_password':
                 return user_interface.ErrorDialog(
                     resources.get_message('configureInvalidPassword'))
             return self.step_password(ui)
         else:
             return self.step_menu_main(ui)
     except:
         return user_interface.ErrorDialog(
             resources.get_message('configureErrorConnection'))
コード例 #21
0
 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)
コード例 #22
0
ファイル: sendMails.py プロジェクト: 5l1v3r1/DepremApi
def is_updated(stmtime):
    if stmtime == os.stat(filedir).st_mtime:
        print("Nothing changed")
        return stmtime
    else:
        with open("sublist.txt", "r") as fp:
            lines = fp.readlines()
            fp.close()
        with open("lastErtq.txt", "r") as fp:
            Ertq = fp.readline()
            fp.close()
        data = split_data(Ertq)
        isbigenough = check_isbigenough(data)
        message = get_message(data)
        if isbigenough == True:
            print("Updated sending mails...")
            with open("send_mail.log", "a") as fp:
                for line in lines:
                    sendto = line.strip("\n")
                    print("Sending to : " + sendto)
                    fp.write(sendto + "     " + str(datetime.now()) + "\n")
                    send_mail(sendto, message)
                fp.close()
        elif isbigenough == False:
            print("Updated but not high enough passing.")
        else:
            pass
        return os.stat(filedir).st_mtime
コード例 #23
0
 def printInfo(self):
     msgst = ""
     appar = self.get_info()
     s = appar["state"]
     if s == '0':  #STATUS_OFFLINE
         msgst = resources.get_message('monitorStatusOffline')
     elif s == '1':  #STATUS_ONLINE
         msgst = resources.get_message('monitorStatusOnline')
     elif s == '3':  #STATUS_DISABLE
         msgst = resources.get_message('monitorStatusDisabled')
     elif s == '10':  #STATUS_UPDATING
         msgst = resources.get_message('monitorStatusUpdating')
     else:
         msgst = resources.get_message('monitorStatusNoService')
     print("Status: " + msgst)
     print("Connections: " + appar["connections"])
コード例 #24
0
 def _show_error(self, msg):
     if self._gui_enable is True:
         dlgerr = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_OK,
                                    gdi.DIALOGMESSAGE_LEVEL_ERROR,
                                    self._app)
         dlgerr.set_title(self._title)
         dlgerr.set_message(msg)
         dlgerr.set_action(self._show_error_gui_ok)
         dlgerr.show()
     else:
         print("")
         print(resources.get_message('error') + ": " + msg)
         try:
             raw_input(resources.get_message('pressEnter'))
             self._prepare_step(self._cur_step_ui)
         except:
             None
コード例 #25
0
 def step_menu_monitor_selected(self, ui):
     try:
         chs = user_interface.Chooser()
         chs.set_message(
             resources.get_message(
                 'configureChooseMonitorTrayIconVisibility'))
         chs.add("yes", resources.get_message('yes'))
         chs.add("no", resources.get_message('no'))
         if self.get_config("monitor_tray_icon") == "True":
             chs.set_variable(user_interface.VarString("yes"))
         else:
             chs.set_variable(user_interface.VarString("no"))
         chs.prev_step(self.step_menu_monitor)
         chs.next_step(self.step_menu_monitor_procede)
         return chs
     except:
         return user_interface.ErrorDialog(
             resources.get_message('configureErrorConnection'))
コード例 #26
0
 def fire_next_step(self):
     #Verifica mandatory
     for i in range(len(self._arinputs)):
         inp = self._arinputs[i]
         if inp['mandatory'] is True and inp['variable'].get().strip(
         ) == "":
             return ErrorDialog(
                 resources.get_message("fieldRequired").format(
                     inp['label']))
     return UI.fire_next_step(self)
コード例 #27
0
 def _guimode_close(self, e):
     if self._cur_step_ui is None or (self._cur_step_ui.is_next_enabled() or
                                      self._cur_step_ui.is_back_enabled()):
         dlgerr = gdi.DialogMessage(gdi.DIALOGMESSAGE_ACTIONS_YESNO,
                                    gdi.DIALOGMESSAGE_LEVEL_INFO, self._app)
         dlgerr.set_title(self._title)
         dlgerr.set_message(resources.get_message('confirmExit'))
         dlgerr.set_action(self._guimode_close_action)
         dlgerr.show()
     else:
         self.close()
コード例 #28
0
 def fire_next_step(self):
     #Verifica se selezionato
     bok = False
     for i in range(len(self._archooser)):
         inp = self._archooser[i]
         if self._variable.get() == inp["key"]:
             bok = True
             break
     if not bok:
         return ErrorDialog(resources.get_message("mustSelectOptions"))
     return UI.fire_next_step(self)
コード例 #29
0
 def step_config_password(self, ui):
     if ui.get_variable().get() == 'configureSetPassword':
         self._change_pwd = user_interface.VarString("", True)
         self._change_repwd = user_interface.VarString("", True)
         ipt = user_interface.Inputs()
         ipt.set_key("set_password")
         ipt.set_message(resources.get_message('configurePassword'))
         ipt.add('password', resources.get_message('password'),
                 self._change_pwd, True)
         ipt.add('rePassword', resources.get_message('rePassword'),
                 self._change_repwd, True)
         ipt.prev_step(self.step_menu_password)
         ipt.next_step(self.step_config_password_procede)
         return ipt
     elif ui.get_variable().get() == 'configureRemovePassword':
         chs = user_interface.Chooser()
         chs.set_key("remove_password")
         chs.set_message(
             resources.get_message('configureRemovePasswordQuestion'))
         chs.add("yes", resources.get_message('yes'))
         chs.add("no", resources.get_message('no'))
         chs.set_variable(user_interface.VarString("no"))
         chs.set_accept_key("yes")
         chs.prev_step(self.step_menu_password)
         chs.next_step(self.step_config_password_procede)
         return chs
コード例 #30
0
 def step_menu_main_selected(self, ui):
     if ui.get_variable().get() == "configureAgent":
         return self.step_menu_agent(ui)
     elif ui.get_variable().get() == "configureProxy":
         ui.set_key("menuProxy")
         return self.step_configure_proxy_type(ui)
     elif ui.get_variable().get() == "configureMonitor":
         return self.step_menu_monitor(ui)
     elif ui.get_variable().get() == "configurePassword":
         return self.step_menu_password(ui)
     elif ui.get_variable().get() == "configureExit":
         return user_interface.Message(
             resources.get_message('configureEnd'))