Fixed LOGPPRINT and LOGRAWDATA, export log window
authoretotheipi <etotheipi@gmail.com>
Tue, 10 Jul 2012 02:51:01 +0000 (22:51 -0400)
committeretotheipi <etotheipi@gmail.com>
Tue, 10 Jul 2012 02:51:01 +0000 (22:51 -0400)
ArmoryQt.py
armoryengine.py
qtdialogs.py

index 38b7e43..324f1e9 100644 (file)
@@ -288,13 +288,11 @@ class ArmoryMainWindow(QMainWindow):
       btnRecvBtc   = QPushButton("Receive Bitcoins")
       btnWltProps  = QPushButton("Wallet Properties")
       btnOfflineTx = QPushButton("Offline Transactions")
-      btnDevTools  = QPushButton("Expert Tools")
  
 
       self.connect(btnWltProps, SIGNAL('clicked()'), self.execDlgWalletDetails)
       self.connect(btnRecvBtc,  SIGNAL('clicked()'), self.clickReceiveCoins)
       self.connect(btnSendBtc,  SIGNAL('clicked()'), self.clickSendBitcoins)
-      self.connect(btnDevTools, SIGNAL('clicked()'), self.openToolsDlg)
       self.connect(btnOfflineTx,SIGNAL('clicked()'), self.execOfflineTx)
 
       verStr = 'Armory %s-alpha / %s User' % (getVersionString(BTCARMORY_VERSION), \
@@ -311,7 +309,6 @@ class ArmoryMainWindow(QMainWindow):
       if self.usermode in (USERMODE.Advanced, USERMODE.Expert):
          logoBtnFrame.append(btnOfflineTx)
       logoBtnFrame.append(lblInfo)
-      #logoBtnFrame.append(btnDevTools)
       logoBtnFrame.append('Stretch')
 
       btnFrame = makeVertFrame(logoBtnFrame, STYLE_SUNKEN)
@@ -1808,36 +1805,26 @@ class ArmoryMainWindow(QMainWindow):
             # just seeing the updated balance when they get back to the main
             # screen
             if not TheBDM.getTxByHash(newTxHash).isInitialized():
-               #failedFN = os.path.join(ARMORY_HOME_DIR, 'failedtx.bin')
-               #f = open(failedFN, 'ab')
-               #bp = BinaryPacker()
-               #bp.put(UINT64, long(RightNow()))
-               #f.write(bp.getBinaryString())
-               #f.write(pytx.serialize())
-               #f.close()
                LOGERROR('Transaction was not accepted by the Satoshi client')
                LOGERROR('Raw transaction:')
                LOGRAWDATA(pytx.serialize(), logging.ERROR)
                LOGERROR('Transaction details')
                LOGPPRINT(pytx, logging.ERROR)
                QMessageBox.warning(self, 'Invalid Transaction', \
-               'The transaction that you just executed, does not '
-               'appear to have been accepted by the Bitcoin network. '
-               'This sometimes happens with legitimate transactions '
-               'when a fee is not included but was required.  Sometimes '
-               'it will happen when you have zero-confirmation transactions '
-               'waiting to get into the blockchain.  Or it is due to a '
-               'bug in the Armory software.  '
-               '<br><br>Please consider reporting this error the the Armory '
-               'developers.  All information the developers need is '
-               'in the following file: <br><br>' + ARMORY_LOG_FILE + '<br><br>'
-               'This file never '
-               'contains any sensitive data, so it is safe to send to '
-               'the Armory developers for help diagnosing the issue, and '
-               'fixing any potential bugs.  '
-               'Please email the above file to '
-               'alan.reiner@gmail.com along with any information you can '
-               'provide about the context of this failed transaction.', QMessageBox.Ok)
+                  'The transaction that you just executed, does not '
+                  'appear to have been accepted by the Bitcoin network. '
+                  'This sometimes happens with legitimate transactions '
+                  'when a fee is not included but was required.  Sometimes it '
+                  'is caused by network issues.  '
+                  'Or it is due to a bug in the Armory software.  '
+                  '<br><br>Please consider reporting this error the the Armory '
+                  'developers.  If you do, please use '
+                  '"<b>File</b>"-->"<b>Export Log File</b>" '
+                  'from the main window to make a copy of your log file to send '
+                  'via email to alan.reiner@gmail.com.  Please also include any '
+                  'information you might consider relevant about the context of '
+                  'this failed transaction.' , \
+                  QMessageBox.Ok)
                   
          reactor.callLater(2, sendGetDataMsg)
          reactor.callLater(4, checkForTxInBDM)
index 4c758db..c72236e 100644 (file)
@@ -288,8 +288,8 @@ DEFAULT_RAWDATA_LOGLEVEL  = logging.DEBUG
 rootLogger = logging.getLogger('')
 if CLI_OPTIONS.doDebug:
    # Drop it all one level: console will see INFO, file will see DEBUG
