- when installing a package, datecreation will be updated accordingly to the system date
- fixed few things here and there - started to work on spritz packages search git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@994 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -1543,6 +1543,11 @@ class etpDatabase(TextInterface):
|
||||
raise exceptionTools.CorruptionError("CorruptionError: I tried to insert compile flags but then, fetching it returned -1. There's something broken.")
|
||||
self.commitChanges()
|
||||
|
||||
# date expressed the unix way
|
||||
def setDateCreation(self, idpackage, date):
|
||||
self.cursor.execute('UPDATE extrainfo SET datecreation = (?) WHERE idpackage = (?)', (str(date),idpackage,))
|
||||
self.commitChanges()
|
||||
|
||||
def setDigest(self, idpackage, digest):
|
||||
self.cursor.execute('UPDATE extrainfo SET digest = (?) WHERE idpackage = (?)', (digest,idpackage,))
|
||||
self.commitChanges()
|
||||
|
||||
@@ -268,7 +268,7 @@ class EquoInterface(TextInterface):
|
||||
depend
|
||||
), importance = 0, type = "info", back = True, count = (cnt, maxlen) )
|
||||
self.atomMatch(depend)
|
||||
self.updateProgress(darkred("Dependencies filled. Flushing to disk."), importance = 2, type = "warning")
|
||||
self.updateProgress(darkred("Dependencies cache filled."), importance = 2, type = "warning")
|
||||
self.save_cache()
|
||||
|
||||
def load_cache(self):
|
||||
@@ -2191,6 +2191,10 @@ class PackageInterface:
|
||||
del data
|
||||
del status # if operation isn't successful, an error will be surely raised
|
||||
|
||||
# update datecreation
|
||||
ctime = self.Entropy.entropyTools.getCurrentUnixTime()
|
||||
self.Entropy.clientDbconn.setDateCreation(idpk, str(ctime))
|
||||
|
||||
# add idpk to the installedtable
|
||||
self.Entropy.clientDbconn.removePackageFromInstalledTable(idpk)
|
||||
self.Entropy.clientDbconn.addPackageToInstalledTable(idpk,self.infoDict['repository'])
|
||||
@@ -4416,7 +4420,7 @@ class TriggerInterface:
|
||||
rc = self.trigger_call_ext_generic()
|
||||
return rc
|
||||
|
||||
def call_ext_postinstall(self):
|
||||
def trigger_call_ext_postinstall(self):
|
||||
rc = self.trigger_call_ext_generic()
|
||||
return rc
|
||||
|
||||
@@ -4453,6 +4457,7 @@ class TriggerInterface:
|
||||
stdfile.close()
|
||||
|
||||
stage = self.phase
|
||||
pkgdata = self.pkgdata
|
||||
my_ext_status = 0
|
||||
execfile(triggerfile)
|
||||
os.remove(triggerfile)
|
||||
|
||||
@@ -1364,6 +1364,10 @@ def convertUnixTimeToHumanTime(unixtime):
|
||||
humantime = str(datetime.fromtimestamp(unixtime))
|
||||
return humantime
|
||||
|
||||
def getCurrentUnixTime():
|
||||
import time
|
||||
return time.time()
|
||||
|
||||
def convertSecondsToFancyOutput(seconds):
|
||||
|
||||
mysecs = seconds
|
||||
@@ -1647,10 +1651,10 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
|
||||
pkgver = package[len(package)-1]
|
||||
pkglen -= 1
|
||||
for i in range(pkglen):
|
||||
if i == pkglen-1:
|
||||
pkgname += package[i]
|
||||
else:
|
||||
pkgname += package[i]+"-"
|
||||
if i == pkglen-1:
|
||||
pkgname += package[i]
|
||||
else:
|
||||
pkgname += package[i]+"-"
|
||||
pkgname = pkgname.split("/")[len(pkgname.split("/"))-1]
|
||||
|
||||
# Fill Package name and version
|
||||
@@ -1664,11 +1668,11 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
|
||||
if not silent: print_info(yellow(" * ")+red(info_package+"Getting package mtime..."),back = True)
|
||||
# .tbz2 md5
|
||||
data['datecreation'] = str(getFileUnixMtime(tbz2File))
|
||||
|
||||
|
||||
if not silent: print_info(yellow(" * ")+red(info_package+"Getting package size..."),back = True)
|
||||
# .tbz2 byte size
|
||||
data['size'] = str(os.stat(tbz2File)[6])
|
||||
|
||||
|
||||
if not silent: print_info(yellow(" * ")+red(info_package+"Unpacking package data..."),back = True)
|
||||
# unpack file
|
||||
tbz2TmpDir = etpConst['packagestmpdir']+"/"+data['name']+"-"+data['version']+"/"
|
||||
|
||||
+12
-10
@@ -17,16 +17,12 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#import logging
|
||||
|
||||
from misc import const,cleanMarkupSting
|
||||
from i18n import _
|
||||
from dialogs import questionDialog
|
||||
#from urlgrabber.grabber import URLGrabError
|
||||
|
||||
# Entropy Imports
|
||||
from entropyConstants import *
|
||||
import entropyTools
|
||||
import exceptionTools
|
||||
from entropy import EquoInterface, urlFetcher
|
||||
|
||||
@@ -52,9 +48,12 @@ class Equo(EquoInterface):
|
||||
import exceptionTools
|
||||
raise exceptionTools.IncorrectParameter("IncorrectParameter: count length must be >= 2")
|
||||
count_str = " (%s/%s) " % (str(count[0]),str(count[1]),)
|
||||
self.progress.set_progress( round((float(count[0])/count[1]),1), str(int(round((float(count[0])/count[1])*100,1)))+"%" )
|
||||
if importance == 0:
|
||||
progress_text = text
|
||||
else:
|
||||
progress_text = str(int(round((float(count[0])/count[1])*100,1)))+"%"
|
||||
self.progress.set_progress( round((float(count[0])/count[1]),1), progress_text )
|
||||
|
||||
myfunc = self.progress.set_extraLabel
|
||||
if importance == 1:
|
||||
myfunc = self.progress.set_subLabel
|
||||
elif importance == 2:
|
||||
@@ -63,7 +62,8 @@ class Equo(EquoInterface):
|
||||
# show warning popup
|
||||
# FIXME: interface with popup !
|
||||
myfunc = self.progress.set_extraLabel
|
||||
myfunc(count_str+text)
|
||||
if importance > 0:
|
||||
myfunc(count_str+text)
|
||||
if not back:
|
||||
self.progressLog(count_str+text)
|
||||
|
||||
@@ -73,10 +73,10 @@ class Equo(EquoInterface):
|
||||
|
||||
class GuiUrlFetcher(urlFetcher):
|
||||
""" hello my highness """
|
||||
|
||||
|
||||
def connect_to_gui(self, progress):
|
||||
self.progress = progress
|
||||
|
||||
|
||||
# reimplementing updateProgress
|
||||
def updateProgress(self):
|
||||
|
||||
@@ -86,7 +86,9 @@ class GuiUrlFetcher(urlFetcher):
|
||||
self.progress.set_extraLabel("%s/%s kB @ %s" % (
|
||||
str(round(float(self.downloadedsize)/1024,1)),
|
||||
str(round(self.remotesize,1)),
|
||||
str(entropyTools.bytesIntoHuman(self.datatransfer))+"/sec",
|
||||
str(self.entropyTools.bytesIntoHuman(self.datatransfer))+"/sec",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
EquoConnection = Equo()
|
||||
+85
-134
@@ -17,75 +17,113 @@
|
||||
# Authors:
|
||||
# Tim Lauridsen <tla@rasmil.dk>
|
||||
|
||||
from etpgui import format_number
|
||||
import time
|
||||
from entropyConstants import *
|
||||
from entropyapi import EquoConnection
|
||||
import types
|
||||
|
||||
|
||||
class PackageWrapper:
|
||||
def __init__(self,pkg,avail):
|
||||
self.__pkg = pkg
|
||||
self.available = avail
|
||||
def __init__(self, matched_atom, avail):
|
||||
|
||||
def __str__( self ):
|
||||
return str(self.__pkg)
|
||||
|
||||
def __cmp__( self,pkg):
|
||||
n1 = str(self.__pkg)
|
||||
n2 = str(pkg)
|
||||
if n1 > n2:
|
||||
return 1
|
||||
elif n1 == n2:
|
||||
return 0
|
||||
if matched_atom[1] == 0:
|
||||
self.dbconn = EquoConnection.clientDbconn
|
||||
else:
|
||||
return -1
|
||||
|
||||
|
||||
self.dbconn = EquoConnection.openRepositoryDatabase(matched_atom[1])
|
||||
self.matched_atom = matched_atom
|
||||
self.idpackage = self.matched_atom[0]
|
||||
self.repository = self.matched_atom[1]
|
||||
self.atom = self.dbconn.retrieveAtom(self.idpackage)
|
||||
self.version = self.dbconn.retrieveVersion(self.idpackage)
|
||||
self.versiontag = self.dbconn.retrieveVersionTag(self.idpackage)
|
||||
self.revision = self.dbconn.retrieveRevision(self.idpackage)
|
||||
self.pkgtuple = (self.version,self.versiontag,self.revision)
|
||||
match = self.dbconn.atomMatch(self.atom)
|
||||
if match[0] != -1:
|
||||
self.available = True
|
||||
else:
|
||||
self.available = False
|
||||
|
||||
def __str__(self):
|
||||
return str(self.atom)
|
||||
|
||||
def __cmp__(self, pkg):
|
||||
pkgcmp = EquoConnection.entropyTools.entropyCompareVersions(self.pkgtuple,pkg.pkgtuple)
|
||||
return pkgcmp
|
||||
|
||||
def getPkg(self):
|
||||
return self.__pkg
|
||||
|
||||
return self.matched_atom
|
||||
|
||||
def getName(self):
|
||||
return self.__pkg.name
|
||||
|
||||
return self.atom
|
||||
|
||||
def getTup(self):
|
||||
return self.__pkg.pkgtup
|
||||
return self.pkgtuple
|
||||
|
||||
def getRepoId(self):
|
||||
return self.__pkg.repoid
|
||||
|
||||
return self.repository
|
||||
|
||||
def getIdpackage(self):
|
||||
return self.idpackage
|
||||
|
||||
def getVer(self):
|
||||
return self.__pkg.printVer()
|
||||
|
||||
tag = ""
|
||||
if self.versiontag:
|
||||
tag = "#"+self.versiontag
|
||||
tag += "~"+str(self.revision)
|
||||
return self.version+tag
|
||||
|
||||
|
||||
def getSummaryFirst(self):
|
||||
summary = self.__pkg.returnSimple( 'summary' )
|
||||
if summary:
|
||||
return self._toUTF(summary.splitlines()[0])
|
||||
else:
|
||||
return ''
|
||||
return str(self.dbconn.getBaseData(self.idpackage))
|
||||
|
||||
def getSummary(self):
|
||||
return self.__pkg.returnSimple( 'summary' )
|
||||
return str(self.dbconn.getScopeData(self.idpackage))
|
||||
|
||||
def getDescription(self):
|
||||
return self.__pkg.returnSimple( 'description' )
|
||||
|
||||
return self.dbconn.retrieveDescription(self.idpackage)
|
||||
|
||||
def getSize(self):
|
||||
return float(self.__pkg.size)
|
||||
|
||||
return self.dbconn.retrieveSize(self.idpackage)
|
||||
|
||||
def getSizeFmt(self):
|
||||
return format_number(float(self.__pkg.size))
|
||||
|
||||
|
||||
return EquoConnection.entropyTools.bytesIntoHuman(self.dbconn.retrieveSize(self.idpackage))
|
||||
|
||||
|
||||
def getArch(self):
|
||||
return self.__pkg.arch
|
||||
|
||||
return etpConst['currentarch']
|
||||
|
||||
def getEpoch(self):
|
||||
return self.__pkg.epoch
|
||||
return self.dbconn.retrieveDateCreation(self.idpackage)
|
||||
|
||||
def getRel(self):
|
||||
return self.__pkg.release
|
||||
|
||||
return self.dbconn.retrieveBranch(self.idpackage)
|
||||
|
||||
def _toUTF( self, txt ):
|
||||
""" this function convert a string to unicode to make gtk happy"""
|
||||
rc=""
|
||||
if isinstance(txt,types.UnicodeType):
|
||||
return txt
|
||||
else:
|
||||
try:
|
||||
rc = unicode( txt, 'utf-8' )
|
||||
except UnicodeDecodeError, e:
|
||||
rc = unicode( txt, 'iso-8859-1' )
|
||||
return rc
|
||||
|
||||
def getAttr(self,attr): # XXX
|
||||
return eval("self.dbconn.retrieve"+attr)(self.idpackage)
|
||||
|
||||
def _get_time( self ):
|
||||
return self.dbconn.retrieveDateCreation(self.idpackage)
|
||||
|
||||
def get_changelog( self ):
|
||||
return "No ChangeLog"
|
||||
|
||||
def get_filelist( self ):
|
||||
return self.dbconn.retrieveContent(self.idpackage)
|
||||
|
||||
def get_fullname( self ):
|
||||
return self.atom # XXX
|
||||
|
||||
pkg = property(fget=getPkg)
|
||||
name = property(fget=getName)
|
||||
repoid = property(fget=getRepoId)
|
||||
@@ -99,91 +137,4 @@ class PackageWrapper:
|
||||
sizeFmt = property(fget=getSizeFmt)
|
||||
arch = property(fget=getArch)
|
||||
epoch = property(fget=getEpoch)
|
||||
pkgtup = property(fget=getTup)
|
||||
|
||||
def _toUTF( self, txt ):
|
||||
""" this function convert a string to unicode to make gtk happy"""
|
||||
rc=""
|
||||
if isinstance(txt,types.UnicodeType):
|
||||
return txt
|
||||
else:
|
||||
try:
|
||||
rc = unicode( txt, 'utf-8' )
|
||||
except UnicodeDecodeError, e:
|
||||
rc = unicode( txt, 'iso-8859-1' )
|
||||
return rc
|
||||
|
||||
|
||||
def getAttr(self,attr):
|
||||
# Check for attributes, contained in the pkg object
|
||||
if self.available:
|
||||
return self._get_available_attr(attr)
|
||||
else:
|
||||
return self._get_installed_attr(attr)
|
||||
|
||||
def _get_available_attr(self,attr):
|
||||
if attr in self.__pkg.__dict__.keys(): # pkg attribute ?
|
||||
return getattr(self.__pkg,attr)
|
||||
else:
|
||||
return self.__pkg.returnSimple(attr)
|
||||
|
||||
def _dumpAttrs(self,obj):
|
||||
attrList = [attr for attr in dir(obj) if not callable(getattr(self.__pkg, attr))]
|
||||
print "\n".join(["%s = %s" % (attr,getattr(obj,attr)) for attr in attrList])
|
||||
|
||||
|
||||
def _get_installed_attr(self,attr):
|
||||
# we can't test for member so just try to get it.
|
||||
try:
|
||||
return self.__pkg.returnSimple(attr)
|
||||
except KeyError:
|
||||
# We want a AttributeError Exception, if not found
|
||||
raise AttributeError, attr
|
||||
|
||||
def _get_time( self ):
|
||||
if not self.available: # Installed packages dont have filetime
|
||||
ftime = int( self.__pkg.returnSimple( 'installtime' ) )
|
||||
else:
|
||||
ftime = int( self.__pkg.returnSimple( 'filetime' ) )
|
||||
return ftime
|
||||
|
||||
def get_changelog( self ):
|
||||
""" Get changelog from package object"""
|
||||
cl = []
|
||||
if self.available: # YumAvailablePackage
|
||||
clog = self.__pkg.returnChangelog()
|
||||
for tim, name, text in clog:
|
||||
cl.append( str( time.ctime( float( tim ) ) )+" "+name+"\n"+text )
|
||||
else: # YumInstalledPackage, get files from rpm header.
|
||||
cltime = self.__pkg.hdr['changelogtime']
|
||||
clname = self.__pkg.hdr['changelogname']
|
||||
cltext = self.__pkg.hdr['changelogtext']
|
||||
if not isinstance(cltime, types.ListType): # cltime should always be a list
|
||||
cltime = [cltime]
|
||||
for tim, name, text in zip( cltime, clname, cltext ):
|
||||
cl.append( str( time.ctime( tim ) )+" "+name+"\n"+text )
|
||||
return cl
|
||||
|
||||
def get_filelist( self ):
|
||||
""" Get filelist from package object"""
|
||||
if self.available: # YumAvailablePackage
|
||||
files = self.__pkg.returnFileEntries()
|
||||
else: # YumInstalledPackage, get files from rpm header.
|
||||
files = []
|
||||
fn = self.__pkg.hdr['basenames']
|
||||
dn = self.__pkg.hdr['dirnames']
|
||||
for d, n in zip( dn, fn ):
|
||||
files.append( d+n )
|
||||
return files
|
||||
|
||||
def get_fullname( self ):
|
||||
""" return fullpackage name in format : <epoch>:<name>-<ver>.<arch>"""
|
||||
fe = self.ver.find( ":" )
|
||||
if fe > -1:
|
||||
epoch = self.ver[0:fe]
|
||||
ver = self.ver[fe+1:]
|
||||
add = "%s:%s-%s.%s" % ( epoch, self.name, ver, self.arch )
|
||||
else:
|
||||
add = "%s:%s-%s.%s" % ( '0', self.name, self.ver, self.arch )
|
||||
return add
|
||||
|
||||
pkgtup = property(fget=getTup)
|
||||
+27
-22
@@ -114,7 +114,7 @@ class YumexPackageInfo:
|
||||
print msg
|
||||
|
||||
class ProgressTotal:
|
||||
def __init__( self, widget ):
|
||||
def __init__( self, widget ):
|
||||
self.progress = widget
|
||||
self.steps = []
|
||||
self.nowProgres = 0.0
|
||||
@@ -123,7 +123,7 @@ class ProgressTotal:
|
||||
self.stepError = False
|
||||
self.lastFrac = -1
|
||||
self.clear()
|
||||
|
||||
|
||||
def setup( self, steps ):
|
||||
self.steps = steps
|
||||
self.numSteps=len( steps )
|
||||
@@ -132,6 +132,12 @@ class ProgressTotal:
|
||||
self.stepError = False
|
||||
self.clear()
|
||||
|
||||
def hide( self ):
|
||||
self.progress.hide()
|
||||
|
||||
def show( self ):
|
||||
self.progress.show()
|
||||
|
||||
def next( self ):
|
||||
now = 0.0
|
||||
if self.currentStep < self.numSteps:
|
||||
@@ -150,12 +156,12 @@ class ProgressTotal:
|
||||
else:
|
||||
percent = ( now*100L )/total
|
||||
return percent
|
||||
|
||||
|
||||
def clear( self ):
|
||||
self.progress.set_fraction( 0 )
|
||||
self.progress.set_text( " " )
|
||||
self.lastFrac = -1
|
||||
|
||||
|
||||
def setProgress( self, now, total, prefix=None ):
|
||||
relStep = float( now )/float( total )
|
||||
if self.currentStep < self.numSteps:
|
||||
@@ -178,7 +184,7 @@ class ProgressTotal:
|
||||
print "=" * 60
|
||||
self.stepError = True # Only dump vars first time.
|
||||
return False
|
||||
|
||||
|
||||
def setAbsProgress( self, now, prefix=None ):
|
||||
if not now >= self.lastFrac and now < 1:
|
||||
return
|
||||
@@ -192,7 +198,7 @@ class ProgressTotal:
|
||||
else:
|
||||
text = "%3i%%" % procent
|
||||
self.progress.set_text( text )
|
||||
|
||||
|
||||
class YumexProgress:
|
||||
""" Progress Class """
|
||||
def __init__( self, ui, set_page_func,parent ):
|
||||
@@ -207,12 +213,12 @@ class YumexProgress:
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
self.ui.progressBar.set_text( " " )
|
||||
self.lastFrac = -1
|
||||
|
||||
|
||||
def show( self ):
|
||||
self.ui.progressBox.show()
|
||||
self.set_page_func( 'output' )
|
||||
self.lastFrac = -1
|
||||
|
||||
|
||||
def hide( self, clean=False ):
|
||||
self.ui.progressBox.hide()
|
||||
if clean:
|
||||
@@ -221,7 +227,7 @@ class YumexProgress:
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
self.ui.progressBar.set_text( " " )
|
||||
|
||||
|
||||
def setTotal( self, now, total ):
|
||||
self.total.setProgress( now, total )
|
||||
|
||||
@@ -233,7 +239,7 @@ class YumexProgress:
|
||||
return
|
||||
while gtk.events_pending(): # process gtk events
|
||||
gtk.main_iteration()
|
||||
|
||||
|
||||
self.lastFrac = frac + 0.01
|
||||
if frac >= 0 and frac <= 1:
|
||||
self.ui.progressBar.set_fraction( frac )
|
||||
@@ -245,13 +251,13 @@ class YumexProgress:
|
||||
if self.parent.skipMirrorNow:
|
||||
self.parent.skipMirrorNow = False
|
||||
self.parent.yumbase._interrupt_callback(None)
|
||||
|
||||
|
||||
|
||||
|
||||
def set_mainLabel( self, text ):
|
||||
self.ui.progressMainLabel.set_markup( "<span size=\"large\"><b>%s</b></span>" % text )
|
||||
self.ui.progressSubLabel.set_text( "" )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
|
||||
|
||||
def set_subLabel( self, text ):
|
||||
self.ui.progressSubLabel.set_markup( "%s" % text )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
@@ -260,7 +266,7 @@ class YumexProgress:
|
||||
self.ui.progressExtraLabel.set_markup( "<span size=\"small\">%s</span>" % cleanMarkupSting(text) )
|
||||
self.lastFrac = -1
|
||||
|
||||
|
||||
|
||||
class YumexGUI:
|
||||
''' This class contains GUI related methods '''
|
||||
def __init__(self):
|
||||
@@ -269,7 +275,7 @@ class YumexGUI:
|
||||
# Package & Queue Views
|
||||
self.queue = YumexQueue()
|
||||
self.queueView = YumexQueueView(self.ui.queueView,self.queue)
|
||||
self.pkgView = EntropyPackageView(self.ui.viewPkg,self.queueView)
|
||||
self.pkgView = EntropyPackageView(self.ui.viewPkg,self.queueView)
|
||||
self.compsView = YumexCompsView(self.ui.tvComps,self.queueView)
|
||||
self.grpPackages = EntropyPackageView(self.ui.tvGrpPackages,self.queueView)
|
||||
self.grpDesc = TextViewConsole(self.ui.grpDesc)
|
||||
@@ -296,14 +302,14 @@ class YumexGUI:
|
||||
self.setupPageButtons() # Setup left side toolbar
|
||||
self.setPage(self.activePage)
|
||||
self.setupPkgFilter()
|
||||
|
||||
|
||||
def loggerSetup(self,logroot,loglvl=None):
|
||||
logger = logging.getLogger(logroot)
|
||||
if loglvl:
|
||||
logger.setLevel(loglvl)
|
||||
logger.addHandler(self.logHandler)
|
||||
return logger
|
||||
|
||||
|
||||
def setupPkgFilter(self):
|
||||
''' set callbacks for package radio buttons (all,updates, ...)'''
|
||||
self.setupPkgRadio(self.ui.rbAll,"all",_('Show All Packages'))
|
||||
@@ -325,7 +331,7 @@ class YumexGUI:
|
||||
self.createButton( _( "Repository Selection View" ), "button-repo.png", 'repos' )
|
||||
self.createButton( _( "Output View" ), "button-output.png", 'output' )
|
||||
style = self.ui.leftEvent.get_style()
|
||||
|
||||
|
||||
# Set the background of the horisontal buttonbar to the same as the views.
|
||||
# To make it look good on other than default gtk themes.
|
||||
style = self.ui.viewOutput.get_style()
|
||||
@@ -369,8 +375,8 @@ class YumexGUI:
|
||||
|
||||
def setNotebookPage(self,page):
|
||||
''' Switch to Page in GUI'''
|
||||
self.ui.notebook.set_current_page(page)
|
||||
|
||||
self.ui.notebook.set_current_page(page)
|
||||
|
||||
def setStatus( self, text ):
|
||||
''' Write Message to Statusbar'''
|
||||
context_id = self.ui.status.get_context_id( "Status" )
|
||||
@@ -404,7 +410,7 @@ class YumexGUI:
|
||||
self.pkgFiles.goTop()
|
||||
self.pkgChangeLog.goTop()
|
||||
self.pkgOther.goTop()
|
||||
|
||||
|
||||
def enableSkipMirror(self):
|
||||
self.ui.skipMirror.show()
|
||||
self.skipMirror = True
|
||||
@@ -412,4 +418,3 @@ class YumexGUI:
|
||||
def disableSkipMirror(self):
|
||||
self.ui.skipMirror.hide()
|
||||
self.skipMirror = False
|
||||
|
||||
+24
-17
@@ -18,6 +18,7 @@
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
from etpgui.packages import PackageWrapper
|
||||
import exceptionTools
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -32,22 +33,22 @@ color_install = 'darkgreen'
|
||||
color_update = 'blue'
|
||||
color_obsolete = 'red'
|
||||
|
||||
class YumexPackage( PackageWrapper ):
|
||||
class EntropyPackage( PackageWrapper ):
|
||||
""" This class contains a yumPackage and some extra features used by
|
||||
yumex """
|
||||
|
||||
def __init__( self, pkg, recentlimit, avail=True ):
|
||||
|
||||
def __init__( self, matched_atom, recentlimit, avail=True ):
|
||||
global color_normal
|
||||
PackageWrapper.__init__( self, pkg, avail )
|
||||
PackageWrapper.__init__( self, matched_atom, avail )
|
||||
self.selected = False
|
||||
self.visible = True
|
||||
self.queued = None
|
||||
self.queued = None
|
||||
self.action = None
|
||||
self.obsolete = False
|
||||
self.obsolete_tup = None
|
||||
self.color = color_normal
|
||||
self.time = self._get_time()
|
||||
if self.time > recentlimit:
|
||||
if float(self.time) > float(recentlimit):
|
||||
self.recent = True
|
||||
else:
|
||||
self.recent = False
|
||||
@@ -59,20 +60,26 @@ class YumexPackage( PackageWrapper ):
|
||||
self.visible = state
|
||||
|
||||
|
||||
|
||||
|
||||
class EntropyPackages:
|
||||
def __init__(self):
|
||||
def __init__(self, EquoInstance):
|
||||
self.Entropy = EquoInstance
|
||||
try:
|
||||
self.Entropy.instanceTest()
|
||||
except:
|
||||
raise exceptionTools.IncorrectParameter("IncorrectParameter: a valid Entropy Instance is needed")
|
||||
self.logger = logging.getLogger('yumex.Packages')
|
||||
self.filterCallback = None
|
||||
self._packages = {}
|
||||
self.currentCategory = None
|
||||
self._categoryPackages = {}
|
||||
self.pkgInGrps = PkgInGroupList()
|
||||
|
||||
self.recent = self.Entropy.entropyTools.getCurrentUnixTime()
|
||||
|
||||
|
||||
def clearPackages(self):
|
||||
self._packages = {}
|
||||
|
||||
|
||||
def populatePackages(self,masks):
|
||||
for flt in masks:
|
||||
if self._packages.has_key(flt):
|
||||
@@ -84,7 +91,7 @@ class EntropyPackages:
|
||||
|
||||
def setCategoryPackages(self,pkgdict = {}):
|
||||
self._categoryPackages = pkgdict
|
||||
|
||||
|
||||
def getPackagesByCategory(self,cat=None):
|
||||
if not cat:
|
||||
cat = self.currentCategory
|
||||
@@ -103,7 +110,7 @@ class EntropyPackages:
|
||||
|
||||
def getAvailable(self):
|
||||
if not self._packages.has_key('updates'):
|
||||
self.populatePackages('updates')
|
||||
self.populatePackages(['updates'])
|
||||
polist = []
|
||||
updlist = []
|
||||
for po in self._packages['updates']:
|
||||
@@ -164,8 +171,8 @@ class EntropyPackages:
|
||||
def _getPackages(self,mask):
|
||||
global color_install,color_update,color_obsolete
|
||||
if mask == 'installed':
|
||||
for po in self.rpmdb:
|
||||
yp = YumexPackage(po,self.recent,False)
|
||||
for idpackage in self.Entropy.clientDbconn.listAllIdpackages():
|
||||
yp = EntropyPackage((idpackage,0), self.recent, False)
|
||||
yp.selected = True
|
||||
yp.action = 'r'
|
||||
yp.color = color_install
|
||||
@@ -174,7 +181,7 @@ class EntropyPackages:
|
||||
# Get the rest of the available packages.
|
||||
for po in self.pkgSack.returnNewestByNameArch():
|
||||
if not self.isInst(po.name):
|
||||
yp = YumexPackage(po,self.recent,True)
|
||||
yp = EntropyPackage(po,self.recent,True)
|
||||
yp.action = 'i'
|
||||
yield yp
|
||||
elif mask == 'updates':
|
||||
@@ -183,7 +190,7 @@ class EntropyPackages:
|
||||
for ( obsoleting, installed ) in obsoletes:
|
||||
obsoleting_pkg = self.getPackageObject( obsoleting )
|
||||
installed_pkg = self.rpmdb.searchPkgTuple( installed )[0]
|
||||
yp = YumexPackage(obsoleting_pkg,self.recent,True)
|
||||
yp = EntropyPackage(obsoleting_pkg,self.recent,True)
|
||||
yp.action = 'u'
|
||||
yp.obsolete = True
|
||||
yp.obsolete_tup = installed_pkg.pkgtup
|
||||
@@ -197,7 +204,7 @@ class EntropyPackages:
|
||||
matches = self.pkgSack.searchNevra( name=n, arch=a, epoch=e,
|
||||
ver=v, rel=r )
|
||||
if len( matches ) > 0:
|
||||
yp = YumexPackage(matches[0],self.recent,True)
|
||||
yp = EntropyPackage(matches[0],self.recent,True)
|
||||
yp.action = 'u'
|
||||
yp.color = color_update
|
||||
yield yp
|
||||
|
||||
+30
-24
@@ -39,21 +39,23 @@ import exceptions
|
||||
from etpgui.widgets import UI, Controller
|
||||
from etpgui import *
|
||||
|
||||
|
||||
# yumex imports
|
||||
import filters
|
||||
from entropyapi import Equo
|
||||
from entropyapi import EquoConnection
|
||||
from gui import YumexGUI
|
||||
from dialogs import *
|
||||
from misc import const, YumexOptions, YumexProfile
|
||||
from i18n import _
|
||||
import time
|
||||
|
||||
|
||||
|
||||
class YumexController(Controller):
|
||||
''' This class contains all glade signal callbacks '''
|
||||
|
||||
|
||||
|
||||
|
||||
def __init__( self ):
|
||||
self.etpbase = EntropyPackages()
|
||||
self.etpbase = EntropyPackages(EquoConnection)
|
||||
# Create and ui object contains the widgets.
|
||||
ui = UI( const.GLADE_FILE , 'main', 'yumex' )
|
||||
# init the Controller Class to connect signals.
|
||||
@@ -141,7 +143,7 @@ class YumexController(Controller):
|
||||
repos = self.repoView.get_selected()
|
||||
self.setPage('output')
|
||||
self.logger.info( "Cleaning cache")
|
||||
self.cleanEntropyCaches()
|
||||
self.cleanEntropyCaches(alone = True)
|
||||
|
||||
def on_repoDeSelect_clicked(self,widget):
|
||||
self.repoView.deselect_all()
|
||||
@@ -312,10 +314,10 @@ class YumexController(Controller):
|
||||
flt.activate(False)
|
||||
action = self.lastPkgPB
|
||||
rb = self.packageRB[action]
|
||||
self.on_pkgFilter_toggled(rb,action)
|
||||
|
||||
|
||||
def on_schArchText_activate(self,entry):
|
||||
self.on_pkgFilter_toggled(rb,action)
|
||||
|
||||
|
||||
def on_schArchText_activate(self,entry):
|
||||
''' Search Arch Entry handler'''
|
||||
txt = entry.get_text()
|
||||
flt = filters.yumexFilter.get('ArchFilter')
|
||||
@@ -346,9 +348,9 @@ class YumexController(Controller):
|
||||
pkg = model.get_value( iterator, 0 )
|
||||
if pkg:
|
||||
self.grpDesc.clear()
|
||||
self.grpDesc.write_line(pkg.description)
|
||||
|
||||
|
||||
self.grpDesc.write_line(pkg.description)
|
||||
|
||||
|
||||
# Menu Handlers
|
||||
|
||||
def on_profile( self, data ):
|
||||
@@ -360,25 +362,25 @@ class YumexController(Controller):
|
||||
|
||||
def on_FileQuit( self, widget ):
|
||||
self.quit()
|
||||
|
||||
|
||||
def on_EditPreferences( self, widget ):
|
||||
Preferences()
|
||||
self.yumexOptions.reload()
|
||||
self.settings = self.yumexOptions.settings
|
||||
|
||||
|
||||
def on_HelpAbout( self, widget ):
|
||||
about = AboutDialog(const.PIXMAPS_PATH+'/spritz-about.png',const.CREDITS,self.settings.branding_title)
|
||||
about.show()
|
||||
|
||||
|
||||
def on_ProfileSave( self, widget ):
|
||||
repos = self.repoView.get_selected()
|
||||
if self.profile.writeProfile(repos):
|
||||
self.setStatus( _( "Profile : %s saved ok" ) % self.profile.getActive() )
|
||||
else:
|
||||
self.setStatus( _( "Profile : %s save failed" ) % self.profile.getActive() )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def on_ProfileNew( self, widget ):
|
||||
name = inputBox(self.ui.main,_("Create New Profile"),_("Name of new profile"))
|
||||
if name:
|
||||
@@ -414,7 +416,7 @@ class YumexApplication(YumexController,YumexGUI):
|
||||
self.logger.info(_('Yum Config Setup'))
|
||||
self.yumexOptions.parseCmdOptions()
|
||||
#self.lastPkgPB = "updates"
|
||||
|
||||
|
||||
# Setup GUI
|
||||
self.setupGUI()
|
||||
self.logger.info(_('GUI Setup Completed'))
|
||||
@@ -424,7 +426,7 @@ class YumexApplication(YumexController,YumexGUI):
|
||||
self.firstTime = True
|
||||
#self.addPackages()
|
||||
self.setPage('repos')
|
||||
self.Equo = Equo()
|
||||
self.Equo = EquoConnection
|
||||
self.Equo.connect_to_gui(self.progress, self.progressLogWrite)
|
||||
|
||||
def startWorking(self):
|
||||
@@ -438,10 +440,14 @@ class YumexApplication(YumexController,YumexGUI):
|
||||
self.ui.progressVBox.grab_remove()
|
||||
normalCursor(self.ui.main)
|
||||
gtkEventThread.endProcessing()
|
||||
|
||||
def cleanEntropyCaches(self):
|
||||
|
||||
def cleanEntropyCaches(self, alone = False):
|
||||
if alone:
|
||||
self.progress.total.hide()
|
||||
self.Equo.generate_cache(depcache = True, configcache = False)
|
||||
|
||||
if alone:
|
||||
self.progress.total.show()
|
||||
|
||||
def updateRepositories(self, repos):
|
||||
self.setPage('output')
|
||||
self.startWorking()
|
||||
|
||||
+20
-21
@@ -101,7 +101,7 @@ class EntropyPackageView:
|
||||
self.view.set_reorderable( False )
|
||||
return store
|
||||
|
||||
def create_text_column( self, hdr, property, size,sortcol = None):
|
||||
def create_text_column( self, hdr, property, size, sortcol = None):
|
||||
"""
|
||||
Create a TreeViewColumn with text and set
|
||||
the sorting properties and add it to the view
|
||||
@@ -116,7 +116,7 @@ class EntropyPackageView:
|
||||
self.view.append_column( column )
|
||||
return column
|
||||
|
||||
def get_data_text( self, column, cell, model, iter,property ):
|
||||
def get_data_text( self, column, cell, model, iter, property ):
|
||||
obj = model.get_value( iter, 0 )
|
||||
if obj:
|
||||
cell.set_property( 'text', getattr( obj, property ) )
|
||||
@@ -127,24 +127,24 @@ class EntropyPackageView:
|
||||
cell.set_property( "visible", True )
|
||||
if obj:
|
||||
cell.set_property( "active", getattr( obj, property ) )
|
||||
|
||||
|
||||
def on_toggled( self, widget, path ):
|
||||
""" Package selection handler """
|
||||
iter = self.store.get_iter( path )
|
||||
obj = self.store.get_value( iter, 0 )
|
||||
self.togglePackage(obj)
|
||||
self.queueView.refresh()
|
||||
|
||||
|
||||
def togglePackage(self,obj):
|
||||
if obj.queued == obj.action:
|
||||
obj.queued = None
|
||||
self.queue.remove(obj)
|
||||
else:
|
||||
obj.queued = obj.action
|
||||
self.queue.add(obj)
|
||||
obj.queued = obj.action
|
||||
self.queue.add(obj)
|
||||
obj.set_select( not obj.selected )
|
||||
|
||||
|
||||
|
||||
|
||||
def selectAll(self):
|
||||
for el in self.store:
|
||||
obj = el[0]
|
||||
@@ -185,7 +185,6 @@ class EntropyPackageView:
|
||||
cell.set_property( 'icon-name', 'document-new' )
|
||||
else:
|
||||
cell.set_property( 'visible', False )
|
||||
|
||||
|
||||
def get_selected( self, package=True ):
|
||||
""" Get selected packages in current packageList """
|
||||
@@ -198,7 +197,7 @@ class EntropyPackageView:
|
||||
selected.append( pkg )
|
||||
return selected
|
||||
|
||||
|
||||
|
||||
class YumexQueueView:
|
||||
""" Queue View Class"""
|
||||
def __init__( self, widget,queue ):
|
||||
@@ -270,8 +269,8 @@ class YumexQueueView:
|
||||
def populate_list( self, label, list ):
|
||||
parent = self.model.append( None, [label, ""] )
|
||||
for pkg in list:
|
||||
self.model.append( parent, [str( pkg ), pkg.summaryFirst] )
|
||||
|
||||
self.model.append( parent, [str( pkg ), pkg.atom] )
|
||||
|
||||
|
||||
class YumexCompsView:
|
||||
def __init__( self, treeview,qview):
|
||||
@@ -289,8 +288,8 @@ class YumexCompsView:
|
||||
model = gtk.TreeStore(gobject.TYPE_BOOLEAN, # Installed
|
||||
gobject.TYPE_STRING, # Group Name
|
||||
gobject.TYPE_STRING, # Group Id
|
||||
gobject.TYPE_BOOLEAN, # In queue
|
||||
gobject.TYPE_BOOLEAN) # isCategory
|
||||
gobject.TYPE_BOOLEAN, # In queue
|
||||
gobject.TYPE_BOOLEAN) # isCategory
|
||||
|
||||
|
||||
self.view.set_model( model )
|
||||
@@ -300,7 +299,7 @@ class YumexCompsView:
|
||||
selection.set_property( 'activatable', True )
|
||||
column.pack_start(selection, False)
|
||||
column.set_cell_data_func( selection, self.setCheckbox )
|
||||
selection.connect( "toggled", self.on_toggled )
|
||||
selection.connect( "toggled", self.on_toggled )
|
||||
self.view.append_column( column )
|
||||
|
||||
column = gtk.TreeViewColumn(None, None)
|
||||
@@ -438,18 +437,18 @@ class YumexRepoView:
|
||||
self.view = widget
|
||||
self.headers = [_('Repository'),_('Filename')]
|
||||
self.store = self.setup_view()
|
||||
|
||||
|
||||
def on_toggled( self, widget, path):
|
||||
""" Repo select/unselect handler """
|
||||
iter = self.store.get_iter( path )
|
||||
state = self.store.get_value(iter,0)
|
||||
self.store.set_value(iter,0, not state)
|
||||
|
||||
|
||||
def setup_view( self ):
|
||||
""" Create models and columns for the Repo TextView """
|
||||
store = gtk.ListStore( 'gboolean', gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
self.view.set_model( store )
|
||||
|
||||
|
||||
# Setup Selection Column
|
||||
cell1 = gtk.CellRendererToggle() # Selection
|
||||
cell1.set_property( 'activatable', True )
|
||||
@@ -459,17 +458,17 @@ class YumexRepoView:
|
||||
column1.set_sort_column_id( -1 )
|
||||
self.view.append_column( column1 )
|
||||
cell1.connect( "toggled", self.on_toggled )
|
||||
|
||||
|
||||
# Setup revision column
|
||||
self.create_text_column( _('Revision'),1 )
|
||||
|
||||
|
||||
# Setup reponame & repofile column's
|
||||
self.create_text_column( _('Repository Identifier'),2 )
|
||||
self.create_text_column( _('Description'),3 )
|
||||
self.view.set_search_column( 1 )
|
||||
self.view.set_reorderable( False )
|
||||
return store
|
||||
|
||||
|
||||
def create_text_column( self, hdr,colno):
|
||||
cell = gtk.CellRendererText() # Size Column
|
||||
column = gtk.TreeViewColumn( hdr, cell, text=colno )
|
||||
|
||||
Reference in New Issue
Block a user