forked from github.com/pypiserver
merge vsajip's support for verify, doc_upload and remove_pkg
This commit is contained in:
commit
244f3eb85a
@ -1,4 +1,9 @@
|
|||||||
import sys, os, itertools
|
import sys, os, itertools, zipfile
|
||||||
|
|
||||||
|
try:
|
||||||
|
from io import BytesIO
|
||||||
|
except ImportError:
|
||||||
|
from StringIO import StringIO as BytesIO
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
@ -114,11 +119,39 @@ def update():
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise HTTPError(400, output=":action field not found")
|
raise HTTPError(400, output=":action field not found")
|
||||||
|
|
||||||
if action == "submit":
|
if action in ("verify", "submit"):
|
||||||
|
return ""
|
||||||
|
|
||||||
|
if action == "doc_upload":
|
||||||
|
try:
|
||||||
|
content = request.files['content']
|
||||||
|
except KeyError:
|
||||||
|
raise HTTPError(400, output="content file field not found")
|
||||||
|
zip_data = content.file.read()
|
||||||
|
try:
|
||||||
|
zf = zipfile.ZipFile(BytesIO(zip_data))
|
||||||
|
info = zf.getinfo('index.html')
|
||||||
|
except Exception:
|
||||||
|
raise HTTPError(400, output="not a zip file")
|
||||||
|
return ""
|
||||||
|
|
||||||
|
if action == "remove_pkg":
|
||||||
|
name = request.forms.get("name")
|
||||||
|
version = request.forms.get("version")
|
||||||
|
if not name or not version:
|
||||||
|
raise HTTPError(400, "Name or version not specified")
|
||||||
|
found = None
|
||||||
|
for pkg in find_packages(packages()):
|
||||||
|
if pkg.pkgname == name and pkg.version == version:
|
||||||
|
found = pkg
|
||||||
|
break
|
||||||
|
if found is None:
|
||||||
|
raise HTTPError(404, "%s (%s) not found" % (name, version))
|
||||||
|
os.unlink(found.fn)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if action != "file_upload":
|
if action != "file_upload":
|
||||||
raise HTTPError(400, output="actions other than file_upload/submit, not supported")
|
raise HTTPError(400, output="action not supported: %s" % action)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = request.files['content']
|
content = request.files['content']
|
||||||
|
Loading…
Reference in New Issue
Block a user