Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
deploy_script
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Script
deploy_script
Commits
f4d1578b
Commit
f4d1578b
authored
Jun 28, 2021
by
jinkaiqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature:获取所有容器内部的日志文件
parent
0813d8ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
get_all_container_version.py
get_all_container_version.py
+29
-0
table_value_to_str.py
table_value_to_str.py
+10
-0
No files found.
get_all_container_version.py
0 → 100644
View file @
f4d1578b
# -*- coding:utf-8 -*-
'''
获取所有docker容器内的版本文件
'''
import
os
if
__name__
==
'__main__'
:
# 获取所有启动的容器
with
os
.
popen
(
"docker ps | awk '{print $1,$2}'"
)
as
f
:
docker_containers
=
f
.
read
()
# 根据启动的容器,依次获取内部的version.txt,版本文件
container_list
=
docker_containers
.
split
(
"
\n
"
)
verison_info
=
""
for
container_str
in
container_list
:
if
(
container_str
==
"CONTAINER ID"
or
not
container_str
):
continue
container
=
container_str
.
split
(
" "
)
c_id
=
container
[
0
]
c_image
=
container
[
1
]
get_version_cmd
=
f
"docker exec -it {c_id} cat version.txt"
with
os
.
popen
(
get_version_cmd
)
as
f
:
print
(
f
"正在获取镜像{c_image}版本"
)
get_version_result
=
f
.
read
()
# 记录
verison_info
+=
f
"镜像:{c_id}-{c_image},获取版本结果为:
\n
{get_version_result}
\n
"
# 写入文件
with
open
(
"get_all_container_version.txt"
,
'w'
)
as
f
:
f
.
write
(
verison_info
)
table_value_to_str.py
0 → 100644
View file @
f4d1578b
# -*- coding:utf-8 -*-
if
__name__
==
'__main__'
:
table_value_str
=
'''1401734842471800834 1401723910119043074 20210607105644079 2 5 2021-06-07T11:26:44+08:00 2021-06-07 10:56:44.673 NULL
1401734891385774082 1401723910119043074 20210607105655753 2 1 2021-06-07T11:26:55+08:00 [gmt_create2021-06-07 10:57:04][charsetUTF-8][gmt_payment2021-06-07 10:57:10][notify_time2021-06-07 10:57:10][subject测试-IOT设备运维平台V1.0-企业版][buyer_id2088902407659583][invoice_amount0.01][version1.0][notify_id2021060700222105710059581411695231][fund_bill_list[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]][notify_typetrade_status_sync][out_trade_no20210607105655753][total_amount0.01][trade_statusTRADE_SUCCESS][trade_no2021060722001459581404964773][auth_app_id2021002147611434][receipt_amount0.01][point_amount0.00][buyer_pay_amount0.01][app_id2021002147611434][seller_id2088921658176829] 2021-06-07 10:56:56.347 2021-06-07 10:57:10.677'''
for
item
in
table_value_str
.
split
(
'
\n
'
):
table_value_list
=
item
.
split
(
"
\t
"
)
print
(
","
.
join
([
f
"'{item}'"
if
item
!=
'NULL'
else
'NULL'
for
item
in
table_value_list
]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment