1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU Library General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 from yum
.Errors
import YumBaseError
23 from yum
.rpmtrans
import RPMTransaction
26 from yumguicore
import YumGuiBase
,YumGuiPackageQueue
, YumGuiDownloadError
,\
27 YumGuiDepsolveError
,YumGuiDepsolveError
, YumGuiTransactionError
29 from yumguicore
.gui
import UI
,Controller
,TextViewConsole
,\
30 TextViewLogHandler
,doLoggerSetup
,doGtkEvents
,Progress
32 from yumguicore
.views
import YumGuiPackageView
, YumGuiTransactionView
,YumGuiGroupView
33 from yumguicore
.callback
import YumGuiDownloadCallback
,YumGuiRPMCallback
34 from yumguicore
.dialogs
import questionDialog
38 class MyYumGuiApp(Controller
):
39 ''' This class contains all glade signal callbacks '''
43 # Create and ui object contains the widgets.
44 ui
= UI( 'testgui2.glade' , 'main', 'yumex' )
45 # init the Controller Class to connect signals.
46 Controller
.__init
__( self
, ui
)
47 self
.logger
= logging
.getLogger('yum.verbose.MyYumGuiApp')
52 #****************** Glade callback methods ********************
53 def onQuit(self
,widget
,data
=None):
57 gtk
.main_quit() # Exit gtk
60 def on_gotoPage1_clicked(self
,widget
,data
=None):
64 self
.ui
.notebook
.set_current_page(1)
66 def on_gotoPage0_clicked(self
,widget
,data
=None):
70 self
.ui
.notebook
.set_current_page(0)
73 #**************************************************************
75 ''' Setup the GUI & logging '''
76 self
.ui
.main
.connect( "delete_event", self
.onQuit
)
77 self
.ui
.notebook
.set_show_tabs( False )
78 self
.ui
.main
.present()
79 self
.progress
= Progress(self
.ui
.progressbar
,self
.ui
.progresslabel
,self
.ui
.vboxProgress
)
80 self
.ui
.TransactionLabel
.set_markup('<big><b>Current Transaction</b></big>')
81 self
.rpmCallback
= YumGuiRPMCallback(self
.progress
)
84 def processTransaction(self
):
86 Perform the yum transaction
87 - Resolve Dependencies
89 - Check GPG Signature.
90 - Run Test Transaction
95 self
.logger
.info('Resolve Dependencies')
96 self
.ui
.book
.set_current_page(OUTPUT_VIEW
)
97 self
.yumbase
.doDepSolve()
98 self
.ui
.book
.set_current_page(TRANSACTION_VIEW
)
99 self
.transView
.refresh()
100 self
.logger
.info(self
.queue
.list())
101 if not questionDialog(self
.ui
.main
,'Do you want to continue with the transaction'):
103 self
.ui
.book
.set_current_page(OUTPUT_VIEW
)
104 self
.logger
.info('Download Packages and check signatures')
105 self
.yumbase
.downloadPackages()
106 self
.logger
.info('Run Test Transaction')
107 self
.yumbase
.testTransaction()
108 self
.logger
.info('Run Transaction')
109 self
.yumbase
.runTransaction(self
.rpmCallback
)
110 # Catch depsolve errors
111 except YumGuiDepsolveError
, msgs
:
112 mstrs
= '\n'.join(msgs
)
113 msg
= _( "Error in Dependency Resolution" )
114 self
.logger
.error(msg
)
115 self
.logger
.error(mstrs
)
116 # catch download errors
117 except YumGuiDownloadError
, msgs
:
118 mstrs
= '\n'.join(msgs
)
119 msg
= _( "Error in Download" )
120 self
.logger
.error(msg
)
121 self
.logger
.error(mstrs
)
122 # catch Transaction errors
123 except YumGuiTransactionError
, msgs
:
124 mstrs
= '\n'.join(msgs
)
125 self
.logger
.error(mstrs
)
126 # catch other yum errors.
127 except YumBaseError
, msgs
:
128 mstrs
= '\n'.join(msgs
)
129 self
.logger
.error(mstrs
)
133 self
.ui
.notebook
.set_current_page(1)
135 if not self
.firstRun
: # Dont do reset the first time
138 self
.firstRun
= False
139 self
.yumbase
.setup(doUpdates
=True, doUpdateMetaData
=False)
140 # Get a list of all packages (installed + available)
141 pkgs
= self
.yumbase
.getPackages(sort
=True)
142 # Get a list of all packages (installed + available)
143 updates
= self
.yumbase
.getPackages(pkgTypes
=['updates'],sort
=True)
144 # show the packages in the package view, use po.name for typeahead search
145 #self.pkgView.populate(updates,'name')
147 self
.ui
.notebook
.set_current_page(0)
154 #tests.testProgress(self.progress)
155 #tests.testTextViewConsole(self.output)
156 #tests.testRPMCallback(self.rpmCallback)
161 self
.yumbase
= YumGuiBase(debuglevel
= 4)
162 # Setup a PackageQueue an interface to yumbase.tsInfo
163 self
.queue
= YumGuiPackageQueue(self
.yumbase
,debug
=False)
164 # Setup a PackageView to display packages.
165 dlCb
= YumGuiDownloadCallback(self
.progress
)
166 self
.yumbase
.setDownloadCallback(dlCb
)
167 # setup yum (load repo metadata etc)
170 if __name__
== "__main__":
171 mainApp
= MyYumGuiApp()