fetcher.py 文件源码

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

项目:iconograph 作者: robot-tools 项目源码 文件源码
def _SetCurrent(self, image):
    filename = '%d.iso' % (image['timestamp'])
    path = os.path.join(self._image_dir, filename)
    current_path = os.path.join(self._image_dir, 'current')

    try:
      link = os.readlink(current_path)
      link_path = os.path.join(self._image_dir, link)
      if link_path == path:
        return
    except FileNotFoundError:
      pass

    print('Changing current link to:', filename, flush=True)
    temp_path = tempfile.mktemp(dir=self._image_dir)
    os.symlink(filename, temp_path)
    os.rename(temp_path, current_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号