Esempio n. 1
0
    def _requestFeedback(self,response):
        if self.type == "get users":
            if not os.path.exists("bin/admin"):
                os.mkdir("bin/admin")            
            with open("bin/admin/allusers.dat",'wb') as newfile:
                pickle.dump(response,newfile)
        elif self.type == "update user":
            if response:
                wx.MessageBox("%s"%"Update Successful","Server Response",wx.ICON_INFORMATION)
            else:
                wx.MessageBox("%s"%"Update could not be made","Server Response",wx.ICON_ERROR)                
        elif self.type == "get gname":
            if not os.path.exists("bin/admin"):
                os.mkdir("bin/admin")            
            for i in response[2]:
                fun.add_new_group(i)
            with open("bin/admin/gnames.dat",'wb') as newfile:
                pickle.dump(response[2],newfile)
            
        elif self.type == "get clients":
            response = pickle.loads(response)
            with open("bin/groupclients.dat",'wb') as newfile:
                pickle.dump(response,newfile)            
            style = (response[1],"INFORMATION",wx.ICON_INFORMATION)
            fun.update_gclients()
            box = Printer(style)
            box.messageBox()
        elif self.type == "audit trail":
            response = pickle.loads(response)
            with open("bin/admin/audit.dat",'wb') as newfile:
               pickle.dump(response,newfile)
        elif self.type == "update protocol":
            wx.MessageBox("%s details have been updated"%response,"Server Response",wx.ICON_INFORMATION)
        elif self.type == "get messages":
            if response[0] == "Failure":
                wx.MessageBox("No messeges found","Server Response",wx.ICON_INFORMATION)
            else:
                inbox = InboxManager()
                data1 = {'current':response[1]}
                inbox.write(data1)
                
        elif self.type == "delete messages":
                if response[0] == "Failure":
                    wx.MessageBox("No messages to delete","Server Response",wx.ICON_ERROR)
                else:
                    wx.MessageBox("%s message(s) deleted"%len(response[1]),"Server Response",wx.ICON_INFORMATION)
        elif self.type == "save compd":
                if response:
                    style = ("Success","SERVER RESPONSE",wx.ICON_INFORMATION)
                else:
                    style = ("Failed","SERVER RESPONSE",wx.ICON_ERROR)
                box = Printer(style)
                box.messageBox()
        elif self.type == "add user":
                if response:
                    style = ("Succesfully added new user","SERVER RESPONSE",wx.ICON_INFORMATION)
                else:
                    style = ("Failed to add new user","SERVER RESPONSE",wx.ICON_ERROR)
                box = Printer(style)
                box.messageBox()
        elif self.type == "add check":
                if response:
                    style = ("Success", "SERVER RESPONSE", wx.ICON_INFORMATION)
                else:
                    style = ("Failed to add new user","SERVER RESPONSE",wx.ICON_ERROR)
                box = Printer(style)
                box.messageBox()

        else:        
             if response[0] == "Error":
                     style = (response[1],"ERROR",wx.ICON_ERROR)
             elif response[0] == False:
                     style = (response[1],"ERROR", wx.ICON_ERROR)
             else:
                print response
                style = (response[1],"INFORMATION", wx.ICON_INFORMATION)
             box = Printer(style)
             box.messageBox()
Esempio n. 2
0
    def _requestFeedback(self, response):
        if self.type == 'all':
            if isinstance(response, dict):
                for key, value in response.items():
                    file_name = "bin/%s.dat" % key
                    with open(file_name, 'wb') as fl:
                        print >>sys.stdout, "Updating %s" % key
                        pickle.dump(value, fl)
                print time.ctime()
            else:
                print "All details Error"
        elif self.type == 'get users':
            if not os.path.exists('bin/admin'):
                os.mkdir('bin/admin')
            with open('bin/admin/allusers.dat', 'wb') as newfile:
                pickle.dump(response, newfile)
        elif self.type == 'update user':
            if response:
                wx.MessageBox('Update Successful', 'Server Response', wx.ICON_INFORMATION)
            else:
                wx.MessageBox('%s' % 'Update could not be made', 'Server Response', wx.ICON_ERROR)

        elif self.type == 'get groups':
            if not os.path.exists('bin/admin'):
                os.mkdir('bin/admin')
            for i in response[2]:
                fun.add_new_group(i)
            with open('bin/admin/gnames.dat', 'wb') as newfile:
                pickle.dump(response[2], newfile)

        elif self.type == "get outbox":
            with open('bin/outbox.dat', "wb") as fl:
                pickle.dump(response, fl)

        elif self.type == 'get group members':
            response = pickle.loads(response)
            with open('bin/members.dat', 'wb') as newfile:
                pickle.dump(response[2], newfile)
            style = (response[1], 'INFORMATION', wx.ICON_INFORMATION)
            box = Printer(style)
            box.messageBox()

        elif self.type == 'audit trail':
            response = pickle.loads(response)
            with open('bin/admin/audit.dat', 'wb') as newfile:
                pickle.dump(response, newfile)
        elif self.type == 'update protocol':
            wx.MessageBox('%s details have been updated' % response, 'Server Response', wx.ICON_INFORMATION)
        elif self.type == 'get messages':
            if response[0] == 'Failure':
                wx.MessageBox('No messages found', 'Server Response', wx.ICON_INFORMATION)
            else:
                inbox = InboxManager()
                data1 = {'current': response[1]}
                inbox.write(data1)
        elif self.type == 'delete messages':
            if response[0] == 'Failure':
                wx.MessageBox('No messages to delete', 'Server Response', wx.ICON_ERROR)
            else:
                wx.MessageBox('%s message(s) deleted' % len(response[1]), 'Server Response', wx.ICON_INFORMATION)
        elif self.type == 'save compd':
            if response:
                style = ('Success', 'SERVER RESPONSE', wx.ICON_INFORMATION)
            else:
                style = ('Failed', 'SERVER RESPONSE', wx.ICON_ERROR)
            box = Printer(style)
            box.messageBox()
        elif self.type == 'add cheque':
            if response:
                style = ('Success', 'SERVER RESPONSE', wx.ICON_INFORMATION)
            else:
                style = ('Failed to add new user', 'SERVER RESPONSE', wx.ICON_ERROR)
            box = Printer(style)
            box.messageBox()
        else:
            try:
                response[0]
            except TypeError:
                print response
                return

            if response[0] == 'Error':
                style = (response[1], 'ERROR', wx.ICON_ERROR)
            elif not response[0]:
                style = (response[1], 'ERROR', wx.ICON_ERROR)
            else:
                print response
                style = (response[1], 'INFORMATION', wx.ICON_INFORMATION)
            box = Printer(style)
            box.messageBox()