On Sun, 2006-09-04 at 10:27 -0700, Zac Medico wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Eldad Zack wrote: > > I've came across another problem as well. > > importing portage will go through its initialization, checking VDB and > > sorts, > > so that if I'd like in to switch a VDB I'll have to re-import portage. > > Since > > I do not know of a way to re-import portage in python, I've worked around > > this by changing ROOT env and then call portage via os.system calls. > > On my humble amd 2600 machine this yields a 8 seconds average per VDB > > change. > > > > Is there something I can do beside replicating the init code into a > > function, > > change root and recall the init function again? > > > > Is there a better way of doing this? > > In python's built-in global function list you'll see one called reload(). If > you call reload(portage), it causes a re-import of the module. > > Zac
Just a word of caution. I don't know why but sometimes after an upgrade of portage a reload(portage) in porthole fails and porthole crashes. I don't remember the details atm and have not investigated the reasons. In all cases restarting porthole, all works fine again. It may not ever happen to your code though. -- Brian <[EMAIL PROTECTED]> -- [email protected] mailing list
