예제 #1
0
파일: process.py 프로젝트: Dohxis/lever
 def spawnv(path, args): 
     pathname = pathobj.to_path(path)
     path = pathobj.os_stringify(pathname).encode('utf-8')
     argv = []
     for arg in args.contents:
         if isinstance(arg, pathobj.Path):
             argv.append(pathobj.os_stringify(arg).encode('utf-8'))
         else:
             argv.append(as_cstring(arg))
     pid = os.spawnv(os.P_NOWAIT, path, argv)
     return Integer(pid)
예제 #2
0
파일: process.py 프로젝트: whitten/lever
 def spawnv(path, args):
     pathname = pathobj.to_path(path)
     path = pathobj.os_stringify(pathname).encode('utf-8')
     argv = []
     for arg in args.contents:
         if isinstance(arg, pathobj.Path):
             argv.append(pathobj.os_stringify(arg).encode('utf-8'))
         else:
             argv.append(as_cstring(arg))
     pid = os.spawnv(os.P_NOWAIT, path, argv)
     return Integer(pid)
예제 #3
0
파일: fs.py 프로젝트: whitten/lever
def getctime(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    try:
        return Float(os.path.getctime(path))
    except IOError as error:
        raise ioerror(pathname, error)
예제 #4
0
파일: fs.py 프로젝트: Dohxis/lever
def getctime(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    try:
        return Float(os.path.getctime(path))
    except IOError as error:
        raise ioerror(pathname, error)
예제 #5
0
파일: bon.py 프로젝트: whitten/lever
def open_file(pathname):
    name = pathobj.os_stringify(pathname).encode('utf-8')
    try:
        fd = rfile.create_file(name, 'rb')
        try:
            return load(fd)
        finally:
            fd.close()
    except IOError as error:
        message = os.strerror(error.errno).decode('utf-8')
        raise OldError(u"%s: %s" % (pathobj.stringify(pathname), message))
예제 #6
0
파일: fs.py 프로젝트: whitten/lever
def open_(argv):
    if len(argv) < 1:
        raise OldError(u"too few arguments to fs.open()")
    pathname = pathobj.to_path(argv[0])
    path = pathobj.os_stringify(pathname).encode('utf-8')
    if len(argv) > 1:
        mode = as_cstring(argv[1])
        mode += 'b'
    else:
        mode = 'rb'
    try:
        return File(rfile.create_file(path, 'rb'))
    except IOError as error:
        raise ioerror(pathname, error)
예제 #7
0
파일: fs.py 프로젝트: Dohxis/lever
def open_(argv):
    if len(argv) < 1:
        raise OldError(u"too few arguments to fs.open()")
    pathname = pathobj.to_path(argv[0])
    path = pathobj.os_stringify(pathname).encode('utf-8')
    if len(argv) > 1:
        mode = as_cstring(argv[1])
        mode += 'b'
    else:
        mode = 'rb'
    try:
        return File(rfile.create_file(path, 'rb'))
    except IOError as error:
        raise ioerror(pathname, error)
예제 #8
0
파일: process.py 프로젝트: whitten/lever
def which(program):
    if isinstance(program, String):
        if program.string.count(u"/") > 0:
            program = pathobj.to_path(program)
    if isinstance(program, pathobj.Path):
        path = pathobj.os_stringify(program).encode('utf-8')
        if is_exe(path):
            return pathobj.concat(pathobj.getcwd(), program)
        return null
    elif not isinstance(program, String):
        raise OldError(u"string or path expected to .which()")
    program = as_cstring(program)
    for path in os.environ.get("PATH").split(os.pathsep):
        path = path.strip('"')
        exe_file = os.path.join(path, program)
        if is_exe(exe_file):
            return from_cstring(exe_file)
    return null
예제 #9
0
파일: process.py 프로젝트: Dohxis/lever
def which(program):
    if isinstance(program, String):
        if program.string.count(u"/") > 0:
            program = pathobj.to_path(program)
    if isinstance(program, pathobj.Path):
        path = pathobj.os_stringify(program).encode('utf-8')
        if is_exe(path):
            return pathobj.concat(pathobj.getcwd(), program)
        return null
    elif not isinstance(program, String):
        raise OldError(u"string or path expected to .which()")
    program = as_cstring(program)
    for path in os.environ.get("PATH").split(os.pathsep):
        path = path.strip('"')
        exe_file = os.path.join(path, program)
        if is_exe(exe_file):
            return from_cstring(exe_file)
    return null
예제 #10
0
파일: fs.py 프로젝트: whitten/lever
def stat(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    try:
        s = os.stat(path)
    except IOError as error:
        raise ioerror(pathname, error)
    return Exnihilo({
        u"st_mode": Integer(s.st_mode),
        u"st_ino": Integer(s.st_ino),
        u"st_dev": Integer(s.st_dev),
        u"st_nlink": Integer(s.st_nlink),
        u"st_uid": Integer(s.st_uid),
        u"st_gid": Integer(s.st_gid),
        u"st_size": Integer(s.st_size),
        u"st_atime": Float(s.st_atime),
        u"st_mtime": Float(s.st_mtime),
        u"st_ctime": Float(s.st_ctime),
    })
예제 #11
0
파일: fs.py 프로젝트: Dohxis/lever
def stat(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    try:
        s = os.stat(path)
    except IOError as error:
        raise ioerror(pathname, error)
    return Exnihilo({
        u"st_mode": Integer(s.st_mode),
        u"st_ino": Integer(s.st_ino),
        u"st_dev": Integer(s.st_dev),
        u"st_nlink": Integer(s.st_nlink),
        u"st_uid": Integer(s.st_uid),
        u"st_gid": Integer(s.st_gid),
        u"st_size": Integer(s.st_size),
        u"st_atime": Float(s.st_atime),
        u"st_mtime": Float(s.st_mtime),
        u"st_ctime": Float(s.st_ctime),
    })
예제 #12
0
파일: fs.py 프로젝트: whitten/lever
def read_file(argv):
    if len(argv) < 1:
        raise OldError(u"too few arguments to fs.read_file()")
    pathname = pathobj.to_path(argv[0])
    path = pathobj.os_stringify(pathname).encode('utf-8')
    convert = from_cstring
    if len(argv) > 1:
        for ch in as_cstring(argv[1]):
            if ch == 'b':
                convert = to_uint8array
            else:
                raise OldError(u"unknown mode string action")
    try:
        fd = rfile.create_file(path, 'rb')
        try:
            return convert(fd.read())
        finally:
            fd.close()
    except IOError as error:
        raise ioerror(pathname, error)
예제 #13
0
파일: fs.py 프로젝트: Dohxis/lever
def read_file(argv):
    if len(argv) < 1:
        raise OldError(u"too few arguments to fs.read_file()")
    pathname = pathobj.to_path(argv[0])
    path = pathobj.os_stringify(pathname).encode('utf-8')
    convert = from_cstring
    if len(argv) > 1:
        for ch in as_cstring(argv[1]):
            if ch == 'b':
                convert = to_uint8array
            else:
                raise OldError(u"unknown mode string action")
    try:
        fd = rfile.create_file(path, 'rb')
        try:
            return convert(fd.read())
        finally:
            fd.close()
    except IOError as error:
        raise ioerror(pathname, error)
예제 #14
0
파일: fs.py 프로젝트: whitten/lever
def exists(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    return boolean(os.path.exists(path))
예제 #15
0
파일: fs.py 프로젝트: Dohxis/lever
def exists(path):
    pathname = pathobj.to_path(path)
    path = pathobj.os_stringify(pathname).encode('utf-8')
    return boolean(os.path.exists(path))