feature:修复自动刮削报错停止的问题

This commit is contained in:
charlesxie
2023-09-07 10:57:35 +08:00
parent 37f4d39e5e
commit 1769f212cc
6 changed files with 265 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ class HttpRequest:
# 全局唯一Session
self.__session = requests.Session()
def getHttp(self, url: str, method: int = 0, data: bytes = r'', header: dict = {}) -> requests.Response:
def getHttp(self, url: str, method: int = 0, data=b"", header=None) -> requests.Response:
"""
Http请求-提交二进制流
Args:
@@ -26,24 +26,30 @@ class HttpRequest:
Returns:
requests.Response: 返回的http数据
"""
if header is None:
header = {}
if method == 0:
d = self.__session.get(url, headers=header)
else:
d = self.__session.post(url, data, headers=header)
return d
def getHttp2Json(self, url: str, method: int = 0, data: dict = {}, header: dict = {}):
def getHttp2Json(self, url: str, method: int = 0, data=None, header=None):
"""Http请求-提交json数据
Args:
url (str): url网址
method (int): 0 表示Get请求 1 表示用POST请求. 默认值为 0.
data (bytes): 提交的json对象数据. 默认值为 {}.
data (dict): 提交的json对象数据. 默认值为 {}.
header (dict): 协议头. 默认值为 {}.
Returns:
requests.Response: 返回的http数据
"""
if header is None:
header = {}
if data is None:
data = {}
d = json.dumps(data, ensure_ascii=False)
d = d.encode('utf-8')
return self.getHttp(url, method, d, header)
@@ -78,7 +84,7 @@ class QQMusicApi:
"Cookie": self.getCookie(),
}
def getQQServersCallback(self, url: str, method: int = 0, data: dict = {}):
def getQQServersCallback(self, url: str, method: int = 0, data=None):
"""重新设计了Http接口
参数:
@@ -89,6 +95,8 @@ class QQMusicApi:
返回:
requests.Response: 返回的http数据
"""
if data is None:
data = {}
return self.QQHttpServer.getHttp2Json(url, method, data, self.getHead())
def getQQMusicMediaLyric(self, mid: str) -> dict:

View File

@@ -0,0 +1,77 @@
# define an alias for the specfic python version used in this file.
FROM python:3.9.12-slim-bullseye as python
# Python build stage
FROM python as python-build-stage
ARG BUILD_ENVIRONMENT=prod
# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev \
default-libmysqlclient-dev \
libffi-dev \
libjpeg-dev \
libxml2 \
libxslt1-dev
# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Python 'run' stage
FROM python as python-run-stage
LABEL title="Music Tag Web | 音乐标签网页版"
LABEL description="『音乐标签』Web版是一款可以编辑歌曲的标题,专辑,艺术家,歌词,封面等信息的应用程序"
LABEL authors="xhongc"
ARG BUILD_ENVIRONMENT=prod
ARG APP_HOME=/app
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV BUILD_ENV ${BUILD_ENVIRONMENT}
WORKDIR ${APP_HOME}
# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
default-libmysqlclient-dev \
nodejs\
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
COPY ./compose/prod/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
COPY ./compose/prod/django/celery/worker/start /start-celeryworker
RUN sed -i 's/\r$//g' /start-celeryworker
RUN chmod +x /start-celeryworker
COPY ./compose/prod/django/celery/beat/start /start-celerybeat
RUN sed -i 's/\r$//g' /start-celerybeat
RUN chmod +x /start-celerybeat
# copy application code to WORKDIR
COPY . ${APP_HOME}
RUN python setup_in_docker.py
CMD ["/start"]

View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -o errexit
set -o nounset
rm -f './celerybeat.pid'
exec celery -A django_vue_cli.celery_app beat -l INFO

View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -o errexit
set -o nounset
exec celery -A django_vue_cli.celery_app worker -l info -P gevent --concurrency 10

10
compose/prod/django/start Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
python manage.py migrate --run-syncdb
gunicorn -w 2 -b 0.0.0.0:8001 django_vue_cli.wsgi:application --timeout 120 --worker-class=gevent
#python manage.py runserver 0.0.0.0:8001

View File

@@ -0,0 +1,151 @@
#user nobody;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 20480;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# compression settings
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/javascript
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# end of compression settings
server {
listen 80;
server_name 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://127.0.0.1:8001;
root /Users/macbookair/coding/django-vue-cli/templates;
index index.html;
}
location /media/attachments {
alias /app/media/attachments;
autoindex on;
}
location /media/music {
alias /app/media/music/;
autoindex on;
# add_header Accept-Ranges bytes;
}
keepalive_timeout 60s;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;