kopia lustrzana https://github.com/micropython/micropython-lib
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
rodzic
8b14946b1c
commit
f568238a0f
41
upip/upip.py
41
upip/upip.py
|
@ -32,6 +32,9 @@ DEFAULT_MICROPYPATH = "~/.micropython/lib:/usr/lib/micropython"
|
||||||
debug = False
|
debug = False
|
||||||
cleanup_files = [".pkg.tar"]
|
cleanup_files = [".pkg.tar"]
|
||||||
|
|
||||||
|
class NotFoundError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def save_file(fname, subf):
|
def save_file(fname, subf):
|
||||||
outf = open(fname, "wb")
|
outf = open(fname, "wb")
|
||||||
while True:
|
while True:
|
||||||
|
@ -84,9 +87,13 @@ def expandhome(s):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def download(url, local_name):
|
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:
|
if local_name not in cleanup_files:
|
||||||
cleanup_files.append(local_name)
|
cleanup_files.append(local_name)
|
||||||
|
if rc == 8 * 256:
|
||||||
|
raise NotFoundError
|
||||||
|
|
||||||
def get_pkg_metadata(name):
|
def get_pkg_metadata(name):
|
||||||
download("https://pypi.python.org/pypi/%s/json" % name, ".pkg.json")
|
download("https://pypi.python.org/pypi/%s/json" % name, ".pkg.json")
|
||||||
|
@ -198,20 +205,24 @@ def main():
|
||||||
|
|
||||||
# sets would be perfect here, but don't depend on them
|
# sets would be perfect here, but don't depend on them
|
||||||
installed = []
|
installed = []
|
||||||
while to_install:
|
try:
|
||||||
if debug:
|
while to_install:
|
||||||
print("Queue:", to_install)
|
if debug:
|
||||||
pkg_spec = to_install.pop(0)
|
print("Queue:", to_install)
|
||||||
if pkg_spec in installed:
|
pkg_spec = to_install.pop(0)
|
||||||
continue
|
if pkg_spec in installed:
|
||||||
meta = install_pkg(pkg_spec, install_path)
|
continue
|
||||||
installed.append(pkg_spec)
|
meta = install_pkg(pkg_spec, install_path)
|
||||||
if debug:
|
installed.append(pkg_spec)
|
||||||
print(meta)
|
if debug:
|
||||||
deps = meta.get("deps", "").rstrip()
|
print(meta)
|
||||||
if deps:
|
deps = meta.get("deps", "").rstrip()
|
||||||
deps = deps.decode("utf-8").split("\n")
|
if deps:
|
||||||
to_install.extend(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:
|
if not debug:
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
Ładowanie…
Reference in New Issue