1. 优化显示容器已运行时间

2. 本次更新需重启
This commit is contained in:
ngfchl
2022-09-02 00:17:22 +08:00
parent 4054bfce89
commit ff82a38e2a
3 changed files with 57 additions and 7 deletions

View File

@@ -1,11 +1,10 @@
import json
import socket
import subprocess
from datetime import datetime
from datetime import datetime, timedelta
import docker
import git
import pytz
from django.http import JsonResponse
from django.shortcuts import render
@@ -171,11 +170,18 @@ def restart_container(request):
# 从内部获取容器id
cid = socket.gethostname()
client.api.info()
started_at = client.api.inspect_container(cid).get('State').get('StartedAt')[:19]
utc_format = "%Y-%m-%dT%H:%M:%S:%fZ"
started_at = client.api.inspect_container(cid).get('State').get('StartedAt')[:-4] + 'Z'
utc_format = "%Y-%m-%dT%H:%M:%S.%fZ"
restart = 'true'
delta = datetime.strptime(started_at, utc_format).astimezone(pytz.UTC)
utc_time = datetime.strptime(started_at, utc_format)
local_time = utc_time + timedelta(hours=8)
delta = datetime.now() - local_time
print(delta.seconds)
print(delta.total_seconds())
# delta = local_time.strftime('%Y-%m-%dT%H:%M:%S.%f')
# delta = delta.astimezone(pytz.timezone('Asia/Shanghai'))
except Exception as e:
# raise
restart = 'false'
delta = '程序未在容器中启动?'
if get_update_logs():
@@ -186,7 +192,7 @@ def restart_container(request):
update_tips = '已有新版本,请根据需要升级!'
return render(request, 'auto_pt/restart.html',
context={
'delta': delta,
'delta': str(delta.total_seconds()) + '',
'restart': restart,
'local_logs': get_git_logs(),
'update_notes': get_git_logs(master='origin/master'),

View File

@@ -1,12 +1,23 @@
APScheduler==3.9.1
asgiref==3.5.2
astor==0.8.1
async-timeout==4.0.2
attrdict==2.0.1
Babel==2.10.3
baidu-aip==4.16.7
bce-python-sdk==0.8.74
borax==3.5.6
cachetools==5.2.0
certifi==2022.6.15
chardet==5.0.0
charset-normalizer==2.1.1
click==8.1.3
cloudscraper==1.2.60
cssselect==1.1.0
cssutils==2.5.1
cycler==0.11.0
Cython==0.29.32
decorator==5.1.1
defusedxml==0.7.1
deluge-client==1.9.0
Deprecated==1.2.13
@@ -18,46 +29,79 @@ django-redis==5.2.0
django-simpleui==2022.7.29
docker==6.0.0
et-xmlfile==1.1.0
Flask==2.2.2
Flask-Babel==2.0.0
fonttools==4.35.0
future==0.18.2
gitdb==4.0.9
GitPython==3.1.27
htmlgenerator==1.2.18
idna==3.3
imageio==2.21.1
imgaug==0.4.0
importlib-metadata==4.12.0
itsdangerous==2.1.2
Jinja2==3.1.2
kiwisolver==1.4.4
lmdb==1.3.0
lxml==4.9.1
Markdown==3.4.1
MarkupPy==1.14
MarkupSafe==2.1.1
matplotlib==3.5.3
networkx==2.8.5
numpy==1.23.2
odfpy==1.4.1
OpenCC==1.1.4
opencv-contrib-python==4.4.0.46
opencv-python==4.6.0.66
openpyxl==3.0.10
opt-einsum==3.3.0
packaging==21.3
paddle-bfloat==0.1.7
paddleocr==2.5.0.3
paddlepaddle==2.3.1
pandas==1.4.3
Pillow==9.2.0
premailer==3.10.0
prettytable==3.3.0
protobuf==3.20.0
pyclipper==1.3.0.post3
pycryptodome==3.15.0
pyparsing==3.0.9
pypushdeer==0.0.3
python-dateutil==2.8.2
python-Levenshtein==0.12.2
pytz==2022.2.1
pytz-deprecation-shim==0.1.0.post0
PyWavelets==1.3.0
PyYAML==6.0
qbittorrent-api==2022.8.36
qqai==0.2.1
redis==4.3.4
requests==2.28.1
requests-toolbelt==0.9.1
scikit-image==0.19.3
scipy==1.9.0
Shapely==1.8.3
simplejson==3.17.6
six==1.16.0
smmap==5.0.0
sqlparse==0.4.2
supervisor==4.2.4
tablib==3.2.1
tifffile==2022.8.12
tqdm==4.64.0
transmission-rpc==3.3.2
typing_extensions==4.3.0
tzdata==2022.2
tzlocal==4.2
urllib3==1.26.11
visualdl==2.3.0
wcwidth==0.2.5
websocket-client==1.4.0
wechat-push==1.0.1
Werkzeug==2.2.2
wrapt==1.14.1
wxpusher==2.2.0
xlrd==2.0.1

View File

@@ -17,7 +17,7 @@
trigger="hover"
content="如果遇到无法更新的情况,您可以选择重建容器或者进入容器命令行到项目根目录执行`git pull`命令!">
<el-link slot="reference"
type="success">{{ update_tips }} + <span>启动时间{{ delta }}</span></el-link>
type="success">{{ update_tips }} + <span>容器已运行{{ delta }}</span></el-link>
</el-popover>
</span>
<span style="float: right;margin-top: -10px">