main.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:SDPremote 作者: MartinBienz 项目源码 文件源码
def writetldirs(handler):
    mydirs=gettldirs(timelapsedir)

    content=[]

    for item in mydirs:

        fcount = len([name for name in os.listdir(item) if os.path.isfile(os.path.join(item,name))])
        totsize = helpers.bytes2human(sum(os.path.getsize(os.path.join(item,name)) for name in os.listdir(item) if os.path.isfile(os.path.join(item,name))))

        if not fcount == 0:
            thumbnail=sorted([ name for name in os.listdir(item) if os.path.isfile(os.path.join(item,name))])[-1]
        else:
            thumbnail="../../images/nocam.png"

        info = {
        "directory":    item,
        "count": fcount,
        "size":  totsize,
        "thumbnail": thumbnail,
        }
        content.append(info)

    handler.write(json.dumps({"info": content}))

#webserver------------------------------------------------------------------------------------------------------------
#WebsocketHandler HTML5 and other websocket capable clients
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号