From 5f988bde546b03cb2f9c290eb1413ec6d82571a7 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Mon, 29 Aug 2022 06:58:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=B9=E5=99=A8=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E4=BB=A5=E6=8F=90=E7=A4=BA=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E6=88=90=E5=8A=9F=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 8 ++++++-- templates/auto_pt/restart.html | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/auto_pt/views.py b/auto_pt/views.py index ee15d55..a5375d1 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -168,7 +168,11 @@ def restart_container(request): client = docker.from_env() # 从内部获取容器id cid = socket.gethostname() - started_at = client.api.inspect_container(cid).get('State').get('StartedAt') + started_at = client.api.inspect_container(cid).get('State').get('StartedAt')[:19] + UTC_FORMAT = "%Y-%m-%dT%H:%M:%S" + utc_time = datetime.strptime(started_at, UTC_FORMAT) + delta = datetime.now() - utc_time + if get_update_logs(): update = 'false' update_tips = '目前您使用的是最新版本!' @@ -177,7 +181,7 @@ def restart_container(request): update_tips = '已有新版本,请根据需要升级!' return render(request, 'auto_pt/restart.html', context={ - 'started_at': started_at, + 'delta': delta.total_seconds(), 'local_logs': get_git_logs(), 'update_notes': get_git_logs(master='origin/master'), 'update': update, diff --git a/templates/auto_pt/restart.html b/templates/auto_pt/restart.html index a2e830a..ab1f522 100644 --- a/templates/auto_pt/restart.html +++ b/templates/auto_pt/restart.html @@ -16,7 +16,7 @@ width="200" trigger="hover" content="如果遇到无法更新的情况,您可以选择重建容器或者进入容器命令行到项目根目录执行`git pull`命令!"> - {{ update_tips }} + 启动时间:{{ started_at }} + {{ update_tips }} + 启动时间:{{ delta }}