Initial commit

This commit is contained in:
xtaodada 2022-02-02 20:28:57 +08:00
parent 181421c78c
commit f61fa9397b
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
3 changed files with 24 additions and 1 deletions

View File

@ -2,6 +2,7 @@ from coloredlogs import ColoredFormatter
from logging import getLogger, StreamHandler, ERROR, INFO, basicConfig
from datetime import datetime
from os import getcwd
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pagermaid.config import Config
import pyromod.listen
@ -11,6 +12,10 @@ CMD_LIST = {}
module_dir = __path__[0]
working_dir = getcwd()
help_messages = {}
scheduler = AsyncIOScheduler()
if not scheduler.running:
scheduler.configure(timezone="Asia/ShangHai")
scheduler.start()
logs = getLogger(__name__)
logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s"
logging_handler = StreamHandler()

View File

@ -1,6 +1,11 @@
import subprocess
from importlib.util import find_spec
from os.path import exists
from typing import Optional
import httpx
from os import remove
from sys import platform
from sys import executable
from asyncio import create_subprocess_shell
from asyncio.subprocess import PIPE
@ -96,6 +101,18 @@ async def execute(command, pass_error=True):
return result
def pip_install(package: str, version: Optional[str] = "", alias: Optional[str] = "") -> bool:
""" Auto install extra pypi packages """
if not alias:
# when import name is not provided, use package name
alias = package
if find_spec(alias) is None:
subprocess.call([executable, "-m", "pip", "install", f"{package}{version}"])
if find_spec(package) is None:
return False
return True
""" Init httpx client """
# 使用自定义 UA
headers = {

View File

@ -7,3 +7,4 @@ PyYAML>=6.0
coloredlogs>=15.0.1
psutil>=5.8.0
httpx
apscheduler>=3.8.1