-   DEFAULT_FILE_LOGTHRESH    -= 10
-   DEFAULT_PPRINT_LOGTHRESH  -= 10
+   DEFAULT_CONSOLE_LOGTHRESH  -= 10
+   DEFAULT_FILE_LOGTHRESH     -= 10
 
 
 if CLI_OPTIONS.logDisable:
@@ -331,25 +331,25 @@ def LOGPPRINT(theObj, loglevel=DEFAULT_PPRINT_LOGLEVEL):
    theObj.pprint()
    printedStr = sys.stdout.getStr()
    sys.stdout = sys.__stdout__
-   stkOneUp   = traceback.extract_stack()[1]
-   filename   = stkOneUp[0]
-   methodLine = stkOneUp[1]
-   methodStr  = '(PPRINT from %s::%d)\n' % (filename,methodLine)
+   stkOneUp = traceback.extract_stack()[-2]
+   filename,method = stkOneUp[0], stkOneUp[1]
+   methodStr  = '(PPRINT from %s:%d)\n' % (filename,method)
    logging.log(loglevel, methodStr + printedStr)
    
 # For super-debug mode, we'll write out raw data
 def LOGRAWDATA(rawStr, loglevel=DEFAULT_RAWDATA_LOGLEVEL):
    dtype = isLikelyDataType(rawStr)
-   stkOneUp   = traceback.extract_stack()[1]
-   filename   = stkOneUp[0]
-   methodLine = stkOneUp[1]
-   methodStr  = '(PPRINT from %s::%d)\n' % (filename,methodLine)
+   stkOneUp = traceback.extract_stack()[-2]
+   filename,method = stkOneUp[0], stkOneUp[1]
+   methodStr  = '(PPRINT from %s:%d)\n' % (filename,method)
    pstr = rawStr[:]
    if dtype==DATATYPE.Binary:
       pstr = binary_to_hex(rawStr)
-      pstr = prettyHex(pstr, indent='  ')
+      pstr = prettyHex(pstr, indent='  ', withAddr=False)
    elif dtype==DATATYPE.Hex:
-      pstr = prettyHex(pstr, indent='  ')
+      pstr = prettyHex(pstr, indent='  ', withAddr=False)
+   else:
+      pstr = '   ' + '\n   '.join(pstr.split('\n'))
 
    logging.log(loglevel, methodStr + pstr)
 
@@ -544,7 +544,7 @@ TheBDM = Cpp.BlockDataManager().getBDM()
 
 
 
