Re: Treating 'not found' packages as errors

Anders Blomdell <[email protected]>
Newsgroups gmane.linux.rpm.yum
Message-ID <[email protected]>
seth vidal wrote:
> On Wed, 2008-04-23 at 20:31 +0200, Anders Blomdell wrote:
> 
>> now the problem is that this program:
>>
>> #!/usr/bin/python
>>
>> import yum, os, sys
>>
>> my = yum.YumBase()
>> my.conf.basecachedir = '/tmp/whereever'
>> if not os.path.exists(my.conf.basecachedir):
>>     os.makedirs(my.conf.basecachedir)
>> my.conf.cache = 0
>> my.repos.setCacheDir(my.conf.basecachedir)
>>
>> my.install(name='xpdf')
>> my.install(name='xwnc')
>> my.resolveDeps()
>> my.processTransaction()
>>
>> when run as root correctly installs xpdf and xwnc, but when run as an ordinary
>> user just quitely does nothing. How do I check if installation is successful?
> 
> take a look at the code for processTransaction() and the callback it can
> take.
> the callback will be helpful to you
> 
> and also take a look at what my.install() returns - it returns a list of
> TransactionMember objects for the pkgs it added to the transaction.
I have already found that out, the problem is that my.processTransaction()
silently refuses to install.

#!/usr/bin/python

import yum, os, sys

# setup base objects
my = yum.YumBase()

# someplace you can write to as your user
my.conf.basecachedir = '/tmp/whereever'
if not os.path.exists(my.conf.basecachedir):
    os.makedirs(my.conf.basecachedir)
my.conf.cache = 0
my.repos.setCacheDir(my.conf.basecachedir)

class cb(object):

    def event(self, state, *data):
        try:
            print state,yum.callbacks.PT_MESSAGES[state],data
        except:
            print state,data

my.install(name='xpdf')
my.install(name='xwnc')

my.resolveDeps()

for m in my.tsInfo.getMembers():
    print m.name

my.processTransaction(callback=cb())


This is the output when it s run as a user:

xpdf
xwnc
10 Downloading Packages ()
11 11 ([<yum.sqlitesack.YumAvailablePackageSqlite object at 0x956744c>,
<yum.sqlitesack.YumAvailablePackageSqlite object at 0xc525bac>],)
20 Check Package Signatures ()
30 Running Test Transaction ()
Running rpm_check_debug
40 Running Transaction ()

And this is what I get as root:

xpdf
xwnc
10 Downloading Packages ()
11 11 ([<yum.sqlitesack.YumAvailablePackageSqlite object at 0x95e828c>,
<yum.sqlitesack.YumAvailablePackageSqlite object at 0xc52632c>],)
20 Check Package Signatures ()
30 Running Test Transaction ()
Running rpm_check_debug
40 Running Transaction ()
Installing: xwnc - 0.3.3-3.fc7.i386 65664/997380 [1/2]
...
Installing: xwnc - 0.3.3-3.fc7.i386 997380/997380 [1/2]
Installing: xpdf - 1:3.02-4.fc7.i386 124/2579392 [2/2]
...
Installing: xpdf - 1:3.02-4.fc7.i386 2579392/2579392 [2/2]


Best regards

Anders Blomdell


-- 
Anders Blomdell                  Email: [email protected]
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.