packagekit/backends/conary/helpers/conaryCallback.py

113 lines
3.4 KiB
Python
Raw Normal View History

2007-09-20 21:00:34 -07:00
#
# Copyright (c) 2007 Elliot Peele <elliot@bentlogic.net>
#
# Licensed under the GNU General Public License Version 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
from conary import callbacks
2007-10-09 12:18:42 -07:00
from packagekit.backend import *
2007-09-20 21:00:34 -07:00
class UpdateCallback(callbacks.UpdateCallback):
2007-09-20 21:00:34 -07:00
def resolvingDependencies(self):
#self.backend.status('Resolving Dependencies')
pass
2007-09-20 21:00:34 -07:00
def creatingRollback(self):
#self.backend.status('Creating Rollback')
pass
2007-09-20 21:00:34 -07:00
def committingTransaction(self):
#self.backend.status('Committing Transaction')
pass
2007-09-20 21:00:34 -07:00
def downloadingFileContents(self, got, need):
#self.backend.status('Downloading files for changeset')
self.backend.status(INFO_DOWNLOADING)
2007-09-20 21:00:34 -07:00
def downloadingChangeSet(self, got, need):
self.backend.status(INFO_DOWNLOADING)
2007-09-20 21:00:34 -07:00
def requestingFileContents(self):
#self.backend.status('Requesting File Contents')
pass
2007-09-20 21:00:34 -07:00
def requestingChangeSet(self):
#self.backend.status('Requesting Changeset')
pass
def done(self):
#self.backend.status('Done')
pass
2007-09-20 21:00:34 -07:00
def preparingUpdate(self, troveNum, troveCount, add=0):
if troveNum > 0 and troveCount > 0:
sub_percent = (add + troveNum) / (2 * float(troveCount)) * 100
self.backend.sub_percentage(sub_percent)
2007-09-20 21:00:34 -07:00
2007-09-24 14:43:09 -07:00
if self.smallUpdate:
self.backend.percentage(sub_percent)
2007-09-20 21:00:34 -07:00
if troveNum != 0:
troveNum -= 1
job = self.currentJob[troveNum]
name = job[0]
oldVersion, oldFlavor = job[1]
newVersion, newFlavor = job[2]
if oldVersion and newVersion:
self.backend.status(INFO_UPDATING)
id = self.backend.get_package_id(name, newVersion, newFlavor)
self.backend.package(id, INFO_UPDATING, '')
elif oldVersion and not newVersion:
self.backend.status(INFO_REMOVING)
id = self.backend.get_package_id(name, oldVersion, oldFlavor)
self.backend.package(id, INFO_REMOVING, '')
elif not oldVersion and newVersion:
self.backend.status(INFO_INSTALLING)
id = self.backend.get_package_id(name, newVersion, newFlavor)
self.backend.package(id, INFO_INSTALLING, '')
2007-09-20 21:00:34 -07:00
def creatingDatabaseTransaction(self, troveNum, troveCount):
self.preparingUpdate(troveNum, troveCount, add=troveCount)
def setChangesetHunk(self, num, total):
pass
def setUpdateHunk(self, hunk, hunkCount):
if hunk > 0 and hunkCount > 0:
percentage = hunk / float(hunkCount) * 100.0
self.backend.percentage(percentage)
2007-09-24 14:43:09 -07:00
else:
self.smallUpdate = True
2007-09-20 21:00:34 -07:00
def setUpdateJob(self, job):
self.currentJob = job
def updateDone(self):
self.currentJob = None
def tagHandlerOutput(self, tag, msg, stderr = False):
pass
def troveScriptOutput(self, typ, msg):
pass
def troveScriptFailure(self, typ, errcode):
pass
def __init__(self, backend, cfg=None):
2007-09-20 21:00:34 -07:00
callbacks.UpdateCallback.__init__(self)
if cfg:
self.setTrustThreshold(cfg.trustThreshold)
self.backend = backend
2007-09-20 21:00:34 -07:00
self.currentJob = None
2007-09-24 14:43:09 -07:00
self.smallUpdate = False