[Catalog-sig] [Announce] Catalog Server Prototype Updated
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Wed, 2 May 2001 09:31:27 +0200
> * It now supports PEP 243 (HTTP POST to /archive/pep243_accept to try
> it out.)
This is what I'm most interested in, so I tried it first, using
swalowsupp.py (adopted to the right host, port, and relative path).
sendFile returned ('TRYAGAIN', ''). From the strace output, I could
see that the server response started with
HTTP/1.0 503 Service Unavailable\r\n
Server: Zope/(unreleased version) ZServer/1.1b1\r\n
Date: Wed, 02 May 2001 07:15:54 GMT\r\n
Bobo-Exception-File: /home/amos/Trunk/lib/python/Products/PythonCatalog/PEP243.py\r\n
Content-Type: text/html\r\n
Bobo-Exception-Type: NameError\r\n
Connection: close\r\n
Bobo-Exception-Value: <HTML><HEAD><TITLE>archive</TITLE></HEAD><BODY BGCOLOR=\#FFFFF\> <TABLE BORDER=\0\ WIDTH=\100%\> <TR VALIGN=\TOP\> <TD WIDTH=\10%\ ALIG=\CENTER\> <IMG SRC=\http://pdx:8080/p_/ZButton\ ALT=\Zope\> </TD> <TD WIDTH=\90%\> <H2>Zope Error</H2> <P>Zop\r\n
Content-Length: 2006\r\n
Bobo-Exception-Line: 61\r\n
\r\n
Unfortunately, swalowsupp closed the connection afterwards, so I did
not get to see the 2006 bytes content.
Using another approach, I tried to run Lynx, and Netscape, on the file
<html>
<body>
<H1>Upload file</H1>
<FORM NAME="fileupload" METHOD="POST" ACTION="http://63.230.174.230:8080/archive/pep243_accept"
ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="distribution"><BR>
<INPUT TYPE="text" NAME="distmd5sum"><BR>
<INPUT TYPE="file" NAME="pkginfo"><BR>
<INPUT TYPE="text" NAME="infomd5sum"><BR>
<INPUT TYPE="text" NAME="platform"><BR>
<INPUT TYPE="file" NAME="signature"><BR>
<INPUT TYPE="hidden" NAME="protocol_version" VALUE="1"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
</body>
</html>
Even though I've entered a distribution and a signature, both browsers
would not include them in their HTTP request. Any idea what could be
wrong with that form?
Regards,
Martin
P.S. In case anybody wants to experiment with it, I include my
modified swalowsupp.py as well. To initiate an upload, do something like
swalowsupp.sendDist("PyXML-0.7.0.tar.gz",
signature=open("PyXML-0.7.0.tar.gz.asc").read())
#!/usr/bin/env python
'''Routines for submission of distributions to repository server.'''
# created 2001/03/26 by Sean Reifschneider <jafo-swalow@tummy.com>
uploadHost = 'community.tummy.com'
import httplib, urllib
import time, os, sys
import md5
#####################################
# emulate 'md5sum' command on a file
def md5sum(file):
fp = open(file, 'rb')
md = md5.new()
while 1:
data = fp.read(10240)
if not data: break
md.update(data)
digest = md.digest()
sum = reduce(lambda x,y: x + ('%02x' % y), map(ord, digest), '')
return(sum)
#######################################################
def sendDist(fileName, pkgFile = None, platform = None,
signature = None, userAgent = 'swalow', uploadHost = None):
if uploadHost == None: uploadHost = '63.230.174.230'
tmp = os.environ.get('PYTHON_MODULE_SERVER', None)
if tmp: uploadHost = tmp
# get file information
fileLen = os.stat(fileName)[6]
fileMD5 = md5sum(fileName)
# create body
boundary = '%s%.8f_%s' % ( '-' * 30, time.time(), os.uname()[1] )
boundary = '---------------------------87109191412184106881070100800'
body = ''
body = body + '--%s\r\nContent-Disposition: form-data; ' \
'name="protocol_version"\r\n\r\n1\r\n' % ( boundary, )
if platform:
body = body + '--%s\r\nContent-Disposition: form-data; ' \
'name="platform"\r\n\r\n%s\r\n' % ( boundary, platform )
if signature:
body = body + '--%s\r\nContent-Disposition: form-data; ' \
'name="signature"\r\n\r\n%s\r\n' % ( boundary, signature )
body = body + '--%s\r\nContent-Disposition: form-data; ' \
'name="distmd5sum"\r\n\r\n%s\r\n' % ( boundary, fileMD5 )
body = body + '--%s\r\nContent-Disposition: form-data; name="distribution"' \
'; filename="%s"\r\n\r\n' % ( boundary, os.path.basename(fileName) )
body2 = ''
body3 = '\r\n--%s--\r\n' % boundary
if pkgFile != None:
fileLen = fileLen + os.stat(pkgFile)[6]
infoMD5 = md5sum(pkgFile)
body2 = body2 + '--%s\r\nContent-Disposition: form-data; ' \
'name="infomd5sum"\r\n\r\n%s\r\n' % ( boundary, infoMD5 )
body2 = body2 + '--%s\r\nContent-Disposition: form-data; ' \
'name="pkginfo"; filename="%s"\r\n\r\n' \
% ( boundary, os.path.basename(fileName) )
# send header
h = httplib.HTTP(uploadHost,8080)
h.putrequest('POST', '/archive/pep243_accept')
h.putheader('Content-length', '%d' % (len(body) + fileLen + len(body2)))
h.putheader('Content-type', 'multipart/form-data; boundary=%s' % boundary)
#h.putheader('User-Agent', userAgent)
h.endheaders()
# send body
h.send(body)
fp = open(fileName, 'rb')
while 1:
data = fp.read(4096)
if not data: break
h.send(data)
h.send(body2)
reply, msg, hdrs = h.getreply()
status = hdrs.get('X-Swalow-Status', 'TRYAGAIN')
reason = hdrs.get('X-Swalow-Reason', '')
return(status, reason)