upip: Try to detect and report package noy found condition.

Doesn't work to well while using wget, may be mixed up with another
server error.
pull/35/head
Paul Sokolovsky 2015-06-25 01:38:15 +03:00
rodzic 8b14946b1c
commit f568238a0f
1 zmienionych plików z 26 dodań i 15 usunięć

Wyświetl plik

@ -32,6 +32,9 @@ DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
debug = False
cleanup_files = [".pkg.tar"]
class NotFoundError(Exception):
pass
def save_file(fname, subf):
outf = open(fname, "wb")
while True:
@ -84,9 +87,13 @@ def expandhome(s):
return s
def download(url, local_name):
os.system("wget -q %s -O %s" % (url, local_name))
if debug:
print("wget -q %s -O %s" % (url, local_name))
rc = os.system("wget -q %s -O %s" % (url, local_name))
if local_name not in cleanup_files:
cleanup_files.append(local_name)
if rc == 8 * 256:
raise NotFoundError
def get_pkg_metadata(name):
download("https://pypi.python.org/pypi/%s/json" % name, ".pkg.json")
@ -198,6 +205,7 @@ def main():
# sets would be perfect here, but don't depend on them
installed = []
try:
while to_install:
if debug:
print("Queue:", to_install)
@ -212,6 +220,9 @@ def main():
if deps:
deps = deps.decode("utf-8").split("\n")
to_install.extend(deps)
except NotFoundError:
print("Error: cannot find '%s' package (or server error), packages may be partially installed" \
% pkg_spec, file=sys.stderr)
if not debug:
cleanup()