/
usr
/
lib
/
python2.6
/
site-packages
/
setuptools
/
command
/
/usr/lib/python2.6/site-packages/setuptools/command
mkdir
upload
Name
Size
Mode
Actions
alias.py
2477
0644
edit
dl
rm
alias.pyc
3252
0644
edit
dl
rm
alias.pyo
3252
0644
edit
dl
rm
bdist_egg.py
17993
0644
edit
dl
rm
bdist_egg.pyc
18015
0644
edit
dl
rm
bdist_egg.pyo
18015
0644
edit
dl
rm
bdist_rpm.py
2025
0644
edit
dl
rm
bdist_rpm.pyc
2317
0644
edit
dl
rm
bdist_rpm.pyo
2317
0644
edit
dl
rm
bdist_wininst.py
1548
0644
edit
dl
rm
bdist_wininst.pyc
1836
0644
edit
dl
rm
bdist_wininst.pyo
1836
0644
edit
dl
rm
build_ext.py
11704
0644
edit
dl
rm
build_ext.pyc
10361
0644
edit
dl
rm
build_ext.pyo
10315
0644
edit
dl
rm
build_py.py
9944
0644
edit
dl
rm
build_py.pyc
11055
0644
edit
dl
rm
build_py.pyo
11055
0644
edit
dl
rm
develop.py
9535
0644
edit
dl
rm
develop.pyc
9028
0644
edit
dl
rm
develop.pyo
9028
0644
edit
dl
rm
easy_install.py
64104
0755
edit
dl
rm
easy_install.pyc
59092
0644
edit
dl
rm
easy_install.pyo
59092
0644
edit
dl
rm
egg_info.py
14356
0644
edit
dl
rm
egg_info.pyc
17028
0644
edit
dl
rm
egg_info.pyo
17028
0644
edit
dl
rm
install.py
4065
0644
edit
dl
rm
install.pyc
3801
0644
edit
dl
rm
install.pyo
3801
0644
edit
dl
rm
install_egg_info.py
3732
0644
edit
dl
rm
install_egg_info.pyc
4672
0644
edit
dl
rm
install_egg_info.pyo
4672
0644
edit
dl
rm
install_lib.py
2486
0644
edit
dl
rm
install_lib.pyc
3273
0644
edit
dl
rm
install_lib.pyo
3223
0644
edit
dl
rm
install_scripts.py
2011
0644
edit
dl
rm
install_scripts.pyc
2534
0644
edit
dl
rm
install_scripts.pyo
2534
0644
edit
dl
rm
launcher manifest.xml
628
0644
edit
dl
rm
register.py
277
0644
edit
dl
rm
register.pyc
692
0644
edit
dl
rm
register.pyo
692
0644
edit
dl
rm
rotate.py
2021
0644
edit
dl
rm
rotate.pyc
2940
0644
edit
dl
rm
rotate.pyo
2940
0644
edit
dl
rm
saveopts.py
740
0644
edit
dl
rm
saveopts.pyc
1275
0644
edit
dl
rm
saveopts.pyo
1275
0644
edit
dl
rm
sdist.py
7183
0644
edit
dl
rm
sdist.pyc
8309
0644
edit
dl
rm
sdist.pyo
8309
0644
edit
dl
rm
setopt.py
5053
0644
edit
dl
rm
setopt.pyc
6063
0644
edit
dl
rm
setopt.pyo
6063
0644
edit
dl
rm
test.py
5110
0644
edit
dl
rm
test.pyc
5442
0644
edit
dl
rm
test.pyo
5442
0644
edit
dl
rm
upload.py
6681
0644
edit
dl
rm
upload.pyc
6408
0644
edit
dl
rm
upload.pyo
6375
0644
edit
dl
rm
upload_docs.py
5507
0644
edit
dl
rm
upload_docs.pyc
5741
0644
edit
dl
rm
upload_docs.pyo
5708
0644
edit
dl
rm
__init__.py
690
0644
edit
dl
rm
__init__.pyc
915
0644
edit
dl
rm
__init__.pyo
915
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/setuptools/command/upload.py
(6681B)
"""distutils.command.upload Implements the Distutils 'upload' subcommand (upload package to PyPI).""" from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn from distutils import log try: from hashlib import md5 except ImportError: from md5 import md5 import os import socket import platform import ConfigParser import httplib import base64 import urlparse import cStringIO as StringIO class upload(Command): description = "upload binary package to PyPI" DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi' user_options = [ ('repository=', 'r', "url of repository [default: %s]" % DEFAULT_REPOSITORY), ('show-response', None, 'display full response text from server'), ('sign', 's', 'sign files to upload using gpg'), ('identity=', 'i', 'GPG identity used to sign files'), ] boolean_options = ['show-response', 'sign'] def initialize_options(self): self.username = '' self.password = '' self.repository = '' self.show_response = 0 self.sign = False self.identity = None def finalize_options(self): if self.identity and not self.sign: raise DistutilsOptionError( "Must use --sign for --identity to have meaning" ) if os.environ.has_key('HOME'): rc = os.path.join(os.environ['HOME'], '.pypirc') if os.path.exists(rc): self.announce('Using PyPI login from %s' % rc) config = ConfigParser.ConfigParser({ 'username':'', 'password':'', 'repository':''}) config.read(rc) if not self.repository: self.repository = config.get('server-login', 'repository') if not self.username: self.username = config.get('server-login', 'username') if not self.password: self.password = config.get('server-login', 'password') if not self.repository: self.repository = self.DEFAULT_REPOSITORY def run(self): if not self.distribution.dist_files: raise DistutilsOptionError("No dist file created in earlier command") for command, pyversion, filename in self.distribution.dist_files: self.upload_file(command, pyversion, filename) def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: gpg_args = ["gpg", "--detach-sign", "-a", filename] if self.identity: gpg_args[2:2] = ["--local-user", self.identity] spawn(gpg_args, dry_run=self.dry_run) # Fill in the data f = open(filename,'rb') content = f.read() f.close() basename = os.path.basename(filename) comment = '' if command=='bdist_egg' and self.distribution.has_ext_modules(): comment = "built on %s" % platform.platform(terse=1) data = { ':action':'file_upload', 'protcol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(basename,content), 'filetype':command, 'pyversion':pyversion, 'md5_digest':md5(content).hexdigest(), } if command == 'bdist_rpm': dist, version, id = platform.dist() if dist: comment = 'built for %s %s' % (dist, version) elif command == 'bdist_dumb': comment = 'built for %s' % platform.platform(terse=1) data['comment'] = comment if self.sign: data['gpg_signature'] = (os.path.basename(filename) + ".asc", open(filename+".asc").read()) # set up the authentication auth = "Basic " + base64.encodestring(self.username + ":" + self.password).strip() # Build up the MIME payload for the POST data boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' sep_boundary = '\n--' + boundary end_boundary = sep_boundary + '--' body = StringIO.StringIO() for key, value in data.items(): # handle multiple entries for the same name if type(value) != type([]): value = [value] for value in value: if type(value) is tuple: fn = ';filename="%s"' % value[0] value = value[1] else: fn = "" value = str(value) body.write(sep_boundary) body.write('\nContent-Disposition: form-data; name="%s"'%key) body.write(fn) body.write("\n\n") body.write(value) if value and value[-1] == '\r': body.write('\n') # write an extra newline (lurve Macs) body.write(end_boundary) body.write("\n") body = body.getvalue() self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) # build the Request # We can't use urllib2 since we need to send the Basic # auth right with the first request schema, netloc, url, params, query, fragments = \ urlparse.urlparse(self.repository) assert not params and not query and not fragments if schema == 'http': http = httplib.HTTPConnection(netloc) elif schema == 'https': http = httplib.HTTPSConnection(netloc) else: raise AssertionError, "unsupported schema "+schema data = '' loglevel = log.INFO try: http.connect() http.putrequest("POST", url) http.putheader('Content-type', 'multipart/form-data; boundary=%s'%boundary) http.putheader('Content-length', str(len(body))) http.putheader('Authorization', auth) http.endheaders() http.send(body) except socket.error, e: self.announce(str(e), log.ERROR) return r = http.getresponse() if r.status == 200: self.announce('Server response (%s): %s' % (r.status, r.reason), log.INFO) else: self.announce('Upload failed (%s): %s' % (r.status, r.reason), log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75
Save
cmd:
run