seth vidal wrote:
writing a program that downloads pkgs and runs the transaction w/o
duplicating a bunch of code from cli.doTransaction(). this clearly needs
to be fixed.

The standard operating set:

1. download pkgs
2. sig check pkgs
3. test transaction
4. rpm_check_debug transaction
5. ts.check()
6. ts.order()
7. self.runTransaction(cb)

yes, this needs to be much simpler.

-sv


_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
Yes, it sucks, and there is even more step for the time you have populates self.tsInfo with the actions you want to perform.

1. Solve dependencies.
2. Ask the user for confimation.
3. Download packages.
4. Check signatures.
5 Ask user for gpg key import confimation if needed.
6. Do a test transaction
7. Do the real transaction

But how do we make it better ?.
Add a generic 'processTransaction' to YumBaseCli with some kind of callback, so it can be extended ??
See the attached pseudo kode.

Tim


# Add this to the YumBase class

    def ProcessTransaction(self, callback=None)
        action = "Download Packages"
        if callback: callback.event(action=action, state="Start")
        self._downloadPackages()
        if callback: callback.event(action=action", state="End")
        action = "Checking Signatures"
        if callback: callback.event(action=action, state="Start")
        self._checkSignatures()
        if callback: callback.event(action=action", state="End")
        action = "Test Transaction"
        if callback: callback.event(action=action, state="Start")
        self._doTestTransaction()
        if callback: callback.event(action=action", state="End")
        action = "Test Transaction"
        if callback: callback.event(action=action, state="Start")
        self._doTransaction()
        if callback: callback.event(action=action", state="End")
    
    def _downloadPackages(self):
       ''' Download the need packages in the Transaction '''
       # Add the code here.
       # This can be overloaded by a subclass.    


    def _checkSignatures(self):
       ''' The the signatures of the downloaded packages '''
       # Add the code here.
       # This can be overloaded by a subclass.    


    def _doTestTransaction(self):
       ''' Do the test transaction '''
       # Add the code here.
       # This can be overloaded by a subclass.    


    def _doTransaction(self):
       ''' do the real Transaction '''
       # Add the code here.
       # This can be overloaded by a subclass.    

class ProcessTransactionCallback:
    ''' 
    callback class for YumBase.processTransaction
    the event method is called for every step in the process
    it can be overloaded by subclass the want do some other action
    '''

    def __init__(self,logger,logIt = False):
        self.logger = logger
        self.logIt = logIt
        # setup code
        
    def event(self,action = None, state = None):
        if self.logIt:
            self.logger.info('%s %s' % (state,action))
    

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to