Esempio n. 1
0
    def Dbcon_Rclk(self):
        """Disconnect / reconnect iffy record from db. 
        
        Disc = pass bk to undo, recon = when undo is not null, move it back to bk;
        both overwrite current user input completely.
        Only relevant for mtc 5, for now.
        Updates the displayed list key including postprocessing, but it's display only -
        a swap back ought to ignore mtc 2 when a bk is available."""
        Deb_Prtlog("Start dbcon",logging.DEBUG)
        verr = 0
        try:
            (idx,lkey,_,quemem) = List_Getsel1(self.lstQue,1)
            if idx >= 0:
                (verr,_,_) = quemem.Swap_Dbcon()
                if verr == METHCODES["badact"][0]:
                    Deb_Prtlog(LOGMSG["swpwr"].format(lkey),logging.WARN)
                    return verr
                (tdisp,_) = List_Text(quemem,"qseq")
                self.lstQue.item(idx).setText(tdisp)
                self.Show_Details(quemem) # Refresh display.
                Deb_Prtlog(LOGMSG["swpok"].format(lkey),logging.DEBUG)
#                 scrque.Tag_Postprocess(self.lstQue)
            else:
                pass
        except Exception as err:
            Quiterr(err)
Esempio n. 2
0
def List_Del(frm,lstw,selidx):
    """Removes (selected) recs from both list and que class.
    
    Index is list of the (selected) items (modelindex list or empty) format, or ints.
    Not actually items (listwidgetitem) - doesn't know its own index."""
#     self.lstQue.selectedIndexes()[0].row(),
#     self.lstQue.selectedIndexes()[0].column(),
#     self.lstQue.selectedIndexes()[0].data())
    Deb_Prtlog("Start listdel",logging.DEBUG)
#     dbini = dbrefs[-1]
    verr = 0
    inddsl = False
    for itm in selidx: # No items, no delete.
        if isinstance(itm,int):
            idx = itm
        else:
            idx = itm.row()
        skey = lstw.takeItem(idx)
        skey = skey.text()
        # Alt: Generic way.
        # skey = lstw.item(idx).text()
        lkey = QueStr2Key(skey)
        qkey = tuple(lkey[:2])
        
#         scrque.Del_One(qkey)
        inddsl = True
        Deb_Prtlog(LOGMSG["quedok"].format(skey),logging.DEBUG)
        
    if inddsl and int(dbini["Main"][Sini("CHKDSL")]) == 1:
        List_Desel(lstw) # Creep: Ini setting. Faster for multidelete.
        
    return verr
Esempio n. 3
0
def Quiterr(err):
    """Default exception handling.
    
    Log and print then quit.
    Trigger wherever code potentially unsafe."""
    Deb_Prtlog("Start quit due to error",logging.DEBUG)
    global indcrash # Alt: Append to list requires no global ref.
    badfunc = inspect.stack()[1][3] # [0][3] is current function, 1 is caller.
    # These are much faster methods for current func, but use "private" members.
#     print(inspect.currentframe().f_code.co_name)
#     print(sys._getframe().f_code.co_name)
    Deb_Prtlog(LOGMSG["guier"].format(badfunc,err.__class__.__name__,err.args))
    indcrash = True 
    for frm in FORMDIR.values():
        frm.close()
Esempio n. 4
0
def Start_Form():
    """Start form - for use by callers.
    
    Spam."""
    verr = 0
    global dbini
    global indcrash # Lasting indication from the gui.
    global FORMDIR
    global quecmb1
    global quecmb2
    dbini = Init_Parms()
    # Start gui.
    app = QtWidgets.QApplication(sys.argv)
    FORMDIR["Main"] = MainApp()
    #FORMDIR["Query"] = QueryApp()
    FORMDIR["Main"].show()
    FORMDIR["Main"].New_Board()
    quecmb1 = [] # No need for the intricacy of updque class. 
    quecmb2 = []
    try:
        app.exec_()
    except Exception as err: # Not very useful, since the gui hangs after uncaught action.
        Deb_Prtlog(LOGMSG["guier"].format(err.__class__.__name__,err.args))
        indcrash = True
    if indcrash:
        verr = METHCODES["guierr"][0]
#     input() # Keeps the thread alive after form window is closed.
    return verr
Esempio n. 5
0
def Go_Form(curfrm,newfrm):
    """Hide current form and show different one.
    
    Send appname vals as parms.
    Alt: Permit sending references directly."""
    Deb_Prtlog("Start form switch",logging.DEBUG)
    FORMDIR[curfrm].hide()
    FORMDIR[newfrm].show()
Esempio n. 6
0
def Main():
    """Activates function calls.
    
    Main."""
    Deb_Prtlog("Start main",logging.DEBUG)
    uti.St_Timer("Main")
    verr = 0
    
    Start_Form()
    
    tdiff = uti.Ed_Timer("Main")
    print("\nFin.")
    Deb_Prtlog("End main {}".format(tdiff),logging.DEBUG) # Remember that timestamp is automatic in logger.
    if verr == 0:
        uti.Msgbox(LOGMSG["mainok"],"Good morning chrono")
    else:
        uti.Msgbox(LOGMSG["mainer"],"Wake up")
    
    return verr
Esempio n. 7
0
    def Load_Db(self,laddq):
        """Load data from query form.
        
        As in other functions, laddq should be dict (pid+lseq) of dicts (full data from sel).
        Build it externally as necessary."""
        cntnew = 0
        cntiffy = 0
        cntdrop = 0
        for vtag in laddq.values():
            key = (vtag["pid"],-1) # Use the default load increment.
#             scrque[key] = vtag
        (_,_,cntupd) = List_Add(self.lstQue,laddq,"qseq")
        Deb_Prtlog(LOGMSG["queok"].format(cntnew,cntiffy,cntupd,cntdrop),logging.INFO)
Esempio n. 8
0
def Init_Parms():
    """Loads up (db connections and) ini parms - LEAN VERSION.
    
    Spam."""
    Deb_Prtlog("Start init parms",logging.DEBUG)
#     filedb = ldb.LiteBrowser(dbbs = "Tagger",cre = CREFILE, crex = CREFILEX, fld = DBFLD,
#                              dbtb = "filetag",nseq = 0,spsz = None,autosp = None)
    dbini = uti.IniFile(INIFLD) # Parms saved or loaded in place using ini keywords.
    for (inikey,inidef) in INIDDL.values():
        vdef = dbini["Main"][inikey]
        if vdef is None:
            vdef = inidef
        dbini["Main"][inikey] = vdef
    return dbini
Esempio n. 9
0
def Questrcnv(que1,key):
    """Convenience que1 value -> str.
    
    Uses dict to discern type.
    Que1 can be either que1 class or dict (ie one of the bks)."""
    if uti.islstup(key):
        qtyp = QUETYPES[key[0]]
        qval = [que1[k] for k in key]
    else:
        qtyp = QUETYPES[key]
        qval = que1[key]
    (verr,tval) = Type_Conv(qval,qtyp,True)
    if verr != 0:
        Deb_Prtlog(LOGMSG["qcnver"].format(key),logging.WARN)
    return tval
Esempio n. 10
0
    def Screen_Init(self):
        """Small direct links of gui - inner data.
        
        Spam."""
        Deb_Prtlog("Start main screen init",logging.DEBUG)
#         dbini = dbrefs[-1]
        # Init widgets.
#         self.txtDser.setText(dbini["Main"][Sini("DEFSER")])
#         self.chkUpdRem.setChecked(int(dbini["Main"][Sini("CHKUPD")])) # Alt: Setchecked?
#         self.chkLFull.setChecked(int(dbini["Main"][Sini("CHKFUL")]))
#         self.chkLDir.setChecked(int(dbini["Main"][Sini("CHKDIR")]))
#         self.chkDsl.setChecked(int(dbini["Main"][Sini("CHKDSL")]))
        # print(self.chkLDir.isChecked(),self.chkLDir.checkState(),self.chkLFull.checkState()) # Test.
        #self.lstQue.clear()
        self.ltxtBoard = [] # May vary in size.
        MLSTCONT.Add_Key(self.lstRes1,"opt","combo")
        MLSTCONT.Add_Key(self.lstRes2,"dang","combo")
        self.txtHiddenTest.hide()
        self.Clear_Details()