mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: (wip) 支持Python 3.6 / 3.7
This commit is contained in:
parent
177273de99
commit
18fd6a4cb2
@ -40,9 +40,9 @@ python main.py # 运行项目
|
||||
|
||||
### 直接部署
|
||||
|
||||
环境要求:Python 3.8+
|
||||
没有其他限制,能用 Python 理论上就能跑起来
|
||||
如果需要部署 flask 版本,请将 main.py 自行换成 main-flask.py
|
||||
环境要求:Python 3.6+, 建议Python 3.8+
|
||||
没有其他限制,能用 Python 理论上就能跑起来
|
||||
flask版本即将停止支持,不建议使用
|
||||
测试版本部署,linux 命令如果为 python3 请自行替换:
|
||||
|
||||
```bash
|
||||
|
@ -36,10 +36,12 @@ def _read_config(key):
|
||||
return value
|
||||
except:
|
||||
return None
|
||||
|
||||
debug_mode = debug_mode if (debug_mode := _read_config("common.debug_mode")) else False
|
||||
log_length_limit = log_length_limit if (log_length_limit := _read_config("common.log_length_limit")) else 500
|
||||
log_file = log_file if (not isinstance(log_file := _read_config("common.log_file"), type(None))) else True
|
||||
_dm = _read_config("common.debug_mode")
|
||||
_lm = _read_config("common.log_file")
|
||||
_ll = _read_config("common.log_length_limit")
|
||||
debug_mode = _dm if (_dm) else False
|
||||
log_length_limit = _ll if (_ll) else 500
|
||||
log_file = _lm if (not isinstance(_lm , type(None))) else True
|
||||
running = True
|
||||
config = {}
|
||||
workdir = _os.getcwd()
|
||||
|
16
main.py
16
main.py
@ -9,6 +9,12 @@
|
||||
# ----------------------------------------
|
||||
# This file is part of the "lx-music-api-server" project.
|
||||
|
||||
import sys
|
||||
|
||||
if (sys.version_info.major < 3 or sys.version_info.minor < 6):
|
||||
print('Python版本过低,请使用Python 3.6+ ')
|
||||
sys.exit(1)
|
||||
|
||||
from common import config
|
||||
from common import lxsecurity
|
||||
from common import log
|
||||
@ -31,6 +37,14 @@ def handleResult(dic, status = 200):
|
||||
logger = log.log("main")
|
||||
aiologger = log.log('aiohttp_web')
|
||||
|
||||
stopEvent = None
|
||||
if (sys.version_info.minor < 8):
|
||||
logger.warning('您使用的Python版本已经停止更新,不建议继续使用')
|
||||
import concurrent
|
||||
stopEvent = concurrent.futures._base.CancelledError
|
||||
else:
|
||||
stopEvent = asyncio.exceptions.CancelledError
|
||||
|
||||
def start_checkcn_thread():
|
||||
threading.Thread(target=Httpx.checkcn).start()
|
||||
|
||||
@ -147,7 +161,7 @@ async def initMain():
|
||||
await run_app()
|
||||
logger.info("服务器启动成功,请按下Ctrl + C停止")
|
||||
await asyncio.Event().wait() # 等待停止事件
|
||||
except (KeyboardInterrupt, asyncio.exceptions.CancelledError):
|
||||
except (KeyboardInterrupt, stopEvent):
|
||||
pass
|
||||
except OSError as e:
|
||||
if str(e).startswith("[Errno 98]"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user