当前位置: 首页>>代码示例>>Python>>正文


Python uos.stat方法代码示例

本文整理汇总了Python中uos.stat方法的典型用法代码示例。如果您正苦于以下问题:Python uos.stat方法的具体用法?Python uos.stat怎么用?Python uos.stat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uos的用法示例。


在下文中一共展示了uos.stat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_description

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def make_description(self, path, fname, full):
        global _month_name
        if full:
            stat = uos.stat(self.get_absolute_path(path, fname))
            file_permissions = ("drwxr-xr-x"
                                if (stat[0] & 0o170000 == 0o040000)
                                else "-rw-r--r--")
            file_size = stat[6]
            tm = localtime(stat[7])
            if tm[0] != localtime()[0]:
                description = "{} 1 owner group {:>10} {} {:2} {:>5} {}\r\n".\
                    format(file_permissions, file_size,
                           _month_name[tm[1]], tm[2], tm[0], fname)
            else:
                description = "{} 1 owner group {:>10} {} {:2} {:02}:{:02} {}\r\n".\
                    format(file_permissions, file_size,
                           _month_name[tm[1]], tm[2], tm[3], tm[4], fname)
        else:
            description = fname + "\r\n"
        return description 
开发者ID:robert-hh,项目名称:FTP-Server-for-ESP8266-ESP32-and-PYBD,代码行数:22,代码来源:uftpd.py

示例2: filesize

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def filesize(fname):
    if isfile(fname):
        return os.stat(fname)[6]
    else:
        return None 
开发者ID:m5stack,项目名称:UIFlow-Code,代码行数:7,代码来源:utils.py

示例3: startup

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def startup(timer=None):
    conf = Config('global')
    for app in uos.listdir('/apps'):
        try:
            uos.stat('/apps/{}/boot.py'.format(app))
        except OSError:
            pass
        else:
            execfile('/apps/{}/boot.py'.format(app))
            gc.collect()
    del conf
    gc.collect() 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:14,代码来源:util.py

示例4: download_file

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def download_file(url, filename=None):
    if filename is None:
        filename = url.split('/')[-1]

    print('Downloading file from {}.'.format(url))
    print('It will be saved as \'{}\''.format(filename))

    try:
        st = uos.stat(filename)
        raise Exception('Already exist file')
    except OSError:
        pass

    if not wait_network(5):
        raise Exception('Not connected: check your internet')

    gc.collect()

    s = upip.url_open(url)
    s.setblocking(False)

    with open(filename, 'w') as f:
        BUF_LEN = 256
        try:
            while True:
                data = s.read(BUF_LEN)
                print('.',end='')
                # print(data,end='')
                if data is None or len(data) < BUF_LEN:
                    break
                f.write(data)
        except Exception as e:
            s.close()
            f.close()
            raise e

    s.close()
    print('') 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:40,代码来源:util.py

示例5: save

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def save(self):
        # Create config_dir if do not exists
        try:
            uos.stat(self.config_dir)
        except OSError:
            uos.mkdir(self.config_dir)
        with open('{}/{}.json'.format(self.config_dir, self.name), 'w') as fp:
            json.dump(self.data, fp) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:10,代码来源:util.py

示例6: make_description

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def make_description(self, path, fname, full):
        if full:
            stat = uos.stat(self.get_absolute_path(path,fname))
            file_permissions = "drwxr-xr-x" if (stat[0] & 0o170000 == 0o040000) else "-rw-r--r--"
            file_size = stat[6]
            description = "{}    1 owner group {:>10} Jan 1 2000 {}\r\n".format(
                    file_permissions, file_size, fname)
        else:
            description = fname + "\r\n"
        return description 
开发者ID:lemariva,项目名称:uPyPortal,代码行数:12,代码来源:ftp.py

示例7: exists

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def exists(path):
    try:
        uos.stat(path)
        return True
    except OSError:
        return False 
开发者ID:fadushin,项目名称:esp8266,代码行数:8,代码来源:file_handler.py

示例8: file_size

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def file_size(path):
        return uos.stat(path)[6] 
开发者ID:fadushin,项目名称:esp8266,代码行数:4,代码来源:file_handler.py

示例9: make_description

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def make_description(path, fname, full):
    if full:
        stat = uos.stat(get_absolute_path(path, fname))
        file_permissions = ("drwxr-xr-x"
                            if (stat[0] & 0o170000 == 0o040000)
                            else "-rw-r--r--")
        file_size = stat[6]
        description = "{}    1 owner group {:>10} Jan 1 2000 {}\r\n".format(
                file_permissions, file_size, fname)
    else:
        description = fname + "\r\n"
    return description 
开发者ID:robert-hh,项目名称:FTP-Server-for-ESP8266-ESP32-and-PYBD,代码行数:14,代码来源:ftp.py

示例10: make_description

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def make_description(path, fname, full):
    if full:
        stat = uos.stat(get_absolute_path(path, fname))
        file_permissions = "drwxr-xr-x"\
            if (stat[0] & 0o170000 == 0o040000)\
            else "-rw-r--r--"
        file_size = stat[6]
        description = "{}    1 owner group {:>10} Jan 1 2000 {}\r\n".format(
                file_permissions, file_size, fname)
    else:
        description = fname + "\r\n"
    return description 
开发者ID:robert-hh,项目名称:FTP-Server-for-ESP8266-ESP32-and-PYBD,代码行数:14,代码来源:ftp_thread.py

示例11: send_file

# 需要导入模块: import uos [as 别名]
# 或者: from uos import stat [as 别名]
def send_file(self, filename, content_type=None, content_encoding=None, max_age=2592000):
        """Send local file as HTTP response.
        This function is generator.

        Arguments:
            filename - Name of file which exists in local filesystem
        Keyword arguments:
            content_type - Filetype. By default - None means auto-detect.
            max_age - Cache control. How long browser can keep this file on disk.
                      By default - 30 days
                      Set to 0 - to disable caching.

        Example 1: Default use case:
            await resp.send_file('images/cat.jpg')

        Example 2: Disable caching:
            await resp.send_file('static/index.html', max_age=0)

        Example 3: Override content type:
            await resp.send_file('static/file.bin', content_type='application/octet-stream')
        """
        try:
            # Get file size
            stat = os.stat(filename)
            slen = str(stat[6])
            self.add_header('Content-Length', slen)
            # Find content type
            if content_type:
                self.add_header('Content-Type', content_type)
            # Add content-encoding, if any
            if content_encoding:
                self.add_header('Content-Encoding', content_encoding)
            # Since this is static content is totally make sense
            # to tell browser to cache it, however, you can always
            # override it by setting max_age to zero
            self.add_header('Cache-Control', 'max-age={}, public'.format(max_age))
            with open(filename) as f:
                await self._send_headers()
                gc.collect()
                buf = bytearray(128)
                while True:
                    size = f.readinto(buf)
                    if size == 0:
                        break
                    await self.send(buf, sz=size)
        except OSError as e:
            # special handling for ENOENT / EACCESS
            if e.args[0] in (errno.ENOENT, errno.EACCES):
                raise HTTPException(404)
            else:
                raise 
开发者ID:belyalov,项目名称:tinyweb,代码行数:53,代码来源:server.py


注:本文中的uos.stat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。