Changeset c71b68c


Ignore:
Timestamp:
Jul 12, 2013 10:48:43 AM (12 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
4f9718b
Parents:
b5cfd4d
git-author:
Ken Moore <ken@…> (07/12/13 10:44:39)
git-committer:
Ken Moore <ken@…> (07/12/13 10:48:43)
Message:

Add a bunch of error loggin to the backend processes, and also add a new dialog for displaying these error logs. Also fix the detection of an update failure.

Location:
src-qt4/pc-softwaremanager
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-softwaremanager/configDialog.h

    r78fa8b2 rc71b68c  
     1/*************************************************************************** 
     2 *   Copyright (C) 2011 - iXsystems                                       * 
     3 *   kris@pcbsd.org  * 
     4 *   tim@pcbsd.org   * 
     5 *   ken@pcbsd.org   * 
     6 *                                                                         * 
     7 *   Permission is hereby granted, free of charge, to any person obtaining * 
     8 *   a copy of this software and associated documentation files (the       * 
     9 *   "Software"), to deal in the Software without restriction, including   * 
     10 *   without limitation the rights to use, copy, modify, merge, publish,   * 
     11 *   distribute, sublicense, and/or sell copies of the Software, and to    * 
     12 *   permit persons to whom the Software is furnished to do so, subject to * 
     13 *   the following conditions:                                             * 
     14 *                                                                         * 
     15 *   The above copyright notice and this permission notice shall be        * 
     16 *   included in all copies or substantial portions of the Software.       * 
     17 *                                                                         * 
     18 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       * 
     19 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    * 
     20 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 
     21 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     * 
     22 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 
     23 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * 
     24 *   OTHER DEALINGS IN THE SOFTWARE.                                       * 
     25 ***************************************************************************/ 
    126#ifndef _APPCAFE_CONFIG_DIALOG_H 
    227#define _APPCAFE_CONFIG_DIALOG_H 
  • src-qt4/pc-softwaremanager/mainUI.cpp

    rf3baeb9 rc71b68c  
    7373     connect(PBI,SIGNAL(SearchComplete(QStringList,QStringList)),this,SLOT(slotShowSearchResults(QStringList, QStringList)) ); 
    7474     connect(PBI,SIGNAL(SimilarFound(QStringList)),this,SLOT(slotShowSimilarApps(QStringList)) ); 
    75      connect(PBI,SIGNAL(Error(QString,QString)),this,SLOT(slotDisplayError(QString,QString)) ); 
     75     connect(PBI,SIGNAL(Error(QString,QString,QStringList)),this,SLOT(slotDisplayError(QString,QString,QStringList)) ); 
    7676     PBI->start(); 
    7777 
     
    893893} 
    894894 
    895 void MainUI::slotDisplayError(QString title,QString err){ 
    896   QMessageBox::warning(this,title,err); 
     895void MainUI::slotDisplayError(QString title,QString message,QStringList log){ 
     896  ErrorDialog *dlg = new ErrorDialog(this); 
     897  dlg->setDLGTitle(title); 
     898  dlg->setDLGMessage(message); 
     899  dlg->setDLGLog(log); 
     900  dlg->exec(); 
     901  //QMessageBox::warning(this,title,message+"\n\n"+log.join("\n")); 
    897902} 
    898903 
  • src-qt4/pc-softwaremanager/mainUI.h

    rf3baeb9 rc71b68c  
    2727#include "largeItemWidget.h" 
    2828#include "smallItemWidget.h" 
     29#include "ErrorDialog.h" 
    2930 
    3031namespace Ui { 
     
    9899  void on_group_bapp_similar_toggled(bool); 
    99100  //OTHER 
    100   void slotDisplayError(QString,QString); 
     101  void slotDisplayError(QString,QString,QStringList); 
    101102 
    102103private: 
  • src-qt4/pc-softwaremanager/pbiBackend.cpp

    rf3baeb9 rc71b68c  
    3838   connect(PMAN, SIGNAL(ProcessFinished(int)),this,SLOT(slotProcessFinished(int)) ); 
    3939   connect(PMAN, SIGNAL(ProcessMessage(int, QString)),this,SLOT(slotProcessMessage(int, QString)) ); 
    40    connect(PMAN, SIGNAL(ProcessError(int,QString)),this,SLOT(slotProcessError(int,QString)) ); 
     40   connect(PMAN, SIGNAL(ProcessError(int,QStringList)),this,SLOT(slotProcessError(int,QStringList)) ); 
    4141   PENDINGREMOVAL.clear(); PENDINGDL.clear(); PENDINGINSTALL.clear(); PENDINGUPDATE.clear(); PENDINGOTHER.clear(); 
    4242   sDownload=FALSE; sInstall=FALSE; sUpdate=FALSE; sRemove=FALSE; 
     
    557557  } 
    558558  return output; 
    559   /* 
    560   for(int i=0; i<pbilist.length(); i++){ 
    561     if(PBIHASH[pbilist[i]].metaID == appID){ 
    562       switch (PBIHASH[pbilist[i]].status){ 
    563         case InstalledPBI::DOWNLOADING: 
    564           output = tr("Downloading"); break; 
    565         case InstalledPBI::INSTALLING: 
    566           output = tr("Installing"); break; 
    567         case InstalledPBI::REMOVING: 
    568           output = tr("Removing"); break; 
    569         case InstalledPBI::UPDATING: 
    570           output = tr("Updating"); break; 
    571         case InstalledPBI::PENDINGDOWNLOAD: 
    572           output = tr("Pending Download"); break; 
    573         case InstalledPBI::PENDINGINSTALL: 
    574           output = tr("Pending Install"); break; 
    575         case InstalledPBI::PENDINGREMOVAL: 
    576           output = tr("Pending Removal"); break; 
    577         case InstalledPBI::PENDINGUPDATE: 
    578           output = tr("Pending Update"); break; 
    579         default: //do nothing for the rest 
    580           output.clear(); 
    581       } 
    582       if(!output.isEmpty()){ break; } //break out of the loop 
    583     } 
    584   } 
    585   return output;*/ 
    586559} 
    587560 
     
    943916   bool resync = FALSE; 
    944917   if(ID == ProcessManager::UPDATE){ 
     918     if(!isInstalled(cUpdate).isEmpty()){ 
     919       //Error completing the update - old version still installed 
     920       QString title = QString(tr("%1 Update Error:")).arg(PBIHASH[cUpdate].name); 
     921       QString err = tr("The PBI could not be updated, please try again later"); 
     922       QStringList log = PMAN->getProcessLog(ProcessManager::UPDATE); 
     923       emit Error(title,err,log); 
     924     } 
    945925     cUpdate.clear(); //remove that it is finished 
    946926     sUpdate=FALSE; 
     
    969949         QString title = QString(tr("%1 Download Error:")).arg(PBIHASH[cDownload].name); 
    970950         QString err = tr("The PBI could not be downloaded, please try again later"); 
    971          emit Error(title,err); 
     951         QStringList log = PMAN->getProcessLog(ProcessManager::DOWNLOAD); 
     952         emit Error(title,err,log); 
    972953       }else{ 
    973954         //Now Check to see if an alternate version needs to be removed 
    974          QString otherID = isInstalled( Extras::nameToID(PBIHASH[cDownload].name) ); 
     955         QString otherID = isInstalled( PBIHASH[cDownload].metaID ); 
    975956         QString cmd; 
    976957         if(!otherID.isEmpty()){ 
     
    1003984} 
    1004985 
    1005 void PBIBackend::slotProcessError(int ID, QString err){ 
     986void PBIBackend::slotProcessError(int ID, QStringList log){ 
    1006987   QString title; 
    1007988   QString name; 
     989   QString message; 
    1008990   if(ID == ProcessManager::UPDATE){ 
    1009991     if(!sUpdate){ //not stopped manually 
    1010992       if(PBIHASH.contains(cUpdate)){name = PBIHASH[cUpdate].name; } 
    1011993       title = QString(tr("%1 Update Error:")).arg(name);  
     994       message = tr("The update process experienced an error and could not be completed"); 
    1012995     } 
    1013996   } 
     
    1016999       if(APPHASH.contains(cInstall)){name = APPHASH[cInstall].name; } 
    10171000       title = QString(tr("%1 Installation Error:")).arg(name); 
     1001       message = tr("The installation process experienced an error and could not be completed"); 
    10181002     } 
    10191003   } 
     
    10221006       if(PBIHASH.contains(cRemove)){name = PBIHASH[cRemove].name; } 
    10231007       title = QString(tr("%1 Removal Error:")).arg(name); 
     1008       message = tr("The removal process experienced an error and could not be completed"); 
    10241009     } 
    10251010   } 
     
    10281013       if(APPHASH.contains(cDownload)){name = APPHASH[cDownload].name; } 
    10291014       title = QString(tr("%1 Download Error:")).arg(name); 
     1015       message = tr("The download process experienced an error and could not be completed"); 
    10301016     } 
    10311017   } 
     
    10331019     if(PBIHASH.contains(cOther)){name = PBIHASH[cOther].name; } 
    10341020     title = QString(tr("%1 PBI Error:")).arg(name);  
    1035    } 
    1036    if(!title.isEmpty() && !err.isEmpty()){ 
    1037      qDebug() << "Process Error:" << title << err; 
    1038      emit Error(title,err); //send error signal 
     1021     message = tr("The process experienced an error and could not be completed"); 
     1022   } 
     1023   if(!title.isEmpty() && !message.isEmpty()){ 
     1024     qDebug() << "Process Error:" << title << log; 
     1025     emit Error(title,message,log); //send error signal 
    10391026   } 
    10401027   slotProcessFinished(ID); //clean up 
  • src-qt4/pc-softwaremanager/pbiBackend.h

    rf3baeb9 rc71b68c  
    126126        void slotProcessFinished(int); 
    127127        void slotProcessMessage(int, QString); 
    128         void slotProcessError(int, QString); 
     128        void slotProcessError(int, QStringList); 
    129129 
    130130        // Database watcher 
     
    146146        void PBIStatusChange(QString pbiID); 
    147147        //Process Signals 
    148         void Error(QString title, QString message); 
     148        void Error(QString title, QString message, QStringList log); 
    149149        //Search results 
    150150        void SearchComplete(QStringList, QStringList);// "best" and "rest" results lists 
  • src-qt4/pc-softwaremanager/pc-softwaremanager.pro

    r24ef714 rc71b68c  
    1616          pbiDBAccess.h \ 
    1717          processManager.h \ 
    18           configDialog.h 
     18          configDialog.h \ 
     19          ErrorDialog.h 
    1920 
    2021SOURCES += main.cpp \ 
     
    2425         pbiDBAccess.cpp \ 
    2526         processManager.cpp \ 
    26          configDialog.cpp 
     27         configDialog.cpp \ 
     28         ErrorDialog.cpp 
    2729 
    2830RESOURCES += SoftwareManager.qrc 
    2931 
    3032FORMS   = mainUI.ui \ 
    31         configDialog.ui 
     33        configDialog.ui \ 
     34        ErrorDialog.ui 
    3235 
    3336TARGET  = pc-softwaremanager 
  • src-qt4/pc-softwaremanager/processManager.cpp

    r78fa8b2 rc71b68c  
    7878  if( ID == UPDATE ){ 
    7979    qDebug() << "Update Process Started:" << cmd; 
     80    upLog.clear(); //clear the log for action 
    8081    upProc->start(cmd);    
    8182  }else if( ID == REMOVE ){ 
    8283    qDebug() << "Removal Process Started:" << cmd; 
     84    remLog.clear(); 
    8385    remProc->start(cmd);                   
    8486  }else if( ID == DOWNLOAD ){ 
    8587    qDebug() << "Download Process Started:" << cmd; 
     88    dlLog.clear(); 
    8689    dlProc->start(cmd);            
    8790  }else if( ID == INSTALL ){ 
    8891    qDebug() << "Install Process Started:" << cmd; 
     92    inLog.clear(); 
    8993    inProc->start(cmd);            
    9094  }else if( ID == OTHER ){ 
     
    113117} 
    114118 
     119QStringList ProcessManager::getProcessLog(ProcessID ID){ 
     120  if( ID == UPDATE ){ return upLog; } 
     121  else if( ID == REMOVE ){ return remLog; } 
     122  else if( ID == DOWNLOAD ){ return dlLog; } 
     123  else if( ID == INSTALL ){ return inLog; } 
     124  else{ return QStringList(); } 
     125} 
    115126 
    116127// ========================= 
     
    174185// == UPDATE PROCESS == 
    175186void ProcessManager::slotUpProcMessage(){ 
    176     while( upProc->canReadLine() ){ 
     187  while( upProc->canReadLine() ){ 
    177188    QString line = upProc->readLine().simplified(); 
     189    if(line.isEmpty()){ continue; } 
    178190    QString dl = parseDlLine(line); 
    179191    if(!dl.isEmpty()){ emit ProcessMessage(UPDATE,dl); } 
     192    else{ upLog << line; } //not a download line - add to the log 
    180193  } 
    181194} 
     
    183196void ProcessManager::slotUpProcFinished(){ 
    184197  if(upProc->exitStatus() != QProcess::NormalExit){ 
    185     QString msg = upProc->readAllStandardError(); 
    186     if(msg.isEmpty()){ msg = upProc->readAllStandardOutput(); } 
    187     if(msg.isEmpty()){ msg = tr("Unknown Error"); } 
    188     qDebug() << "Update Process Error:"<<msg; 
    189     emit ProcessError(UPDATE, msg); 
     198    //Emit the command log 
     199    qDebug() << "Update Process Error Log:\n"<<upLog.join("\n"); 
     200    emit ProcessError(UPDATE, upLog); 
    190201  }else{ 
    191202    qDebug() << "Update Process Finished"; 
     
    196207// == REMOVE PROCESS == 
    197208void ProcessManager::slotRemProcMessage(){ 
    198   QString msg = remProc->readAllStandardOutput(); 
    199   emit ProcessMessage(REMOVE,msg); 
     209  while( remProc->canReadLine() ){ 
     210    QString line = remProc->readLine().simplified(); 
     211    if(!line.isEmpty()){  
     212      remLog << line;  
     213      emit ProcessMessage(REMOVE,line); 
     214    } 
     215  } 
    200216} 
    201217 
    202218void ProcessManager::slotRemProcFinished(){ 
    203219  if(remProc->exitStatus() != QProcess::NormalExit){ 
    204     QString msg = remProc->readAllStandardError(); 
    205     if(msg.isEmpty()){ msg = remProc->readAllStandardOutput(); } 
    206     if(msg.isEmpty()){ msg = tr("Unknown Error"); } 
    207     qDebug() << "Removal Process Error:"<<msg; 
    208     emit ProcessError(REMOVE, msg); 
     220    qDebug() << "Removal Process Error Log:\n"<<remLog.join("\n"); 
     221    emit ProcessError(REMOVE, remLog); 
    209222  }else{ 
    210223    qDebug() << "Removal Process Finished"; 
     
    217230  while( dlProc->canReadLine() ){ 
    218231    QString line = dlProc->readLine().simplified(); 
     232    if(line.isEmpty()){ continue; } 
    219233    QString dl = parseDlLine(line); 
    220234    if(!dl.isEmpty()){ emit ProcessMessage(DOWNLOAD,dl); } 
     235    else{ dlLog << line; } //not a download line - add to the log 
    221236  } 
    222237} 
     
    224239void ProcessManager::slotDlProcFinished(){ 
    225240  if(dlProc->exitStatus() != QProcess::NormalExit){ 
    226     QString msg = dlProc->readAllStandardError(); 
    227     if(msg.isEmpty()){ msg = dlProc->readAllStandardOutput(); } 
    228     if(msg.isEmpty()){ msg = tr("Unknown Error"); } 
    229     qDebug() << "Download Process Error:"<<msg; 
    230     emit ProcessError(DOWNLOAD, msg); 
     241    qDebug() << "Download Process Error Log:\n"<<dlLog.join("\n"); 
     242    emit ProcessError(DOWNLOAD, dlLog); 
    231243  }else{ 
    232244    qDebug() << "Download Process Finished"; 
     
    237249// == INSTALL PROCESS == 
    238250void ProcessManager::slotInProcMessage(){ 
    239   QString msg = inProc->readAllStandardOutput(); 
    240   emit ProcessMessage(INSTALL,msg); 
     251  while( inProc->canReadLine() ){ 
     252    QString line = inProc->readLine().simplified(); 
     253    if(!line.isEmpty()){  
     254      inLog << line;  
     255      emit ProcessMessage(INSTALL,line); 
     256    } 
     257  } 
    241258} 
    242259 
    243260void ProcessManager::slotInProcFinished(){ 
    244261  if(inProc->exitStatus() != QProcess::NormalExit){ 
    245     QString msg = inProc->readAllStandardError(); 
    246     if(msg.isEmpty()){ msg = inProc->readAllStandardOutput(); } 
    247     if(msg.isEmpty()){ msg = tr("Unknown Error"); } 
    248     qDebug() << "Install Process Error:"<<msg; 
    249     emit ProcessError(INSTALL, msg); 
     262    qDebug() << "Install Process Error Log:\n"<<inLog.join("\n"); 
     263    emit ProcessError(INSTALL, inLog); 
    250264  }else{ 
    251265    qDebug() << "Install Process Finished"; 
     
    266280    if(msg.isEmpty()){ msg = tr("Unknown Error"); } 
    267281    qDebug() << "Other Process Error:"<<msg; 
    268     emit ProcessError(OTHER, msg); 
     282    emit ProcessError(OTHER, QStringList(msg)); 
    269283  }else{ 
    270284    qDebug() << "Other Process Finished"; 
  • src-qt4/pc-softwaremanager/processManager.h

    r78fa8b2 rc71b68c  
    55#include <QProcessEnvironment> 
    66#include <QString> 
     7#include <QStringList> 
    78#include <QObject> 
    89#include <QDebug> 
     
    2324        void startProcess(ProcessID, QString); 
    2425        void stopProcess(ProcessID); 
     26        QStringList getProcessLog(ProcessID); 
    2527         
    2628signals: 
    2729        void ProcessFinished(int ID); 
    2830        void ProcessMessage(int ID,QString); 
    29         void ProcessError(int ID,QString); 
     31        void ProcessError(int ID,QStringList); 
    3032         
    3133private: 
    3234        QProcess *upProc, *remProc, *dlProc, *inProc, *otProc; 
     35        QStringList upLog, remLog, dlLog, inLog; 
    3336         
    3437private slots: 
Note: See TracChangeset for help on using the changeset viewer.