[Checkins] SVN: keas.build/trunk/ - Bug Fix: re did not like non-text parameters coming from BeautifulSoup

Adam Groszer agroszer at gmail.com
Fri Oct 16 12:56:23 EDT 2009


Log message for revision 105104:
  - Bug Fix: re did not like non-text parameters coming from BeautifulSoup
  - Improvement: added the ``--timeout`` option to install
  - Improvement: added mypypi buildout file upload support
  

Changed:
  U   keas.build/trunk/CHANGES.txt
  U   keas.build/trunk/src/keas/build/base.py
  U   keas.build/trunk/src/keas/build/build.py
  U   keas.build/trunk/src/keas/build/index.txt
  U   keas.build/trunk/src/keas/build/install.py
  U   keas.build/trunk/src/keas/build/package.py

-=-
Modified: keas.build/trunk/CHANGES.txt
===================================================================
--- keas.build/trunk/CHANGES.txt	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/CHANGES.txt	2009-10-16 16:56:22 UTC (rev 105104)
@@ -12,6 +12,14 @@
 
 - Bug Fix: multiline template option values crashed on parsing
 
+- Bug Fix: re did not like non-text parameters coming from BeautifulSoup
+
+- Improvement: added the ``--timeout`` option to install
+
+- Improvement: added mypypi buildout file upload support
+
+- Bug Fix: revert to checkout of the complete source tree
+
 0.1.4 (2009-10-01)
 ------------------
 

Modified: keas.build/trunk/src/keas/build/base.py
===================================================================
--- keas.build/trunk/src/keas/build/base.py	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/src/keas/build/base.py	2009-10-16 16:56:22 UTC (rev 105104)
@@ -1,16 +1,8 @@
-##############################################################################
+###############################################################################
 #
-# Copyright (c) 2008 Zope Foundation and Contributors.
-# All Rights Reserved.
+# Copyright 2008 by Keas, Inc., San Francisco, CA
 #
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
+###############################################################################
 """Build a release
 
 $Id$
@@ -65,11 +57,12 @@
         return default
     return value
 
-
-def uploadFile(path, url, username, password, offline):
-    filename = os.path.split(path)[-1]
+def uploadContent(content, filename, url, username, password,
+                  offline, method, headers=None):
     if offline:
         logger.info('Offline: File `%s` not uploaded.' %filename)
+        return
+
     logger.debug('Uploading `%s` to %s' %(filename, url))
     pieces = urlparse.urlparse(url)
     Connection = httplib.HTTPConnection
@@ -78,21 +71,35 @@
 
     base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
 
+    if headers is None:
+        headers = {}
+
+    headers["Authorization"] = "Basic %s" % base64string
+
     conn = Connection(pieces[1])
     conn.request(
-        'PUT',
-        pieces[2]+'/'+filename,
-        open(path, 'r').read(),
-        {"Authorization": "Basic %s" % base64string})
+        method,
+        pieces[2],
+        content,
+        headers)
 
     response = conn.getresponse()
-    if response.status != 201:
+    if ((response.status != 201 and method == 'PUT')
+        or response.status != 200 and method == 'POST'):
         logger.error('Error uploading file. Code: %i (%s)' %(
             response.status, response.reason))
     else:
         logger.info('File uploaded: %s' %filename)
 
+def uploadFile(path, url, username, password, offline, method='PUT',
+               headers=None):
+    filename = os.path.split(path)[-1]
 
+    uploadContent(open(path, 'r').read(),
+                  filename, url+'/'+filename,
+                  username, password, offline, method, headers=headers)
+
+
 def guessNextVersion(version):
     pieces = pkg_resources.parse_version(version)
     newPieces = []

Modified: keas.build/trunk/src/keas/build/build.py
===================================================================
--- keas.build/trunk/src/keas/build/build.py	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/src/keas/build/build.py	2009-10-16 16:56:22 UTC (rev 105104)
@@ -66,7 +66,7 @@
 
         versions = []
         for tag in soup('a'):
-            cntnt = tag.contents[0]
+            cntnt = str(tag.contents[0]) # str: re does not like non-strings
             m = VERSION.search(cntnt)
             if m:
                 versions.append(m.group(1))
@@ -192,9 +192,28 @@
                     config.get(base.BUILD_SECTION, 'buildout-server-password'),
                     options.offline)
     elif uploadType == 'mypypi':
-        pass
+        if not options.offline and not options.noUpload:
+            url = (config.get(base.BUILD_SECTION, 'buildout-server')+
+                   '/'+projectName+'/upload')
+            boundary = "--------------GHSKFJDLGDS7543FJKLFHRE75642756743254"
+            headers={"Content-Type":
+                "multipart/form-data; boundary=%s; charset=utf-8" % boundary}
+            for filename in filesToUpload:
+                #being lazy here with the construction of the multipart form data
+                content = """--%s
+Content-Disposition: form-data; name="content";filename="%s"
 
