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-09-23 21:55:32 -07:00
|
|
|
from packagekit import *
|
2007-09-20 21:00:34 -07:00
|
|
|
|
2007-09-23 21:55:32 -07:00
|
|
|
class UpdateCallback(callbacks.UpdateCallback):
|
2007-09-20 21:00:34 -07:00
|
|
|
def resolvingDependencies(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#self.backend.status('Resolving Dependencies')
|
|
|
|
pass
|
2007-09-20 21:00:34 -07:00
|
|
|
|
|
|
|
def creatingRollback(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#self.backend.status('Creating Rollback')
|
|
|
|
pass
|
2007-09-20 21:00:34 -07:00
|
|
|
|
|
|
|
def committingTransaction(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#self.backend.status('Committing Transaction')
|
|
|
|
pass
|
2007-09-20 21:00:34 -07:00
|
|
|
|
|
|
|
def downloadingFileContents(self, got, need):
|
2007-10-08 19:13:32 -07:00
|
|
|
#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):
|
2007-10-08 19:13:32 -07:00
|
|
|
self.backend.status(INFO_DOWNLOADING)
|
2007-09-20 21:00:34 -07:00
|
|
|
|
|
|
|
def requestingFileContents(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#self.backend.status('Requesting File Contents')
|
|
|
|
pass
|
2007-09-20 21:00:34 -07:00
|
|
|
|
|
|
|
def requestingChangeSet(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#self.backend.status('Requesting Changeset')
|
|
|
|
pass
|
2007-09-23 21:55:32 -07:00
|
|
|
|
|
|
|
def done(self):
|
2007-10-08 19:13:32 -07:00
|
|
|
#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
|
2007-09-23 21:55:32 -07:00
|
|
|
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]
|
2007-09-23 08:54:31 -07:00
|
|
|
oldVersion, oldFlavor = job[1]
|
|
|
|
newVersion, newFlavor = job[2]
|
|
|
|
|
|
|
|
if oldVersion and newVersion:
|
2007-10-08 19:13:32 -07:00
|
|
|
self.backend.status(INFO_UPDATING)
|
2007-09-23 21:55:32 -07:00
|
|
|
id = self.backend.get_package_id(name, newVersion, newFlavor)
|
2007-09-23 08:54:31 -07:00
|
|
|
elif oldVersion and not newVersion:
|
2007-10-08 19:13:32 -07:00
|
|
|
self.backend.status(INFO_REMOVING)
|
2007-09-23 21:55:32 -07:00
|
|
|
id = self.backend.get_package_id(name, oldVersion, oldFlavor)
|
2007-09-23 08:54:31 -07:00
|
|
|
elif not oldVersion and newVersion:
|
2007-10-08 19:13:32 -07:00
|
|
|
self.backend.status(INFO_INSTALLING)
|
2007-09-23 21:55:32 -07:00
|
|
|
id = self.backend.get_package_id(name, newVersion, newFlavor)
|
2007-09-20 21:00:34 -07:00
|
|
|
|
2007-09-23 21:55:32 -07:00
|
|
|
self.backend.package(id, 1, '')
|
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
|
2007-09-23 21:55:32 -07:00
|
|
|
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
|
|
|
|
|
2007-09-23 21:55:32 -07:00
|
|
|
def __init__(self, backend, cfg=None):
|
2007-09-20 21:00:34 -07:00
|
|
|
callbacks.UpdateCallback.__init__(self)
|
|
|
|
if cfg:
|
|
|
|
self.setTrustThreshold(cfg.trustThreshold)
|
|
|
|
|
2007-09-23 21:55:32 -07:00
|
|
|
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
|