darwin.py 文件源码

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

项目:FMoviesPlus.bundle 作者: coder-alpha 项目源码 文件源码
def _get_localzone(_root='/'):
    with Popen(
        "systemsetup -gettimezone",
        shell=True,
        stderr=subprocess.PIPE,
        stdout=subprocess.PIPE
    ) as pipe:
        tzname = pipe.stdout.read().replace(b'Time Zone: ', b'').strip()

    if not tzname or tzname not in pytz.all_timezones_set:
        # link will be something like /usr/share/zoneinfo/America/Los_Angeles.
        link = os.readlink(os.path.join(_root, "etc/localtime"))
        tzname = link[link.rfind("zoneinfo/") + 9:]

    return pytz.timezone(tzname)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号