def __init__(self): self.dbname = util.absolute_path("rss.db") self.sqlfile = util.absolute_path("rss.sql") if self.__need_create_table(): conn, cursor = self.__open() with open(self.sqlfile, 'r') as f: sql = f.read() cursor.executescript(sql) conn.commit() self.__close(cursor, conn)
def dump(self): if (self.__dumped): return self.__dumped = True logging.info("保存数据") with open(absolute_path("database.json"), "w", encoding="UTF-8") as f: json.dump(self.data, f, ensure_ascii=False)
#!/usr/bin/python3 import configparser import logging import sys import util from rssbot import RSSBot from rssdata import Settings if __name__ == '__main__': _level = Settings().get_log_level() _format = "%(asctime)s - %(message)s" _filename = util.absolute_path("rss.log") _filemode = "a" logging.basicConfig(level=_level, format=_format, filename=_filename, filemode=_filemode) bot = RSSBot() bot.run()
def load(self): if self.__loaded: return self.__loaded = True self.data = self.__restore(absolute_path("database.json"))
def __init__(self): self.config = configparser.ConfigParser() self.config.read(absolute_path('conf.ini'))
def dump(self): with open(absolute_path("database.json"), "w", encoding="UTF-8") as f: json.dump(self.data, f, ensure_ascii=False)
#!/usr/bin/python3 import logging import util from moyubot import MoyuBot if __name__ == '__main__': _level = logging.INFO _format = "%(asctime)s - %(message)s" _filename = util.absolute_path("moyu.log") _filemode = "a" logging.basicConfig(level=_level, format=_format, filename=_filename, filemode=_filemode) bot: MoyuBot = MoyuBot() bot.run()