gsuite2mfe.py 文件源码

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

项目:gsuite2mfe 作者: andywalden 项目源码 文件源码
def read(self):
        """ 
        Returns RFC 3339 timestamp string. Tries to read given file.
        If file cannot be read, current time is returned.
        """
        logging.debug("Looking for bookmark file")
        try:
            if os.path.getsize(self.bmfile) < 10:
                logging.error("Bookmark file appears corrupt: %s", self.bmfile)
                self._generate_bm_time()
                return self.s_time

        except FileNotFoundError:
            logging.debug("Bookmark file not found: %s.", self.bmfile)
            self._generate_bm_time()
            return self.s_time

        try:
            with open(self.bmfile, 'r') as self.open_bmfile:
                logging.debug("Opening: %s", self.bmfile)
                self.bookmark = self.open_bmfile.read()
                logging.debug("File found. Reading timestamp: %s", 
                                convert_time(self.bookmark))
                if validate_time('s', self.bookmark):
                    logging.debug("Bookmark time is valid")
                    self.s_time = self.bookmark
                    return self.s_time
                else:
                    logging.error("Invalid bookmark data. Using current time")
                    self._generate_bm_time()
                    return self.s_time
        except OSError:
            logging.debug("Bookmark file cannot be accessed: %s.", self.bmfile)
            self._generate_bm_time()
            return self.s_time
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号