mirror of
https://github.com/tgbot-collection/YYeTsBot.git
synced 2025-11-25 19:37:34 +08:00
remove os.path
This commit is contained in:
@@ -4,20 +4,15 @@
|
||||
|
||||
__author__ = 'Benny <benny.think@gmail.com>'
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pickle
|
||||
import sys
|
||||
import pathlib
|
||||
|
||||
import redis
|
||||
import requests
|
||||
|
||||
from config import AJAX_LOGIN, PASSWORD, REDIS, USERNAME
|
||||
from config import REDIS
|
||||
|
||||
r = redis.StrictRedis(host=REDIS, decode_responses=True)
|
||||
|
||||
cookie_file = os.path.join(os.path.dirname(__file__), 'data', 'cookies.dump')
|
||||
cookie_file = pathlib.Path(__file__).parent / 'data' / 'cookies.dump'
|
||||
|
||||
|
||||
def save_error_dump(uid, err: str):
|
||||
|
||||
@@ -22,7 +22,7 @@ from hashlib import sha1
|
||||
from http import HTTPStatus
|
||||
|
||||
import filetype
|
||||
import requests
|
||||
import pathlib
|
||||
from tornado import escape, gen, web
|
||||
from tornado.concurrent import run_on_executor
|
||||
|
||||
@@ -38,8 +38,7 @@ else:
|
||||
|
||||
logging.info("%s Running with %s. %s", "#" * 10, adapter, "#" * 10)
|
||||
|
||||
static_path = os.path.join(os.path.dirname(__file__), 'templates')
|
||||
index = os.path.join(static_path, "index.html")
|
||||
index = pathlib.Path(__file__).parent.joinpath("templates", "index.html").as_posix()
|
||||
|
||||
|
||||
class BaseHandler(web.RequestHandler):
|
||||
@@ -766,13 +765,13 @@ class DBDumpHandler(BaseHandler):
|
||||
result = {}
|
||||
data = self.file_info(file_list)
|
||||
for file, value in data.items():
|
||||
filename = os.path.basename(file)
|
||||
filename = pathlib.Path(file).name
|
||||
result[filename] = {
|
||||
"checksum": value[0],
|
||||
"date": value[1],
|
||||
"size": value[2],
|
||||
}
|
||||
|
||||
print(result)
|
||||
return result
|
||||
|
||||
@gen.coroutine
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/local/bin/python3
|
||||
# coding: utf-8
|
||||
|
||||
# YYeTsBot - convert_to_sqlite.py
|
||||
# 6/17/21 12:41
|
||||
#
|
||||
|
||||
__author__ = "Benny <benny.think@gmail.com>"
|
||||
|
||||
import json
|
||||
import pymysql
|
||||
|
||||
import pymongo
|
||||
|
||||
mongo = pymongo.MongoClient()
|
||||
yyets = mongo["zimuzu"]["yyets"]
|
||||
|
||||
con = pymysql.connect(host="mysql", user="root", password="root", charset="utf8mb4")
|
||||
cur = con.cursor()
|
||||
cur.execute("create database zimuzu")
|
||||
cur.execute("use zimuzu")
|
||||
TABLE_SQL = """
|
||||
CREATE TABLE IF NOT EXISTS yyets
|
||||
(
|
||||
id int,
|
||||
cnname text,
|
||||
enname text,
|
||||
aliasname text,
|
||||
views int,
|
||||
data longtext
|
||||
);
|
||||
"""
|
||||
cur.execute(TABLE_SQL)
|
||||
|
||||
INSERT_SQL = """
|
||||
INSERT INTO yyets VALUES (%s, %s, %s, %s ,%s, %s);
|
||||
"""
|
||||
for resource in yyets.find(projection={"_id": False}):
|
||||
resource_id = resource["data"]["info"]["id"]
|
||||
cnname = resource["data"]["info"]["cnname"]
|
||||
enname = resource["data"]["info"]["enname"]
|
||||
aliasname = resource["data"]["info"]["aliasname"]
|
||||
views = resource["data"]["info"]["views"]
|
||||
cur.execute(INSERT_SQL, (resource_id, cnname, enname, aliasname, views, json.dumps(resource, ensure_ascii=False)))
|
||||
|
||||
con.commit()
|
||||
con.close()
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/local/bin/python3
|
||||
# coding: utf-8
|
||||
|
||||
# YYeTsBot - convert_to_sqlite.py
|
||||
# 6/17/21 12:41
|
||||
#
|
||||
|
||||
__author__ = "Benny <benny.think@gmail.com>"
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
import pymongo
|
||||
|
||||
mongo = pymongo.MongoClient()
|
||||
yyets = mongo["zimuzu"]["yyets"]
|
||||
|
||||
con = sqlite3.connect("yyets.sqlite")
|
||||
cur = con.cursor()
|
||||
|
||||
TABLE_SQL = """
|
||||
CREATE TABLE IF NOT EXISTS yyets
|
||||
(
|
||||
id int,
|
||||
cnname text,
|
||||
enname text,
|
||||
aliasname text,
|
||||
views int,
|
||||
data text
|
||||
);
|
||||
"""
|
||||
cur.execute(TABLE_SQL)
|
||||
|
||||
INSERT_SQL = """
|
||||
INSERT INTO yyets VALUES (?, ?, ?, ?, ?, ?);
|
||||
"""
|
||||
for resource in yyets.find(projection={"_id": False}):
|
||||
resource_id = resource["data"]["info"]["id"]
|
||||
cnname = resource["data"]["info"]["cnname"]
|
||||
enname = resource["data"]["info"]["enname"]
|
||||
aliasname = resource["data"]["info"]["aliasname"]
|
||||
views = resource["data"]["info"]["views"]
|
||||
cur.execute(INSERT_SQL, (resource_id, cnname, enname, aliasname, views, json.dumps(resource, ensure_ascii=False)))
|
||||
|
||||
con.commit()
|
||||
con.close()
|
||||
@@ -10,7 +10,7 @@ __author__ = "Benny <benny.think@gmail.com>"
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
|
||||
import pathlib
|
||||
import pytz
|
||||
import tornado.autoreload
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -38,8 +38,7 @@ if os.getenv("debug"):
|
||||
|
||||
|
||||
class RunServer:
|
||||
root_path = os.path.dirname(__file__)
|
||||
static_path = os.path.join(root_path, 'templates')
|
||||
static_path = pathlib.Path(__file__).parent.joinpath('templates')
|
||||
handlers = [
|
||||
(r'/', IndexHandler),
|
||||
(r'/api/resource', ResourceHandler),
|
||||
|
||||
Reference in New Issue
Block a user