更改包路径

This commit is contained in:
MarkusJoe
2022-02-19 11:27:13 +08:00
parent fcb4c41f8e
commit 8c89f4a024
8 files changed
+33 -34

No files matched your search

+1 -1
View File
@@ -10,6 +10,6 @@ dist/
*.tar *.tar
*.gz *.gz
*.db *.db
!/db/count.db !/bin/db/count.db
*.log *.log
*.log.* *.log.*
+1 -1
View File
@@ -20,7 +20,7 @@ from bin.utils.error import ErrorProcess
from bin.utils.view import view_template from bin.utils.view import view_template
from bin.utils.logger import logger from bin.utils.logger import logger
from bin.utils.packlog import make_targz from bin.utils.packlog import make_targz
from db.sqlite import fetch_data from bin.db.sqlite import fetch_data
app = Flask(__name__, static_url_path='') app = Flask(__name__, static_url_path='')
app.config['JSON_SORT_KEYS'] = False # 设置JSON消息不根据字母顺序重新排序 app.config['JSON_SORT_KEYS'] = False # 设置JSON消息不根据字母顺序重新排序
+21 -21
View File
@@ -1,21 +1,21 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -- coding:utf-8 -- # -- coding:utf-8 --
# @Author: markushammered@gmail.com # @Author: markushammered@gmail.com
# @Development Tool: PyCharm # @Development Tool: PyCharm
# @Create Time: 2022/2/4 # @Create Time: 2022/2/4
# @File Name: __init__.py.py # @File Name: __init__.py.py
import os import os
from bin.utils.logger import logger from bin.utils.logger import logger
if not os.path.exists('./db/count.db'): if not os.path.exists('./db/count.db'):
logger.error('未检测到用户计数数据库') logger.error('未检测到用户计数数据库')
import sqlite3 import sqlite3
conn = sqlite3.connect('./db/count.db', check_same_thread=False) conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('create table ReqCount (name text primary key, times int)') cursor.execute('create table ReqCount (name text primary key, times int)')
conn.commit() conn.commit()
cursor.close() cursor.close()
conn.close() conn.close()
logger.info('已在./db 目录下创建了count.db数据库') logger.info('已在./db 目录下创建了count.db数据库')
View File
File renamed without changes.
+5 -5
View File
@@ -15,7 +15,7 @@ def insert_data(name: str) -> None:
:param name: :param name:
:return: :return:
""" """
conn = sqlite3.connect('./db/count.db', check_same_thread=False) conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
cursor = conn.cursor() cursor = conn.cursor()
try: try:
cursor.execute('insert into ReqCount values(?, ?)', (name, 1)) cursor.execute('insert into ReqCount values(?, ?)', (name, 1))
@@ -31,7 +31,7 @@ def fetch_data(name: str) -> int:
:param name: :param name:
:return: :return:
""" """
conn = sqlite3.connect('./db/count.db', check_same_thread=False) conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
cursor = conn.cursor() cursor = conn.cursor()
try: try:
cursor.execute('select * from ReqCount') cursor.execute('select * from ReqCount')
@@ -64,7 +64,7 @@ def update_data(name: str, times: int) -> None:
:param times: :param times:
:return: :return:
""" """
conn = sqlite3.connect('./db/count.db', check_same_thread=False) conn = sqlite3.connect('./bin/db/count.db', check_same_thread=False)
cursor = conn.cursor() cursor = conn.cursor()
try: try:
times += 1 times += 1
@@ -80,7 +80,7 @@ def fetch_table() -> list:
返回已有主题列表 返回已有主题列表
:return: :return:
""" """
conn_temp = sqlite3.connect('./db/style.db', check_same_thread=False) conn_temp = sqlite3.connect('./bin/db/style.db', check_same_thread=False)
cursor_temp = conn_temp.cursor() cursor_temp = conn_temp.cursor()
try: try:
lst = [] lst = []
@@ -99,7 +99,7 @@ def fetch_style_data(style: str) -> list[dict[str, Any]]:
:param style: :param style:
:return: :return:
""" """
conn = sqlite3.connect('./db/style.db', check_same_thread=False) conn = sqlite3.connect('./bin/db/style.db', check_same_thread=False)
cursor = conn.cursor() cursor = conn.cursor()
try: try:
cursor.execute('select * from %(style_name)s' % {'style_name': style}) cursor.execute('select * from %(style_name)s' % {'style_name': style})
+2 -2
View File
@@ -14,11 +14,11 @@ if __name__ == '__main__':
yes_or_no = input('该操作会将数据库初始化输入y继续:') yes_or_no = input('该操作会将数据库初始化输入y继续:')
if yes_or_no == 'y': if yes_or_no == 'y':
try: try:
os.remove('../../db/count.db') os.remove('../db/count.db')
except PermissionError: except PermissionError:
print('有其他程序正在使用此数据库无法删除') print('有其他程序正在使用此数据库无法删除')
sys.exit(-1) sys.exit(-1)
conn = sqlite3.connect('../../db/count.db') conn = sqlite3.connect('../db/count.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('create table ReqCount (name text primary key, times integer )') cursor.execute('create table ReqCount (name text primary key, times integer )')
sys.exit(0) sys.exit(0)
+1 -1
View File
@@ -9,7 +9,7 @@
from typing import Optional from typing import Optional
from flask import jsonify from flask import jsonify
from flask import Response from flask import Response
from db.sqlite import (update_data, fetch_table) from bin.db import (update_data, fetch_table)
class ErrorProcess: class ErrorProcess:
+2 -3
View File
@@ -6,10 +6,9 @@
# @File Name: view.py # @File Name: view.py
import sqlite3
from flask import render_template from flask import render_template
from db.sqlite import fetch_style_data from bin.db import fetch_style_data
from db.sqlite import fetch_table from bin.db import fetch_table
def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, str]: def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, str]: