Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
ops
jumpserver
Commits
4fd9957b
Commit
4fd9957b
authored
Feb 20, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改celery日志显示
parent
785cc041
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
41 deletions
+55
-41
api.py
apps/common/api.py
+22
-19
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+26
-22
celery.py
apps/ops/api/celery.py
+7
-0
No files found.
apps/common/api.py
View file @
4fd9957b
...
...
@@ -199,6 +199,8 @@ class LogTailApi(generics.RetrieveAPIView):
buff_size
=
1024
*
10
serializer_class
=
OutputSerializer
end
=
False
mark
=
''
log_path
=
''
def
is_file_finish_write
(
self
):
return
True
...
...
@@ -206,6 +208,9 @@ class LogTailApi(generics.RetrieveAPIView):
def
get_log_path
(
self
):
raise
NotImplementedError
()
def
get_no_file_message
(
self
,
request
):
return
'Not found the log'
def
filter_line
(
self
,
line
):
"""
过滤行,可能替换一些信息
...
...
@@ -214,27 +219,14 @@ class LogTailApi(generics.RetrieveAPIView):
"""
return
line
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
mark
=
request
.
query_params
.
get
(
"mark"
)
or
str
(
uuid
.
uuid4
())
log_path
=
self
.
get_log_path
()
if
not
log_path
or
not
os
.
path
.
isfile
(
log_path
):
if
self
.
is_file_finish_write
():
return
Response
({
"data"
:
'Not found the log'
,
'end'
:
True
,
'mark'
:
mark
})
else
:
return
Response
({
"data"
:
"Waiting...
\r\n
"
},
status
=
200
)
with
open
(
log_path
,
'r'
)
as
f
:
offset
=
cache
.
get
(
mark
,
0
)
def
read_from_file
(
self
):
with
open
(
self
.
log_path
,
'r'
)
as
f
:
offset
=
cache
.
get
(
self
.
mark
,
0
)
f
.
seek
(
offset
)
data
=
f
.
read
(
self
.
buff_size
)
.
replace
(
'
\n
'
,
'
\r\n
'
)
mark
=
str
(
uuid
.
uuid4
())
cache
.
set
(
mark
,
f
.
tell
(),
5
)
new_
mark
=
str
(
uuid
.
uuid4
())
cache
.
set
(
new_
mark
,
f
.
tell
(),
5
)
if
data
==
''
and
self
.
is_file_finish_write
():
self
.
end
=
True
...
...
@@ -244,4 +236,15 @@ class LogTailApi(generics.RetrieveAPIView):
if
line
==
''
:
continue
_data
+=
new_line
+
'
\r\n
'
return
Response
({
"data"
:
_data
,
'end'
:
self
.
end
,
'mark'
:
mark
})
return
_data
,
self
.
end
,
new_mark
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
mark
=
request
.
query_params
.
get
(
"mark"
)
or
str
(
uuid
.
uuid4
())
self
.
log_path
=
self
.
get_log_path
()
if
not
self
.
log_path
or
not
os
.
path
.
isfile
(
self
.
log_path
):
msg
=
self
.
get_no_file_message
(
self
.
request
)
return
Response
({
"data"
:
msg
},
status
=
200
)
data
,
end
,
new_mark
=
self
.
read_from_file
()
return
Response
({
"data"
:
data
,
'end'
:
end
,
'mark'
:
new_mark
})
apps/locale/zh/LC_MESSAGES/django.mo
View file @
4fd9957b
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
4fd9957b
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-0
1-28 12:5
6+0800\n"
"POT-Creation-Date: 2019-0
2-20 16:4
6+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -21,11 +21,11 @@ msgstr ""
msgid "You can't update the root node name"
msgstr "不能修改根节点名称"
#: assets/api/node.py:28
1
#: assets/api/node.py:28
2
msgid "Update node asset hardware information: {}"
msgstr "更新节点资产硬件信息: {}"
#: assets/api/node.py:29
5
#: assets/api/node.py:29
6
msgid "Test if the assets under the node are connectable: {}"
msgstr "测试节点下资产是否可连接: {}"
...
...
@@ -764,48 +764,48 @@ msgstr "获取资产信息失败:{}"
msgid "Update some assets hardware info"
msgstr "更新资产硬件信息"
#: assets/tasks.py:13
6
#: assets/tasks.py:13
4
msgid "Update asset hardware info: {}"
msgstr "更新资产硬件信息: {}"
#: assets/tasks.py:1
61
#: assets/tasks.py:1
59
msgid "Test assets connectivity"
msgstr "测试资产可连接性"
#: assets/tasks.py:18
5
#: assets/tasks.py:18
3
msgid "Test assets connectivity: {}"
msgstr "测试资产可连接性: {}"
#: assets/tasks.py:22
4
#: assets/tasks.py:22
5
msgid "Test admin user connectivity period: {}"
msgstr "定期测试管理账号可连接性: {}"
#: assets/tasks.py:23
1
#: assets/tasks.py:23
2
msgid "Test admin user connectivity: {}"
msgstr "测试管理行号可连接性: {}"
#: assets/tasks.py:27
0
#: assets/tasks.py:27
1
msgid "Test system user connectivity: {}"
msgstr "测试系统用户可连接性: {}"
#: assets/tasks.py:27
7
#: assets/tasks.py:27
8
msgid "Test system user connectivity: {} => {}"
msgstr "测试系统用户可连接性: {} => {}"
#: assets/tasks.py:29
0
#: assets/tasks.py:29
1
msgid "Test system user connectivity period: {}"
msgstr "定期测试系统用户可连接性: {}"
#: assets/tasks.py:36
2
#: assets/tasks.py:36
3
msgid ""
"Push system user task skip, auto push not enable or protocol is not ssh: {}"
msgstr "推送系统用户任务跳过,自动推送没有打开,或协议不是ssh: {}"
#: assets/tasks.py:38
2 assets/tasks.py:396
#: assets/tasks.py:38
3 assets/tasks.py:397
msgid "Push system users to assets: {}"
msgstr "推送系统用户到入资产: {}"
#: assets/tasks.py:38
8
#: assets/tasks.py:38
9
msgid "Push system users to asset: {} => {}"
msgstr "推送系统用户到入资产: {} => {}"
...
...
@@ -1092,7 +1092,7 @@ msgstr "选择节点"
#: assets/templates/assets/admin_user_detail.html:100
#: assets/templates/assets/asset_detail.html:208
#: assets/templates/assets/asset_list.html:63
5
#: assets/templates/assets/asset_list.html:63
6
#: assets/templates/assets/cmd_filter_detail.html:106
#: assets/templates/assets/system_user_asset.html:112
#: assets/templates/assets/system_user_detail.html:182
...
...
@@ -1312,7 +1312,7 @@ msgstr "重命名成功"
msgid "Rename failed, do not change the root node name"
msgstr "重命名失败,不能更改root节点的名称"
#: assets/templates/assets/asset_list.html:6
29
#: assets/templates/assets/asset_list.html:6
30
#: assets/templates/assets/system_user_list.html:137
#: users/templates/users/user_detail.html:382
#: users/templates/users/user_detail.html:408
...
...
@@ -1322,11 +1322,11 @@ msgstr "重命名失败,不能更改root节点的名称"
msgid "Are you sure?"
msgstr "你确认吗?"
#: assets/templates/assets/asset_list.html:63
0
#: assets/templates/assets/asset_list.html:63
1
msgid "This will delete the selected assets !!!"
msgstr "删除选择资产"
#: assets/templates/assets/asset_list.html:63
3
#: assets/templates/assets/asset_list.html:63
4
#: assets/templates/assets/system_user_list.html:141
#: common/templates/common/terminal_setting.html:163
#: users/templates/users/user_detail.html:386
...
...
@@ -1339,16 +1339,16 @@ msgstr "删除选择资产"
msgid "Cancel"
msgstr "取消"
#: assets/templates/assets/asset_list.html:6
39
#: assets/templates/assets/asset_list.html:6
40
msgid "Asset Deleted."
msgstr "已被删除"
#: assets/templates/assets/asset_list.html:64
0
#: assets/templates/assets/asset_list.html:64
5
#: assets/templates/assets/asset_list.html:64
1
#: assets/templates/assets/asset_list.html:64
6
msgid "Asset Delete"
msgstr "删除"
#: assets/templates/assets/asset_list.html:64
4
#: assets/templates/assets/asset_list.html:64
5
msgid "Asset Deleting failed."
msgstr "删除失败"
...
...
@@ -2315,6 +2315,10 @@ msgstr ""
"div><div>如果你看到了这个页面,证明你访问的不是nginx监听的端口,祝你好运</"
"div>"
#: ops/api/celery.py:54
msgid "Waiting task start"
msgstr "等待任务开始"
#: ops/models/adhoc.py:38
msgid "Interval"
msgstr "间隔"
...
...
apps/ops/api/celery.py
View file @
4fd9957b
...
...
@@ -4,6 +4,7 @@
import
os
import
re
from
django.utils.translation
import
ugettext
as
_
from
celery.result
import
AsyncResult
from
rest_framework
import
generics
...
...
@@ -46,6 +47,12 @@ class CeleryTaskLogApi(LogTailApi):
def
is_file_finish_write
(
self
):
return
self
.
task
.
ready
()
def
get_no_file_message
(
self
,
request
):
if
self
.
mark
==
'undefined'
:
return
'.'
else
:
return
_
(
'Waiting task start'
)
class
CeleryResultApi
(
generics
.
RetrieveAPIView
):
permission_classes
=
(
IsValidUser
,)
...
...
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