-DATATYPE = enum("Binary", "ASCII", 'Base58', 'Hex')
+DATATYPE = enum("Binary", 'Base58', 'Hex')
 def isLikelyDataType(theStr, dtype=None):
    """ 
    This really shouldn't be used on short strings.  Hence
@@ -553,15 +553,12 @@ def isLikelyDataType(theStr, dtype=None):
    ret = None
    hexCount = sum([1 if c in BASE16CHARS else 0 for c in theStr])
    b58Count = sum([1 if c in BASE58CHARS else 0 for c in theStr])
-   ascCount = sum([1 if 32<=ord(c)<=126 else 0 for c in theStr])
    canBeHex = hexCount==len(theStr)
    canBeB58 = b58Count==len(theStr)
    if canBeHex:
       ret = DATATYPE.Hex
    elif canBeB58 and not canBeHex:
       ret = DATATYPE.Base58
-   elif ascCount==len(theStr):
-      ret = DATATYPE.ASCII
    else:
       ret = DATATYPE.Binary
 
@@ -5497,7 +5494,7 @@ class PyTxDistProposal(object):
 
       endline = ('-------END-TRANSACTION-' + self.uniqueB58 + '-----').ljust(80,'-')
       txdpLines.append( endline )
-      self.pprint()
+      LOGPPRINT(self, logging.DEBUG)
       return '\n'.join(txdpLines)
       
 
index 9e6c5fd..25aa521 100755 (executable)
@@ -329,7 +329,7 @@ class DlgNewWallet(ArmoryDialog):
          if kdfUnit.lower()=='kb':
             self.kdfBytes = round(float(kdfM))*(1024.0)
 
-         print 'KDF takes', self.kdfSec, 'sec and', self.kdfBytes, 'bytes'
+         LOGINFO('KDF takes', self.kdfSec, 'sec and', self.kdfBytes, 'bytes')
       except:
          QMessageBox.critical(self, 'Invalid KDF Parameters', \
             'Please specify time with units, such as '
@@ -3438,7 +3438,7 @@ class DlgImportPaperWallet(ArmoryDialog):
                'fixed automatically.  Please double-check that you entered the '
                'text exactly as it appears on the wallet-backup page.', \
                QMessageBox.Ok)
-            print 'BadData!'
+            LOGERROR('Error in wallet restore field')
             self.labels[i].setText('<font color="red">'+str(self.labels[i].text())+'</font>')
             return
          if not fixedData==data:
@@ -3897,7 +3897,7 @@ class DlgRemoveWallet(ArmoryDialog):
             thepathBackup = wlt.getWalletPath('backup')
 
             if self.radioWatch.isChecked():
-               print '***Converting to watching-only wallet'
+               LOGINFO('***Converting to watching-only wallet')
                newWltPath = wlt.getWalletPath('WatchOnly')
                wlt.forkOnlineWallet(newWltPath, wlt.labelName, wlt.labelDescr)
                newWlt = PyBtcWallet().readWalletFile(newWltPath)
@@ -3910,7 +3910,7 @@ class DlgRemoveWallet(ArmoryDialog):
                self.main.statusBar().showMessage( \
                      'Wallet %s was replaced with a watching-only wallet.' % wltID, 10000)
             elif self.radioDelete.isChecked():
-               print '***Completely deleting wallet'
+               LOGINFO('***Completely deleting wallet')
                os.remove(thepath)
                os.remove(thepathBackup)
                self.main.removeWalletFromApplication(wltID) 
@@ -4783,7 +4783,6 @@ class DlgSendBitcoins(ArmoryDialog):
             finalTx = txdp.prepareFinalTx()
             if len(commentStr)>0:
                self.wlt.setComment(finalTx.getHash(), commentStr)
-            print binary_to_hex(finalTx.serialize())
             self.main.broadcastTransaction(finalTx)
             self.accept()
             try:
@@ -4966,7 +4965,7 @@ class DlgSendBitcoins(ArmoryDialog):
       self.selectedBehavior = ''
       if totalChange>0:
          self.change160 = self.determineChangeAddr(utxoSelect)
-         print 'Change address behavior: ', self.selectedBehavior
+         LOGINFO('Change address behavior: ', self.selectedBehavior)
          if not self.change160:
             return
          recipValuePairs.append( [self.change160, totalChange])
@@ -6083,8 +6082,7 @@ class DlgReviewOfflineTx(ArmoryDialog):
       filename = self.main.getFileSave('Save Transaction', \
                              ['Transactions (*.signed.tx *.unsigned.tx)'], \
                              defaultFilename)
-      print "Default:", defaultFilename
-      print filename
+      LOGINFO('Saved transaction file: %s', filename)
 
       if len(str(filename))>0:
          f = open(filename, 'w')
@@ -6095,8 +6093,9 @@ class DlgReviewOfflineTx(ArmoryDialog):
    def loadTx(self):
       filename = self.main.getFileLoad('Load Transaction', \
                              ['Transactions (*.signed.tx *.unsigned.tx)'])
-      print filename
+      
       if len(str(filename))>0:
+         LOGINFO('Selected transaction file to load: %s', filename)
          f = open(filename, 'r')
          self.txtTxDP.setText(f.read())
          f.close()
@@ -6420,13 +6419,13 @@ def extractTxInfo(pytx, rcvTime=None):
          txOutToList[-1].append(pubs)
          txOutToList[-1].append(mstype[0]) # this is M (from M-of-N)
       elif scrType in (TXOUT_SCRIPT_OP_EVAL,):
-         print 'No OP_EVAL support yet!'
+         LOGERROR('OP_EVAL doesn\'t exist anymore.  How did we get here?')
          txOutToList[-1].append(txout.binScript)
       elif scrType in (TXOUT_SCRIPT_UNKNOWN,):
-         #print 'Unknown TxOut type'
+         LOGERROR('Unknown TxOut type')
          txOutToList[-1].append(txout.binScript)
       else:
-         print 'How did we miss TXOUT_SCRIPT_UNKNOWN txout type?'
+         LOGERROR('Unrecognized txout script that isn\'t TXOUT_SCRIPT_UNKNOWN...?')
       sumTxOut += txout.value
   
 
@@ -6469,7 +6468,7 @@ def extractTxInfo(pytx, rcvTime=None):
                txinFromList[-1].append(prevTxOut.getParentTxPtr().getThisHash())
                txinFromList[-1].append(prevTxOut.getIndex())
             else:
-               print 'How did we get a bad parent pointer? (extractTxInfo)'
+               LOGERROR('How did we get a bad parent pointer? (extractTxInfo)')
                prevTxOut.pprint()
                txinFromList[-1].append('')
                txinFromList[-1].append('')
@@ -9495,7 +9494,7 @@ class DlgExportTxHistory(ArmoryDialog):
       elif 'descend' in sortTxt:
          ledgerTable.sort(key=lambda x: x[LEDGERCOLS.TxHash], reverse=True)
       else:
-         print '***ERROR: bad sort string!?'
+         LOGERROR('***ERROR: bad sort string!?')
          return