kopia lustrzana https://github.com/micropython/micropython-lib
upip: Update dependency modules.
rodzic
4a1961d465
commit
fd63aa84f1
|
@ -4,12 +4,12 @@ all:
|
||||||
# self-contained install
|
# self-contained install
|
||||||
deps: upip__libc.py upip_os.py upip_os_path.py upip_errno.py upip_gzip.py upip_stat.py upip_utarfile.py
|
deps: upip__libc.py upip_os.py upip_os_path.py upip_errno.py upip_gzip.py upip_stat.py upip_utarfile.py
|
||||||
|
|
||||||
upip__libc.py: ../_libc/_libc.py
|
upip_ffilib.py: ../ffilib/ffilib.py
|
||||||
cp $^ $@
|
cp $^ $@
|
||||||
upip_os.py: ../os/os/__init__.py
|
upip_os.py: ../os/os/__init__.py
|
||||||
sed -r -e 's/((_libc|errno|stat)([^_"]|$$))/upip_\1/' $^ >$@
|
sed -r -e 's/((ffilib|errno|stat)([^_"]|$$))/upip_\1/' $^ >$@
|
||||||
upip_os_path.py: ../os.path/os/path.py
|
upip_os_path.py: ../os.path/os/path.py
|
||||||
sed -r -e 's/((_libc|errno|os|stat)([^_"]|$$))/upip_\1/' $^ >$@
|
sed -r -e 's/((ffilib|errno|os|stat)([^_"]|$$))/upip_\1/' $^ >$@
|
||||||
upip_errno.py: ../errno/errno.py
|
upip_errno.py: ../errno/errno.py
|
||||||
cp $^ $@
|
cp $^ $@
|
||||||
upip_gzip.py: ../gzip/gzip.py
|
upip_gzip.py: ../gzip/gzip.py
|
||||||
|
|
|
@ -3,16 +3,30 @@ import array
|
||||||
import ustruct as struct
|
import ustruct as struct
|
||||||
import upip_errno
|
import upip_errno
|
||||||
import upip_stat as stat_
|
import upip_stat as stat_
|
||||||
import upip__libc
|
import upip_ffilib
|
||||||
try:
|
try:
|
||||||
from _os import *
|
from _os import *
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
libc = upip__libc.get()
|
libc = upip_ffilib.libc()
|
||||||
|
|
||||||
|
try:
|
||||||
|
errno__ = libc.var("i", "errno")
|
||||||
|
def errno_(val=None):
|
||||||
|
if val is None:
|
||||||
|
return errno__.get()
|
||||||
|
errno__.set(val)
|
||||||
|
except OSError:
|
||||||
|
__upip_errno = libc.func("p", "__errno", "")
|
||||||
|
def errno_(val=None):
|
||||||
|
if val is None:
|
||||||
|
p = __upip_errno()
|
||||||
|
buf = ffi.as_bytearray(p, 4)
|
||||||
|
return int.from_bytes(buf)
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
errno_ = libc.var("i", "errno")
|
|
||||||
chdir_ = libc.func("i", "chdir", "s")
|
chdir_ = libc.func("i", "chdir", "s")
|
||||||
mkdir_ = libc.func("i", "mkdir", "si")
|
mkdir_ = libc.func("i", "mkdir", "si")
|
||||||
rename_ = libc.func("i", "rename", "ss")
|
rename_ = libc.func("i", "rename", "ss")
|
||||||
|
@ -62,7 +76,7 @@ def check_error(ret):
|
||||||
# Return True is error was EINTR (which usually means that OS call
|
# Return True is error was EINTR (which usually means that OS call
|
||||||
# should be restarted).
|
# should be restarted).
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
e = errno_.get()
|
e = errno_()
|
||||||
if e == upip_errno.EINTR:
|
if e == upip_errno.EINTR:
|
||||||
return True
|
return True
|
||||||
raise OSError(e)
|
raise OSError(e)
|
||||||
|
@ -223,5 +237,6 @@ def fsdecode(s):
|
||||||
|
|
||||||
|
|
||||||
def urandom(n):
|
def urandom(n):
|
||||||
with open("/dev/urandom", "rb") as f:
|
import builtins
|
||||||
|
with builtins.open("/dev/urandom", "rb") as f:
|
||||||
return f.read(n)
|
return f.read(n)
|
||||||
|
|
|
@ -8,7 +8,9 @@ def normpath(s):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def abspath(s):
|
def abspath(s):
|
||||||
|
if s[0] != "/":
|
||||||
return upip_os.getcwd() + "/" + s
|
return upip_os.getcwd() + "/" + s
|
||||||
|
return s
|
||||||
|
|
||||||
def join(*args):
|
def join(*args):
|
||||||
# TODO: this is non-compliant
|
# TODO: this is non-compliant
|
||||||
|
|
Ładowanie…
Reference in New Issue