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 import yum
.Errors
as Errors
23 import yum
.callbacks
as callbacks
24 from yum
.callbacks
import ProcessTransBaseCallback
25 from yum
.rpmtrans
import RPMTransaction
28 from yumguicore
import YumGuiBase
,YumGuiPackageQueue
, YumGuiDownloadError
,\
29 YumGuiDepsolveError
,YumGuiDepsolveError
, YumGuiTransactionError
31 from yumguicore
.gui
import UI
,Controller
,TextViewConsole
,\
32 TextViewLogHandler
,doLoggerSetup
,doGtkEvents
,Progress
34 from yumguicore
.views
import YumGuiPackageView
, YumGuiTransactionView
,YumGuiGroupView
35 from yumguicore
.callback
import YumGuiDownloadCallback
,YumGuiRPMCallback
36 from yumguicore
.dialogs
import questionDialog
43 class MyYumGuiApp(Controller
):
44 ''' This class contains all glade signal callbacks '''
48 # Create and ui object contains the widgets.
49 ui
= UI( 'test.glade' , 'main', 'yumex' )
50 # init the Controller Class to connect signals.
51 Controller
.__init
__( self
, ui
)
52 self
.logger
= logging
.getLogger('yum.verbose.MyYumGuiApp')
57 #****************** Glade callback methods ********************
58 def on_FileQuit(self
,widget
,data
=None):
62 gtk
.main_quit() # Exit gtk
65 # called if someone clicks the 'Apply' button
67 def on_apply_clicked(self
,widget
):
69 Run the Transaction, when the apply button is pressed
71 self
.ui
.book
.set_current_page(OUTPUT_VIEW
)
72 self
.processTransaction()
76 def on_view_cursor_changed(self
,widget
):
78 Show the package description when row is changed
81 ( model
, iterator
) = widget
.get_selection().get_selected()
82 if model
!= None and iterator
!= None:
83 pkg
= model
.get_value( iterator
, 0 )
85 self
.pkgDesc
.write_line(pkg
.description
)
88 def on_groupCategories_cursor_changed(self
,widget
):
90 Update the package list when the group is changed in the group
93 ( model
, iterator
) = widget
.get_selection().get_selected()
94 if model
!= None and iterator
!= None:
95 id = model
.get_value( iterator
, 2 )
96 isCategory
= model
.get_value( iterator
, 4 )
97 if not isCategory
: # Only update package list if it is a group
98 # Get the packages in the current selected group
99 pkgs
= self
.yumbase
.getPackagesInGroup(id,self
.packages
)
100 # Populate the group package view
101 self
.grpPkgView
.populate(pkgs
)
103 def on_groupPackages_cursor_changed(self
,widget
):
108 #**************************************************************
110 ''' Setup the GUI & logging '''
111 self
.ui
.main
.connect( "delete_event", self
.on_FileQuit
)
112 self
.ui
.main
.present()
113 self
.output
= TextViewConsole( self
.ui
.output
)
114 self
.pkgDesc
= TextViewConsole( self
.ui
.pkgDesc
)
115 self
.progress
= Progress(self
.ui
.progressbar
,self
.ui
.labelProgress
,self
.ui
.vboxProgress
)
116 doLoggerSetup(self
.output
,'yum.verbose')
117 self
.rpmCallback
= YumGuiRPMCallback(self
.progress
)
120 def processTransaction(self
):
122 Perform the yum transaction
123 - Resolve Dependencies
125 - Check GPG Signature.
126 - Run Test Transaction
131 self
.logger
.info('Resolve Dependencies')
132 self
.ui
.book
.set_current_page(OUTPUT_VIEW
)
133 self
.yumbase
.doDepSolve()
134 self
.ui
.book
.set_current_page(TRANSACTION_VIEW
)
135 self
.transView
.refresh()
136 self
.logger
.info(self
.queue
.list())
137 if not questionDialog(self
.ui
.main
,'Do you want to continue with the transaction'):
139 self
.ui
.book
.set_current_page(OUTPUT_VIEW
)
140 self
.yumbase
.processTransaction(callback
=ProcessTransBaseCallback(),
141 rpmDisplay
=self
.rpmCallback
)
142 # Catch depsolve errors
143 except YumGuiDepsolveError
, msgs
:
144 mstrs
= '\n'.join(msgs
)
145 msg
= _( "Error in Dependency Resolution" )
146 self
.logger
.error(msg
)
147 self
.logger
.error(mstrs
)
148 # catch download errors
149 except YumDownloadError
, msgs
:
150 mstrs
= '\n'.join(msgs
)
151 msg
= _( "Error in Download" )
152 self
.logger
.error(msg
)
153 self
.logger
.error(mstrs
)
154 # catch Test Transaction errors
155 except YumTestTransactionError
, msgs
:
156 mstrs
= '\n'.join(msgs
)
157 self
.logger
.error(mstrs
)
158 # catch other yum errors.
159 except YumBaseError
, msgs
:
160 mstrs
= '\n'.join(msgs
)
161 self
.logger
.error(mstrs
)
166 if not self
.firstRun
: # Dont do reset the first time
169 self
.firstRun
= False
170 self
.yumbase
.setup(doUpdates
=True, doUpdateMetaData
=False)
171 # Get a list of all packages (installed + available)
172 pkgs
= self
.yumbase
.getPackages(sort
=True)
173 # Get a list of all packages (installed + available)
174 updates
= self
.yumbase
.getPackages(pkgTypes
=['updates'],sort
=True)
175 # show the packages in the package view, use po.name for typeahead search
176 self
.pkgView
.populate(pkgs
,'name')
177 #self.pkgView.populate(updates,'name')
180 self
.transView
.clear()
181 self
.grpPkgView
.clear()
182 self
.ui
.book
.set_current_page(PACKAGE_VIEW
)
183 self
.grpView
.populate()
190 #tests.testProgress(self.progress)
191 #tests.testTextViewConsole(self.output)
192 #tests.testRPMCallback(self.rpmCallback)
195 def setupPackagesView(self
,view
):
196 pkgView
= YumGuiPackageView(view
,self
.queue
,self
.transView
)
197 # Add a column to display : name - summary
198 pkgView
.createColumn('Name',400,'%s - %s',('name','summary'))
199 # Add a column to display : epoc:version.release.arch
200 pkgView
.createColumn('Version',150,'<span foreground="blue">%s:%s.%s.%s</span>',
201 ('epoch','version','release','arch',),isMarkup
= True)
202 # Add a column to display : size
203 pkgView
.createColumn('Size',100,'%s',('size',))
204 # Add a column to display : repository
205 pkgView
.createColumn('Repo',100,'%s',('repoid',))
210 self
.yumbase
= YumGuiBase(debuglevel
= 4)
211 # Setup a PackageQueue an interface to yumbase.tsInfo
212 self
.queue
= YumGuiPackageQueue(self
.yumbase
,debug
=False)
213 self
.transView
= YumGuiTransactionView(self
.ui
.transaction
,self
.queue
)
214 self
.grpPkgView
= self
.setupPackagesView(self
.ui
.groupPackages
)
215 self
.grpView
= YumGuiGroupView(self
.ui
.groupCategories
,self
.grpPkgView
,self
.transView
,self
.yumbase
)
216 # Setup a PackageView to display packages.
217 self
.pkgView
= self
.setupPackagesView(self
.ui
.view
)
218 # Setup Download Progress
219 dlCb
= YumGuiDownloadCallback(self
.progress
)
220 self
.yumbase
.setDownloadCallback(dlCb
)
221 # setup yum (load repo metadata etc)
226 if __name__
== "__main__":
227 mainApp
= MyYumGuiApp()