+%s
+--%s--
+""" % (boundary, filename, open(filename, 'r').read(), boundary)
 
+                base.uploadContent(
+                    content, filename, url,
+                    config.get(base.BUILD_SECTION, 'buildout-server-username'),
+                    config.get(base.BUILD_SECTION, 'buildout-server-password'),
+                    options.offline, method='POST', headers=headers)
+
+
 def main(args=None):
     # Make sure we get the arguments.
     if args is None:

Modified: keas.build/trunk/src/keas/build/index.txt
===================================================================
--- keas.build/trunk/src/keas/build/index.txt	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/src/keas/build/index.txt	2009-10-16 16:56:22 UTC (rev 105104)
@@ -214,7 +214,7 @@
 
   - **mypypi** Upload generated buildout files to the url specified by
     ``buildout-server``. The url should point to the mypypi upload page.
-    (coming soon)
+    (Something like http://yourhost/++projects++/)
 
 - **buildout-server** - The url to a WebDAV enabled web
   server where generated buildout files should be uploaded.

Modified: keas.build/trunk/src/keas/build/install.py
===================================================================
--- keas.build/trunk/src/keas/build/install.py	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/src/keas/build/install.py	2009-10-16 16:56:22 UTC (rev 105104)
@@ -90,6 +90,9 @@
         versions = []
         for tag in soup('a'):
             text = tag.contents[0]
+            if not text:
+                continue
+            text = str(text)
             if not text.startswith(project+'-'+variant):
                 continue
             version = text.split('-')[-1][:-4]
@@ -136,8 +139,9 @@
                     print '  * ' + name
                 version = base.getInput('Version', versions[-1], False)
         # 4. Install the package
-        base.do('%s -t 2 -%sc %s%s/%s-%s-%s.cfg' %(
+        base.do('%s -t %s -%sc %s%s/%s-%s-%s.cfg' %(
                 self.options.buildout,
+                self.options.timeout,
                 "vv" if self.options.verbose else "",
                 self.options.url,
                 project,
@@ -195,6 +199,12 @@
     dest="verbose", default=False,
     help="When specified, debug information is created.")
 
+parser.add_option(
+    "--timeout", action="store", type="int", default=2,
+    dest="timeout", metavar="TIMEOUT",
+    help="Socket timeout passed on to buildout.")
+
+
 def main(args=None):
     # Make sure we get the arguments.
     if args is None:

Modified: keas.build/trunk/src/keas/build/package.py
===================================================================
--- keas.build/trunk/src/keas/build/package.py	2009-10-16 15:11:35 UTC (rev 105103)
+++ keas.build/trunk/src/keas/build/package.py	2009-10-16 16:56:22 UTC (rev 105104)
@@ -135,7 +135,7 @@
 
         versions = []
         for tag in soup('a'):
-            cntnt = tag.contents[0]
+            cntnt = str(tag.contents[0]) # str: re does not like non-strings
             m = VERSION.search(cntnt)
             if m:
                 versions.append(m.group(1))



More information about the checkins mailing list