def onActivated_after(self, view):
        self.setDisabled(False)
        #self.con_lost_lbl.hide()
        if type(view) == Exception:
            if hasattr (view.message, 'message'):
                view = view.message

            if type(view.message) == tuple:
                if view.message[0] == 403:
                    msg = _('Permission denied')
                else:
                    msg = ' '.join(map(lambda x: str(x), view.message))
            else:
                msg = view.message.__str__()
            show_msg(msg)
            return 1

        method_name = self.ClientObj.method_name
        self._parent.main_frame.viewport().setStyleSheet('')

        # set new Title
        if self.ClientObj.method_names.has_key(method_name):
            view_method = self.ClientObj.method_names[method_name]
        else:
            view_method = method_name
        self.ClientObj._parent.setWindowTitle \
                (view_method + ' - ' + self.ClientObj._parent.windowTitle())
        self.ClientObj.MainWidget.main_frame_view(view, method_name)
 def wrapper():
     try:
         #            fc = open (ClientObj.user_config, 'w')
         #            fc.close()
         os.remove(ClientObj.user_config)
         ClientObj.create_user_config()
         ClientObj.read_user_config(ClientObj.user_config)
     except Exception, e:
         show_msg(e, "Clear Config Error")
 def clear_cache(self, client, sid):
     def wrapper():
         try:
             res = client.service.clear_session_cache(sid)
         except Exception, e:
             show_msg(e, 'Error')
             return 1
         if res:
             show_msg(_('Error clearing the session cache'), parent = self)
         else:
             show_msg(_('Session cache cleared'), parent = self)
    def create_req(self):
        if len(self.country.text()) != 2:
            show_msg(_('The \"Country\" field must be two-character'), \
                     _('Input error'))
            return
        from M2Crypto import X509
#########################################
        private_key_passwd = self.passwd_lineedit.text()
        rsa = generateRSAKey()
        rsa.save_key(self.key + '_pub', cipher = None,
                     callback = lambda *unused: None)

        pkey = makePKey(rsa)
        if not passphrase_callback(private_key_passwd):
            pkey.save_key(self.key, cipher = None,
                          callback = lambda *unused: None)
        else:
            pkey.save_key(self.key,\
                            callback= lambda *unused: str(private_key_passwd))
#########################################
        req = X509.Request()
        req.set_version(req.get_version())
        req.set_pubkey(pkey)
        name = X509.X509_Name()
#######
        # Create NAME value
        name.CN = self.host_name.text()
        User_name = self.user_name.text()
        name.OU = User_name.encode('utf-8')
        Organization = self.org_name.text()
        name.O = Organization.encode('utf-8')
        name.L = self.netw_adr.text()
        State = self.state_name.text()
        name.ST = State.encode('utf-8')
        name.C = self.country.text()
#######
        req.set_subject_name(name)

        ext1 = X509.new_extension('Comment', 'Auto Generated')
        extstack = X509.X509_Extension_Stack()
        extstack.push(ext1)
        req.add_extensions(extstack)
        req.sign(pkey, 'md5')
#########################################
        crtreq = req.as_pem()
        crtfile = open(self.cert_path + '/%s.csr' %self.server_host_name, 'w')
        crtfile.write(crtreq)
        crtfile.close()
        self.close()
        self._parent.end_send()
#########################################
    def onActivated_after(self, view):
        if type(view) == Exception:
            if hasattr(view.message, "message"):
                view = view.message

            if type(view.message) == tuple:
                if view.message[0] == 403:
                    msg = _("Permission denied")
                else:
                    msg = " ".join(map(lambda x: str(x), view.message))
            else:
                msg = view.message.__str__()
            show_msg(msg)
            return 1

        self._parent.ClientObj.MainWidget.main_frame_view(view, self._parent.ClientObj.method_name)
 def kill_process_after(self, result):
     if result == 0:
         msg = _("Well killed!")
     elif result == 2:
         msg = _("Process completed")
     elif result == -1:
         msg = _("Certificate not found in the server!")
     elif result == -2:
         msg = _("Session not matching your certificate!")
     elif result == 1:
         msg = _("Failed to kill the process!")
     else:
         msg = 'error'
     
     show_msg(msg)
     self.ClientObj.MainWidget.view_processes()        
def client_post_cert (client, lang):
    """ send a certificate server for check """
    sid = get_sid(client)
    results = client.service.post_cert()
    if results[0][0] == -4:
        show_msg (_("Certificate not found in the server!"), _('Error'))
        raise Exception()
    sid, new_session = client_sid(sid, client, results[0][0], lang)
    if new_session:
        _print (_(" New session"))
    else: _print (_(" Old session"))
    _print (_(" Your session ID: %s") %sid)
    if results[0][0] == -3:
        _print (_("Certificate not sent!"))
    else:
        _print (_(" Your certifitate ID: %d") %(results[0][0]))
        try:
            if results[0][1] == -2:
                _print (_("Certificate expired"))
            elif results[0][1] > 0:
                _print (_("The certificate expires after %d days")%(results[0][1]))
        except:
            pass
    def send_bug(self):
        name = self.name_edit.text()

        sender = self.send_mail_edit.text()
        mail_re = re.compile("^[a-zA-Z_0-9\.\-]{1,32}[\@]{1}[a-zA-Z_0-9]"+\
                             "{1,16}[\.]{1}[a-zA-Z]{1,3}$")
        if not mail_re.findall(sender):
            show_msg (_('Enter a valid email!'))
            return 1

        to_name = 'calculate bug report'
        receivers = '*****@*****.**'
        subject = self.subject_edit.text()

        body = self.message_edit.toPlainText()
        try:
            body = body.encode('utf-8')
        except:
            body = str(body)

        # assemble the message
        performDebugging = False
        msg = MIMEText(body)
        msg.set_charset('utf-8')
        msg['To'] = email.utils.formataddr((to_name, receivers))
        msg['From'] = email.utils.formataddr((name, sender))
        msg['Subject'] = 'Bug Report: ' + subject

        server = smtplib.SMTP('mail')
        server.set_debuglevel(performDebugging)
        try:
            server.sendmail(sender, [receivers], msg.as_string())
            show_msg (_("Message sent!"))
            server.quit()
            self.close()
        except:
            show_msg (_("Sending error"))
            server.quit()
 def wrapper():
     try:
         res = client.service.clear_session_cache(sid)
     except Exception, e:
         show_msg(e, 'Error')
         return 1
    def start_update_system(self):

        if not self.update_thread.isRunning():
            self.update_thread.start()
        else:
            show_msg(_('An update is already running'))