Re: [Pyobjc-dev] Re: [Pyobjc-checkins] CVS: pyobjc/Examples/Twisted/PackMan newpimp.py,NONE,1.1 Pack
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-11-11 22:59:40
|
We're aware of that, and have discussed it at length with Jack in the MacPython channel. Basically the deal is that it's using Twisted right now, because that's what's easiest, but will be refactored to be pluggable later once it works. When it works, we can distribute a --semi-standalone version w/ Twisted, then begin work on a version that can live in MacPython 2.4 that would use whichever mechanisms are appropriate and available. -bob On Nov 11, 2003, at 5:45 PM, Ronald Oussoren wrote: > Just to give some useless feedback... Your implementation of packman > uses Twisted, but I wonder if this is the right thing to do. > > A new version of PackMan should one day be part of MacPython, and > therefore the core python distribution. I don't think Twisted will be > in by then. Would it not be better to move the downloading of files to > a platform/gui-kit dependent layer? E.g. at initialisation the GUI > asks the pimp module for the URL of the (default) database, downloads > that and initialises the pimp module with that. At installation time > it queries the package for URL's that should be downloaded, downloads > those files and passes them to the module. > > You could then use NSUrl with Cocoa on MacOSX, whatever is used by > wxWindows when using that GUI , Twisted when that is available and > urllib2 when nothing better is available (or when you don't care, I > don't care if the cmd-line tool blocks during the download of > archives). > > Ronald > > P.S. That doesn't mean that I don't like twisted at all, I intend to > use it sometime soon, I just don't think it is the right tool for this > problem. > > On 11 nov 2003, at 23:00, Bob Ippolito wrote: > >> Update of /cvsroot/pyobjc/pyobjc/Examples/Twisted/PackMan >> In directory sc8-pr-cvs1:/tmp/cvs-serv11329 >> >> Modified Files: >> PackMan.py buildapp.py newclient.py >> Added Files: >> newpimp.py >> Log Message: >> move plist parse/download to "newpimp" module, make client non-noisy >> >> >> --- NEW FILE: newpimp.py --- >> """Package Install Manager for Python. >> >> This is currently a MacOSX-only strawman implementation. >> Despite other rumours the name stands for "Packman IMPlementation". >> >> Tools to allow easy installation of packages. The idea is that there >> is >> an online XML database per (platform, python-version) containing >> packages >> known to work with that combination. This module contains tools for >> getting >> and parsing the database, testing whether packages are installed, >> computing >> dependencies and installing packages. >> >> There is a minimal main program that works as a command line tool, >> but the >> intention is that the end user will use this through a GUI. >> """ >> import sys >> import os >> import popen2 >> import urllib >> import urllib2 >> [...1021 lines suppressed...] >> # If the end-user updates pimp through pimp the new version >> # will be called pimp_update and live in site-packages >> # or somewhere similar >> if __name__ != 'pimp_update': >> try: >> import pimp_update >> except ImportError: >> pass >> else: >> if pimp_update.PIMP_VERSION <= PIMP_VERSION: >> import warnings >> warnings.warn("pimp_update is version %s, not newer than >> pimp version %s" % >> (pimp_update.PIMP_VERSION, PIMP_VERSION)) >> else: >> from pimp_update import * >> >> if __name__ == '__main__': >> main() >> >> >> >> Index: PackMan.py >> =================================================================== >> RCS file: /cvsroot/pyobjc/pyobjc/Examples/Twisted/PackMan/PackMan.py,v >> retrieving revision 1.2 >> retrieving revision 1.3 >> diff -C2 -d -r1.2 -r1.3 >> *** PackMan.py 11 Nov 2003 17:15:02 -0000 1.2 >> --- PackMan.py 11 Nov 2003 22:00:16 -0000 1.3 >> *************** >> *** 6,9 **** >> --- 6,11 ---- >> reactor = twisted.internet.cfreactor.install() >> >> + from twisted.internet import error >> + >> ## New HTTP client in Twisted/sandbox/moshez >> import newclient >> *************** >> *** 17,20 **** >> --- 19,31 ---- >> import plistlib >> >> + import newpimp >> + >> + # DEBUG >> + import sys >> + from twisted.python import log >> + log.startLogging(sys.stdout) >> + >> + # the test-multidatabase >> + DATABASE = 'http://undefined.org/python/pimp/panther.plist' >> >> NibClassBuilder.extractClasses("MainMenu") >> *************** >> *** 53,58 **** >> >> class PackageController(NibClassBuilder.AutoBaseClass): >> ! packages = [] >> ! _allPackages = [] >> >> def applicationDidFinishLaunching_(self, aNotification): >> --- 64,69 ---- >> >> class PackageController(NibClassBuilder.AutoBaseClass): >> ! packages = () >> ! _allPackages = () >> >> def applicationDidFinishLaunching_(self, aNotification): >> *************** >> *** 60,72 **** >> NSIndexSet.indexSetWithIndex_(0), NO >> ) >> ! >> self.openDatabase('http://undefined.org/python/pimp/darwin-7.0.0- >> Power_Macintosh.plist') >> reactor.run() >> >> def openDatabase(self, url): >> ! o = newclient.opener() >> ! d = o.open( >> ! newclient.Request(str(url)) >> ! ).addCallback( >> ! newclient.read >> ).addCallback( >> self.gotPlist >> --- 71,80 ---- >> NSIndexSet.indexSetWithIndex_(0), NO >> ) >> ! self.openDatabase(DATABASE) >> reactor.run() >> >> def openDatabase(self, url): >> ! log.msg('Opening database: %s' % (url,)) >> ! return newpimp.downloadPackmanDatabase(url.encode('utf8') >> ).addCallback( >> self.gotPlist >> *************** >> *** 75,83 **** >> ) >> >> ! def gotPlist(self, pliststring): >> ! fl = StringIO(pliststring) >> ! plist = plistlib.Plist.fromFile(fl) >> packages = plist['Packages'] >> ! packages.sort(lambda x, y: cmp(x['Name'].lower(), >> y['Name'].lower())) >> self._allPackagesIncludingHidden = packages >> self._allPackages = self.packages = [x for x in packages if >> x.get('Version', None)] >> --- 83,99 ---- >> ) >> >> ! def gotPlist(self, plist): >> ! log.msg('received plist') >> packages = plist['Packages'] >> ! # >> ! # XXX - Flavors and Version should be condensed into one >> row? >> ! # >> ! # default sort is >> ! # Name, Version, Flavor >> ! # >> ! packages.sort(lambda a,b:( >> ! cmp(a['Name'].lower(), b['Name'].lower()) or >> ! cmp(a.get('Version'), b.get('Version')) or >> ! cmp(a.get('Flavor'), b.get('Flavor')))) >> self._allPackagesIncludingHidden = packages >> self._allPackages = self.packages = [x for x in packages if >> x.get('Version', None)] >> >> Index: buildapp.py >> =================================================================== >> RCS file: >> /cvsroot/pyobjc/pyobjc/Examples/Twisted/PackMan/buildapp.py,v >> retrieving revision 1.1 >> retrieving revision 1.2 >> diff -C2 -d -r1.1 -r1.2 >> *** buildapp.py 11 Nov 2003 04:23:34 -0000 1.1 >> --- buildapp.py 11 Nov 2003 22:00:18 -0000 1.2 >> *************** >> *** 4,9 **** >> mainprogram = "PackMan.py", >> resources = ["MainMenu.nib"], >> ! includeModules=['newclient'], >> symlink = True, >> nibname = "MainMenu" >> ! ) >> \ No newline at end of file >> --- 4,9 ---- >> mainprogram = "PackMan.py", >> resources = ["MainMenu.nib"], >> ! includeModules=['newclient', 'newpimp'], >> symlink = True, >> nibname = "MainMenu" >> ! ) >> >> Index: newclient.py >> =================================================================== >> RCS file: >> /cvsroot/pyobjc/pyobjc/Examples/Twisted/PackMan/newclient.py,v >> retrieving revision 1.2 >> retrieving revision 1.3 >> diff -C2 -d -r1.2 -r1.3 >> *** newclient.py 11 Nov 2003 17:15:02 -0000 1.2 >> --- newclient.py 11 Nov 2003 22:00:19 -0000 1.3 >> *************** >> *** 51,54 **** >> --- 51,55 ---- >> class HTTPClient(http.HTTPClient): >> >> + response = None >> def connectionMade(self): >> self.factory.connection.callback(self) >> *************** >> *** 78,85 **** >> def handleResponseEnd(self): >> self.done = 1 >> ! self.response.dataDone() >> >> class ClientFactory(protocol.ClientFactory): >> protocol = HTTPClient >> def __init__(self): >> self.connection = defer.Deferred() >> --- 79,88 ---- >> def handleResponseEnd(self): >> self.done = 1 >> ! if self.response is not None: >> ! self.response.dataDone() >> >> class ClientFactory(protocol.ClientFactory): >> protocol = HTTPClient >> + noisy = None and "FOR GOD'S SAKE NOISY CLIENT FACTORIES SUCK" >> def __init__(self): >> self.connection = defer.Deferred() >> >> >> >> ------------------------------------------------------- >> This SF.Net email sponsored by: ApacheCon 2003, >> 16-19 November in Las Vegas. Learn firsthand the latest >> developments in Apache, PHP, Perl, XML, Java, MySQL, >> WebDAV, and more! http://www.apachecon.com/ >> _______________________________________________ >> pyobjc-checkins mailing list >> pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-checkins >> > > > > ------------------------------------------------------- > This SF.Net email sponsored by: ApacheCon 2003, > 16-19 November in Las Vegas. Learn firsthand the latest > developments in Apache, PHP, Perl, XML, Java, MySQL, > WebDAV, and more! http://www.apachecon.com/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |