update dependencies, enhance dump backup

This commit is contained in:
Benny
2022-12-30 18:58:23 +01:00
parent f67d41b5d6
commit 293fcfc922
3 changed files with 16 additions and 19 deletions

View File

@@ -1,15 +1,15 @@
requests==2.28.1
pytelegrambotapi==4.7.1
pytelegrambotapi==4.8.0
beautifulsoup4==4.11.1
tgbot-ping==1.0.4
redis==4.3.4
redis==4.4.0
apscheduler==3.9.1.post1
pymongo==4.3.3
tornado==6.2
captcha==0.4
passlib==1.7.4
fakeredis==2.1.0
pytz==2022.6
fakeredis==2.4.0
pytz==2022.7
filetype==1.2.0
requests[socks]
tqdm==4.64.1

View File

@@ -220,13 +220,18 @@ def zip_file():
def cleanup():
# this function will never occur any errors!
logging.info("Cleaning up...")
con = MySQL()
con.cursor().execute("drop database zimuzu")
con.close()
os.unlink(sqlite_file)
MongoDB().drop_database("share")
os.unlink("zimuzu.sql")
with contextlib.suppress(Exception):
con = MySQL()
con.cursor().execute("drop database zimuzu")
con.close()
with contextlib.suppress(Exception):
os.unlink(sqlite_file)
with contextlib.suppress(Exception):
MongoDB().drop_database("share")
with contextlib.suppress(Exception):
os.unlink("zimuzu.sql")
def entry_dump():
@@ -241,10 +246,5 @@ def entry_dump():
logging.info("Total time used: %.2fs" % (time.time() - t0))
def no_error_entry_dump():
with contextlib.suppress(Exception):
entry_dump()
if __name__ == '__main__':
entry_dump()

View File

@@ -11,7 +11,6 @@ import logging
import os
import pathlib
import platform
import threading
import pytz
import tornado.autoreload
@@ -21,6 +20,7 @@ from tornado import httpserver, ioloop, options, web
from tornado.log import enable_pretty_logging
import dump_db
from Mongo import OtherMongoResource, ResourceLatestMongoResource
from handler import (AnnouncementHandler, BlacklistHandler, CaptchaHandler,
CategoryHandler, CommentChildHandler, CommentHandler,
CommentNewestHandler, CommentReactionHandler,
@@ -32,7 +32,6 @@ from handler import (AnnouncementHandler, BlacklistHandler, CaptchaHandler,
ResourceLatestHandler, SpamProcessHandler, TopHandler,
UserEmailHandler, UserHandler)
from migration.douban_sync import sync_douban
from Mongo import OtherMongoResource, ResourceLatestMongoResource
from utils import Cloudflare
enable_pretty_logging()
@@ -110,8 +109,6 @@ if __name__ == "__main__":
scheduler.add_job(OtherMongoResource().import_ban_user, 'interval', seconds=300)
scheduler.add_job(cf.clear_fw, trigger=CronTrigger.from_crontab("0 0 */5 * *"))
scheduler.start()
logging.info("Triggering dump database now...")
threading.Thread(target=dump_db.no_error_entry_dump).start()
options.define("p", default=8888, help="running port", type=int)
options.define("h", default='127.0.0.1', help="listen address", type=str)