Пример #1
0
 def gui_input(self, MSG, Title="UserInput", BgC="white", AnsBoxSize=10):
     if type(MSG) != u"aaa":
         MSG = unicode(MSG, "cp936")
     dialog = FrontEnd(Title, MSG, Config=self.configData, QbgC=BgC, AnsBoxSize=AnsBoxSize)
     UserReturn = dialog.queryUser(MSG)
     if UserReturn == "+":
         raise UserWantRestart(MSG)
     return unicode(UserReturn)
Пример #2
0
def mainloop():
    app = PySimpleApp()
    this = RecordClient()
    while True:
        try:
            UserName = this.getUserName()
            Machine, Product = this.getMachineAndProduct()
            msg = "\n\n"
            msg = msg + "工序:" + Machine + "\n"
            msg = msg + "产品:" + Product + "\n"
            if this.ask_input(msg, AnsBoxSize=this.ConfirmBoxSize) == "":
                msg = ""
            this.queryParms()
            msg = ""
            this.Time = this.time_now().split(".")[0]
            msg = msg  # + this.Time +" "
            Shift = this.calculateShift()
            msg = msg + "姓名: " + UserName + "\n"
            msg = msg + "工序:" + Machine + "\n"
            msg = msg + "产品:" + Product + "\n"
            for each in this.BarcodeTable[this.thisBarcode][5:]:
                if each != "":
                    each = each.encode("cp936")
                    tmpV = this.ParmDict[each]
                    msg = msg + each + ":" + str(tmpV) + "\n"
            print msg
            if this.ask_input(msg, AnsBoxSize=this.ConfirmBoxSize) == "":
                is_Parms_confirmed = True
            this.dataTag = str(time.time())
            tmpTime = datetime.datetime.now()
            this.dataIndex = (
                str(tmpTime.month) + str(tmpTime.day) + str(tmpTime.hour) + str(tmpTime.minute) + str(tmpTime.second)
            )
            this.dataTag = this.dataIndex
            this.updateDB()
            this.printViaPrinter()
            this.ask_input("\n\n" + "请取打印单" + "\n" + "操作结束!", AnsBoxSize=this.ConfirmBoxSize)
            # 异常处理
        except UserWantRestart as UserRestart:
            print "User ask restart!"
            continue

        except ErrorToUser as UserError:
            ErrorInfo = "!!!Error!!!" + str(UserError)
            # print it to backscreen
            print ErrorInfo
            # show it to user as well
            dialog = FrontEnd("", "", Config=this.configData)
            dialog.showInfo2User(ErrorInfo)
            continue

        except Exception as excep1:
            import sys, traceback

            exceptionTraceback = sys.exc_info()
            traceback.print_exc(file=sys.stdout)
            # Send Error Report to user
            try:
                print "Error found !  mailto:[email protected]"
                CrashReport = "CrashReport:\t" + traceback.format_exc()
                Reporter = ErrorReporter("*****@*****.**", "JiuJiu Error Report:\t" + Ver, CrashReport, "")
                Reporter.sendmail()
            except Exception as ExcepReporter:
                exceptionTraceback = sys.exc_info()
                traceback.print_exc(file=sys.stdout)
            # TODO: show fault to user!
            dialog = FrontEnd("", "", Config=this.configData)
            dialog.showInfo2User(this.ErrorMessage)
            continue