def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.disablepercent = False self.dostep = True
def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.progress.set_steps([ 2,5,7,8,90,100 ] )
class GetUpdateCallback(callbacks.UpdateCallback): def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.progress.set_steps([1,50, 100 ] ) def preparingChangeSet(self): log.info("Callback getUpdates ......... preparingChangeset") def sendingChangeset(self, got,need): log.info("Callback getUpdates:sendingChangeset. %s percent of %.2f/%.2f bytes" % ( int( got*100/float(need)), got/MEGA,need/MEGA) ) def requestingChangeSet(self): log.info("Callback getUpdates:requestingChangeSet ........ STATUS_REQUEST changeset ") self.backend.status(STATUS_REQUEST) self.backend.percentage(self.progress.percent) self.progress.step() def downloadingChangeSet(self, got, need): log.info("Callback getUpdates:downloadingChangeSet Changeset %s percent of %.2f/%.2f bytes" % ( int( got*100/float(need)), got/MEGA,need/MEGA) ) self.backend.status(STATUS_DOWNLOAD) self.progress.set_subpercent( got*100 / float(need) ) self.backend.percentage( self.progress.percent ) log.info( "%s percent" % self.progress.percent) def requestingFileContents(self): log.info("callBack getUpdates requestingFileContents") def downloadingFileContents(self,got,need): log.info("Callback getUpdates:downloadingFileContents %s percent of %.2f/%.2f bytes" % ( int( got*100/float(need)), got/MEGA,need/MEGA) ) def setChangesetHunk(self, hunk, hunkCount): """ Called when creating changesets, such as when downloading changesets. @param hunk: the number of the changeset being created (starts at 1) @type hunk: integer @param hunkCount: total number of changesets to be created. @type hunkCount: integer @return: None """ log.info("Callback getUpdates:setChangesetHunk %s percent of %.2f/%.2f bytes" % ( int( hunk*100/float(hunkCount)), hunk/MEGA,hunkCount/MEGA) ) # 3 def resolvingDependencies(self): # self.backend.status(STATUS_DEP_RESOLVE) # self.progress.step() log.info("Callback getUpdates:resolvingDependencies ...... STATUS_DEP_RESOLVE ") # self.backend.percentage(self.progress.percent) def done(self): self.log("Callback getUpdates:DONE()>>>>>") ## update callback def preparingUpdate(self,troveNum,troveCount): log.info("Callback getUpdates:preparingUpdate %s percent of %.2f/%.2f bytes" % ( int( hunk*100/float(hunkCount)), hunk/MEGA,hunkCount/MEGA) )
def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.progress.set_steps([ 1, # requestingChangeSet 1 50, # resolveDeps2 51, # SetChangesetHunk3 52, # requestingChangeSet4 80,# setUpdateHUnk5 81,# setUpdateJob6 ] )
class BasePKConaryCallback(callbacks.UpdateCallback): def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.disablepercent = False self.dostep = True def requestingChangeSet(self): self.backend.status(STATUS_REQUEST) log.info("[STATUS_REQUEST] Requesting ChangeSet") def downloadingChangeSet(self, got, need): self.backend.status(STATUS_DOWNLOAD) log.info("[STATUS_DOWNLOAD] Downloading ChangeSet (%.2f%% %.2f out of %.2f MiB)" \ % ( got*100/float(need), got/MEGA,need/MEGA) ) self.progress.set_subpercent(got * 100 / float(need)) self.backend.percentage(self.progress.percent) if got >= need: self.dostep = True def resolvingDependencies(self): self.backend.status(STATUS_DEP_RESOLVE) log.info("[STATUS_DEP_RESOLVE] Resolving Dependencies") self.backend.percentage(self.progress.percent) def setChangesetHunk(self, num, total): log.info("Changeset Hunk %d out of %d" % (num, total)) if total > 0: p = num * 100 / float(total) else: p = 0 self.progress.set_subpercent(p) self.disablepercent = True self.backend.percentage(self.progress.percent) if num == total: self.dostep = True def setUpdateHunk(self, num, total): log.info("Update Hunk %d out of %d" % (num, total)) if self.dostep: self.disablepercent = True self.dostep = False if num < total: p = num * 100 / float(total) self.progress.set_subpercent(p) else: self.smallUpdate = True self.backend.percentage(self.progress.percent) def setUpdateJob(self, job): self.currentJob = job self.backend.percentage(self.progress.percent) log.info("callback UpdateSystem. setUpdateJob") log.info(self.progress.percent) def creatingRollback(self): # Don't do anything unless we actually rollback pass def preparingUpdate(self, troveNum, troveCount): def _get_package_id(name, v, f): version = str(v.trailingRevision()) label = str(v.trailingLabel()) arch = conarypk.get_arch(f) package_id = get_package_id(name, version, arch, label) return package_id if not self.currentJob or len( self.currentJob) == 0 or troveNum > troveCount: return self.backend.percentage(self.progress.percent) job = self.currentJob[troveNum - 1] name, (oldVersion, oldFlavor), (newVersion, newFlavor) = job[:3] if oldVersion and newVersion: package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Update %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_UPDATE) self.backend.package(package_id, INFO_UPDATING, '') elif oldVersion and not newVersion: package_id = _get_package_id(name, oldVersion, oldFlavor) log.info("Preparing Remove %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_REMOVE) self.backend.package(package_id, INFO_REMOVING, '') elif not oldVersion and newVersion: package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Install %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_INSTALL) self.backend.package(package_id, INFO_INSTALLING, '') def creatingDatabaseTransaction(self, troveNum, troveCount): log.info("Creating Database Transaction %d out of %d" % (troveNum, troveCount)) self.backend.percentage(self.progress.percent) log.info(self.progress.percent) def committingTransaction(self): log.info('[STATUS_COMMIT] Committing Transaction') self.backend.status(STATUS_COMMIT) self.backend.percentage(self.progress.percent) def updateDone(self): log.info("Update Done") self.backend.percentage(self.progress.percent) self.currentJob = None log.info(self.progress.percent) def downloadingFileContents(self, got, need): log.info("[STATUS_DOWNLOAD] Downloading File Contents (%.2f%% %.2f out of %.2f MiB)" \ % ( got*100/float(need), got/MEGA,need/MEGA) ) self.backend.status(STATUS_DOWNLOAD) #self.backend.sub_percentage(got*100/need) def requestingFileContents(self): log.info("[STATUS_REQUEST] Requesting File Contents") self.backend.status(STATUS_REQUEST) def removeFiles(self, filenum, total): log.info("[STATUS_REMOVE] %s out of %s file(s)" % (filenum, total)) self.backend.status(STATUS_REMOVE) def done(self): log.info("Done.") def warning(self, msg, *args, **kwargs): e = msg % args log.warning(e) def tagHandlerOutput(self, tag, msg, stderr=False): log.info("Tag Handler Output: [%s] %s" % (tag, msg)) def troveScriptOutput(self, typ, msg): log.info("Trove Script Output [%s] %s" % (typ, msg))
class BasePKConaryCallback(callbacks.UpdateCallback): def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.disablepercent = False self.dostep = True def requestingChangeSet(self): self.backend.status(STATUS_REQUEST) log.info("[STATUS_REQUEST] Requesting ChangeSet") def downloadingChangeSet(self, got, need): self.backend.status(STATUS_DOWNLOAD) log.info("[STATUS_DOWNLOAD] Downloading ChangeSet (%.2f%% %.2f out of %.2f MiB)" \ % ( got*100/float(need), got/MEGA,need/MEGA) ) self.progress.set_subpercent( got*100 / float(need) ) self.backend.percentage( self.progress.percent ) if got >= need: self.dostep = True def resolvingDependencies(self): self.backend.status(STATUS_DEP_RESOLVE) log.info("[STATUS_DEP_RESOLVE] Resolving Dependencies") self.backend.percentage(self.progress.percent) def setChangesetHunk(self, num, total): log.info("Changeset Hunk %d out of %d" % (num, total) ) if total > 0: p = num*100/float(total) else: p = 0 self.progress.set_subpercent(p) self.disablepercent = True self.backend.percentage(self.progress.percent) if num == total: self.dostep = True def setUpdateHunk(self, num, total): log.info("Update Hunk %d out of %d" % (num, total ) ) if self.dostep: self.disablepercent = True self.dostep = False if num < total: p = num*100/float(total) self.progress.set_subpercent(p) else: self.smallUpdate = True self.backend.percentage(self.progress.percent) def setUpdateJob(self, job): self.currentJob = job self.backend.percentage(self.progress.percent) log.info("callback UpdateSystem. setUpdateJob") log.info(self.progress.percent) def creatingRollback(self): # Don't do anything unless we actually rollback pass def preparingUpdate(self, troveNum, troveCount): def _get_package_id(name, v, f): version = str(v.trailingRevision()) label = str(v.trailingLabel()) arch = conarypk.get_arch(f) package_id = get_package_id(name, version, arch, label) return package_id if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount: return self.backend.percentage(self.progress.percent) job = self.currentJob[troveNum-1] name, (oldVersion, oldFlavor), (newVersion, newFlavor) = job[:3] if oldVersion and newVersion: package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Update %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_UPDATE) self.backend.package(package_id, INFO_UPDATING, '') elif oldVersion and not newVersion: package_id = _get_package_id(name, oldVersion, oldFlavor) log.info("Preparing Remove %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_REMOVE) self.backend.package(package_id, INFO_REMOVING, '') elif not oldVersion and newVersion: package_id = _get_package_id(name, newVersion, newFlavor) log.info("Preparing Install %d out of %d: %s" % (troveNum, troveCount, package_id)) self.backend.status(STATUS_INSTALL) self.backend.package(package_id, INFO_INSTALLING, '') def creatingDatabaseTransaction(self, troveNum, troveCount): log.info("Creating Database Transaction %d out of %d" % (troveNum, troveCount)) self.backend.percentage(self.progress.percent) log.info(self.progress.percent) def committingTransaction(self): log.info('[STATUS_COMMIT] Committing Transaction') self.backend.status(STATUS_COMMIT) self.backend.percentage(self.progress.percent) def updateDone(self): log.info("Update Done") self.backend.percentage(self.progress.percent) self.currentJob = None log.info(self.progress.percent) def downloadingFileContents(self, got, need): log.info("[STATUS_DOWNLOAD] Downloading File Contents (%.2f%% %.2f out of %.2f MiB)" \ % ( got*100/float(need), got/MEGA,need/MEGA) ) self.backend.status(STATUS_DOWNLOAD) #self.backend.sub_percentage(got*100/need) def requestingFileContents(self): log.info("[STATUS_REQUEST] Requesting File Contents") self.backend.status(STATUS_REQUEST) def removeFiles(self, filenum, total): log.info("[STATUS_REMOVE] %s out of %s file(s)" %( filenum, total) ) self.backend.status(STATUS_REMOVE) def done(self): log.info("Done.") def warning(self, msg, *args, **kwargs): e = msg %args log.warning(e) def tagHandlerOutput(self, tag, msg, stderr = False): log.info("Tag Handler Output: [%s] %s" % (tag, msg)) def troveScriptOutput(self, typ, msg): log.info("Trove Script Output [%s] %s" % (typ, msg))
class RemoveCallback(callbacks.UpdateCallback): def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.progress.set_steps([ 2,5,7,8,90,100 ] ) # 1 def resolvingDependencies(self): #self.backend.status('Resolving Dependencies') log.info("Callback ........ STATUS_DEP_RESOLVE ") self.backend.percentage(self.progress.percent) self.backend.status(STATUS_DEP_RESOLVE) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #2 def setChangesetHunk(self, num, total): log.info("callback. .......... set Changeset HUnk %s/%s" % (num, total ) ) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #3 def setUpdateHunk(self, hunk, hunkCount): log.info("callback. .......... set update HUnk %s/%s" % ( hunk, hunkCount)) if hunk < hunkCount: p = hunk / float(hunkCount) * 100.0 self.progress.set_subpercent(p) else: self.smallUpdate = True self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #4 def setUpdateJob(self, job): log.info("callback. .......... set update Job") self.currentJob = job self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #5 def creatingRollback(self): #self.backend.status('Creating Rollback') log.info("Callback ........ STATUS_ROLLBACK ") self.backend.status(STATUS_ROLLBACK) self.progress.step() #self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #6 def removeFiles(self, filenum, total): log.info("Callback ........ STATUS_REMOVE %s percent %s/%s files" %(filenum*100/float(total), filenum, total) ) self.progress.set_subpercent( filenum*100/float(total) ) self.backend.percentage(self.progress.percent) log.info(self.progress.percent) self.backend.status(STATUS_REMOVE) self.preparingUpdate(filenum, total, add=total) def preparingUpdate(self, troveNum, troveCount, add=0): log.info("callback ....... preparing Update trove %s/%s" % (troveNum, troveCount) ) #self.progress.step() if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount: return log.info("currentJob %s" % troveNum) log.info("job %s" % self.currentJob) if len(self.currentJob) > troveNum: job = self.currentJob[troveNum] else: return name = job[0] oldVersion, oldFlavor = job[1] newVersion, newFlavor = job[2] #log.info("JOB>>>>>>>> %s " % str(job) ) if oldVersion and newVersion: log.info("Callback ........ STATUS_UPDATE preparing Update ") self.backend.status(STATUS_UPDATE) package_id = self.backend.get_package_id(name, newVersion, newFlavor) self.backend.package(package_id, INFO_UPDATING, '') elif oldVersion and not newVersion: log.info("Callback ........ STATUS_REMOVE preparing Update ") self.backend.status(STATUS_REMOVE) package_id = self.backend.get_package_id(name, oldVersion, oldFlavor) self.backend.package(package_id, INFO_REMOVING, '') def creatingDatabaseTransaction(self, troveNum, troveCount): log.info("callback. .......... creating Database Transactions") self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #self.preparingUpdate(troveNum, troveCount, add=troveCount) #8 def committingTransaction(self): #self.backend.status('Committing Transaction') log.info("Callback ........ STATUS_COMMIT transactions ") self.backend.status(STATUS_COMMIT) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #9 def updateDone(self): log.info("callback. .......... update done") self.progress.step() self.backend.percentage(self.progress.percent) self.currentJob = None log.info(self.progress.percent) def done(self): # self.progress.step() log.info("Some Problem ...............>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") def warning(self, msg, *args, **kwargs): e = msg %args self.error.append(e) log.error("<<<<<<<<<<<<<<<<<<<<<<<<<<<<") log.error( args )
class UpdateCallback(callbacks.UpdateCallback): def __init__(self, backend, cfg=None): callbacks.UpdateCallback.__init__(self) log.info("==== callback ==== ") if cfg: self.setTrustThreshold(cfg.trustThreshold) self.backend = backend self.currentJob = None self.smallUpdate = False self.error = [] self.progress = PackagekitProgress() self.progress.set_steps([ 1, # requestingChangeSet 1 50, # resolveDeps2 51, # SetChangesetHunk3 52, # requestingChangeSet4 80,# setUpdateHUnk5 81,# setUpdateJob6 ] ) # 1 >> download # 4 >> download def requestingChangeSet(self): log.info("Callback ........ STATUS_REQUEST changeset ") self.backend.status(STATUS_DOWNLOAD) self.backend.percentage(self.progress.percent) log.info(self.progress.percent) self.progress.step() def downloadingChangeSet(self, got, need): log.info("Callback ........ STATUS_DOWNLOAD Changeset %s percent %.2f/%.2f bytes" % ( got*100/float(need), got/MEGA,need/MEGA) ) self.progress.set_subpercent( got*100 / float(need) ) self.backend.percentage( self.progress.percent ) log.info( "%s percent" % self.progress.percent) # 2 def resolvingDependencies(self): #self.backend.status('Resolving Dependencies') log.info("Callback ........ STATUS_DEP_RESOLVE ") self.backend.percentage(self.progress.percent) self.backend.status(STATUS_DEP_RESOLVE) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) # 3 def setChangesetHunk(self, num, total): log.info("callback. .......... set Changeset HUnk %s/%s" % (num, total ) ) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) # 5 def setUpdateHunk(self, hunk, hunkCount): log.info("callback. .......... set update HUnk %s/%s" % ( hunk, hunkCount)) self.progress.step() if hunk < hunkCount: p = hunk / float(hunkCount) * 100.0 self.progress.set_subpercent(p) else: self.smallUpdate = True self.backend.percentage(self.progress.percent) log.info(self.progress.percent) # 6 def setUpdateJob(self, job): log.info("callback. .......... set update Job") self.currentJob = job self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #7 >> preparing update def creatingRollback(self): #self.backend.status('Creating Rollback') log.info("Callback ........ STATUS_ROLLBACK ") self.backend.status(STATUS_ROLLBACK) self.backend.percentage(self.progress.percent) log.info(self.progress.percent) def preparingUpdate(self, troveNum, troveCount, add=0): log.info("callback ....... preparing Update trove %s/%s" % (troveNum, troveCount) ) #self.progress.step() if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount: return if troveNum > 0 and troveCount > 0: sub_percent = (add + troveNum) / (2 * float(troveCount)) * 100 self.progress.set_subpercent(sub_percent) self.backend.percentage(self.progress.percent) if troveNum > 0: troveNum -= 1 log.info("currentJob") log.info(self.currentJob[troveNum]) job = self.currentJob[troveNum] name = job[0] oldVersion, oldFlavor = job[1] newVersion, newFlavor = job[2] #log.info("JOB>>>>>>>> %s " % str(job) ) if oldVersion and newVersion: log.info("pU.. status Update") self.backend.status(STATUS_UPDATE) package_id = self.backend.get_package_id(name, newVersion, newFlavor) self.backend.package(package_id, INFO_UPDATING, '') elif oldVersion and not newVersion: self.backend.status(STATUS_REMOVE) log.info("pU.. status remove") package_id = self.backend.get_package_id(name, oldVersion, oldFlavor) self.backend.package(package_id, INFO_REMOVING, '') elif not oldVersion and newVersion: #self.backend.status(STATUS_INSTALL) log.info("pU.. status install") package_id = self.backend.get_package_id(name, newVersion, newFlavor) self.backend.package(package_id, INFO_INSTALLING, '') log.info(self.progress.percent) #8 def creatingDatabaseTransaction(self, troveNum, troveCount): log.info("callback. .......... creating Database Transactions") self.backend.percentage(self.progress.percent) log.info(self.progress.percent) self.backend.status(STATUS_COMMIT) # self.preparingUpdate(troveNum, troveCount, add=troveCount) # 9 def committingTransaction(self): #self.backend.status('Committing Transaction') log.info("Callback ........ STATUS_COMMIT transactions ") self.backend.status(STATUS_COMMIT) self.progress.step() self.backend.percentage(self.progress.percent) log.info(self.progress.percent) #10 def updateDone(self): log.info("callback. .......... update done") self.backend.percentage(self.progress.percent) self.currentJob = None log.info(self.progress.percent) def downloadingFileContents(self, got, need): #self.backend.status('Downloading files for changeset') log.info("Callback ........ STATUS_DOWNLOAD FIle Contents %s " % str( got*100/need )) self.backend.status(STATUS_DOWNLOAD) #self.backend.sub_percentage(got*100/need) def requestingFileContents(self): #self.backend.status('Requesting File Contents') log.info("Callback ........ STATUS_REQUEST request File contents ") self.backend.status(STATUS_REQUEST) def removeFiles(self, filenum, total): log.info("Callback ........ STATUS_REMOVE %s/%sfiles" %( filenum, total) ) self.backend.status(STATUS_REMOVE) self.preparingUpdate(filenum, total, add=total) def done(self): #self.backend.status('Done') # self.progress.step() log.info("DONEEEEEEEEEEEE") def warning(self, msg, *args, **kwargs): e = msg %args log.error("<<<<<<<<<<<<<<<<<<<<<<<<<<<<") log.error(e) self.backend.error(ERROR_DEP_RESOLUTION_FAILED, e, False ) def tagHandlerOutput(self, tag, msg, stderr = False): pass def troveScriptOutput(self, typ, msg): pass def troveScriptFailure(self, typ, errcode): pass