11#!/usr/bin/env python3
22#
3- # 2019年 05月 14日 星期二 22:32:20 CST
3+ # 2019-05-14 22:32:20
44
55import ast
66import requests
@@ -19,7 +19,7 @@ def __init__(self, window, m):
1919
2020 def task_new (self , button ):
2121 '''
22- rest api获取自: https://github.com/PyxYuYu/MyBlog/issues/69
22+ rest api from https://github.com/PyxYuYu/MyBlog/issues/69
2323 @get("/task/new") 创建新任务
2424 '''
2525 _host = self .m ._page4_api_server_entry .get_text ().strip ()
@@ -34,7 +34,7 @@ def task_new(self, button):
3434
3535 _resp = _resp .json ()
3636 if _resp ['success' ]:
37- self .task_view_append ('%s: 创建成功 .' % _resp ['taskid' ])
37+ self .task_view_append ('%s: success .' % _resp ['taskid' ])
3838 except Exception as e :
3939 self .task_view_append (e )
4040
@@ -63,38 +63,38 @@ def admin_list(self, button):
6363 _a_child .destroy ()
6464 # 填充任务列表
6565 _id = 0
66+ _ = self .m .text .gettext
6667 for _taskid , _status in _resp ['tasks' ].items ():
6768 _a_task_row = g .ListBoxRow ()
6869 _a_row_box_tmp = g .Box ()
6970 _a_task_row .add (_a_row_box_tmp )
7071
71- _task_del_btn = g .Button .new_with_label ('删除' )
72+ _task_del_btn = g .Button .new_with_label (_ ( 'delete' ) )
7273 _task_del_btn .connect ('clicked' , self .task_delete , _a_task_row , _taskid )
73- _scan_kill_btn = g .Button .new_with_label ('杀死 ' )
74+ _scan_kill_btn = g .Button .new_with_label ('kill ' )
7475 _scan_kill_btn .connect ('clicked' , self .scan_kill , _taskid )
75- _scan_stop_btn = g .Button .new_with_label ('停止' )
76+ _scan_stop_btn = g .Button .new_with_label (_ ( 'stop' ) )
7677 _scan_stop_btn .connect ('clicked' , self .scan_stop , _taskid )
77- _scan_start_btn = g .Button .new_with_label ('启动' )
78+ _scan_start_btn = g .Button .new_with_label (_ ( 'start' ) )
7879 _scan_start_btn .connect ('clicked' , self .scan_start , _taskid )
7980 _scan_data_btn = g .Button .new_with_label ('data' )
8081 _scan_data_btn .connect ('clicked' , self .scan_data , _taskid )
8182 _scan_log_btn = g .Button .new_with_label ('log' )
8283 _scan_log_btn .connect ('clicked' , self .scan_log , _taskid )
83- _option_list_btn = g .Button .new_with_label ('所有选项' )
84+ _option_list_btn = g .Button .new_with_label (_ ( 'list' ) )
8485 _option_list_btn .connect ('clicked' , self .option_list , _taskid )
85- _option_get_btn = g .Button .new_with_label ('选项:' )
86+ _option_get_btn = g .Button .new_with_label (_ ( 'option:' ) )
8687 _option_get_btn .connect ('clicked' , self .option_get , _taskid )
87- _option_set_btn = g .Button .new_with_label ('设置:' )
88+ _option_set_btn = g .Button .new_with_label (_ ( 'set:' ) )
8889 _option_set_btn .connect ('clicked' , self .option_set , _taskid )
89-
9090 _id += 1
9191 _a_row_box_tmp .pack_start (g .Label .new ('%s. %s' % (_id , _taskid )), False , True , 5 )
9292 _a_row_box_tmp .pack_start (g .Label .new ('(%s)' % _status ), False , True , 0 )
9393 _a_row_box_tmp .pack_start (_task_del_btn , False , True , 1 )
9494 _a_row_box_tmp .pack_start (_scan_kill_btn , False , True , 1 )
9595 _a_row_box_tmp .pack_start (_scan_stop_btn , False , True , 1 )
9696 _a_row_box_tmp .pack_start (_scan_start_btn , False , True , 1 )
97- _a_row_box_tmp .pack_start (g .Label .new ('查看 :(' ), False , True , 1 )
97+ _a_row_box_tmp .pack_start (g .Label .new (_ ( 'view :(') ), False , True , 1 )
9898 _a_row_box_tmp .pack_start (_scan_data_btn , False , True , 1 )
9999 _a_row_box_tmp .pack_start (_scan_log_btn , False , True , 1 )
100100 _a_row_box_tmp .pack_start (_option_list_btn , False , True , 1 )
@@ -198,11 +198,11 @@ def option_set(self, button, taskid):
198198
199199 _resp = _resp .json ()
200200 if _resp ['success' ]:
201- _mesg += '设置成功 '
201+ _mesg += 'set success. '
202202 except Exception as e :
203203 _mesg += str (e )
204204 else :
205- _mesg += '需要一个有效的python dict'
205+ _mesg += 'need a valid python dict. '
206206
207207 self .task_view_append (_mesg )
208208
@@ -225,7 +225,7 @@ def admin_flush(self, button):
225225 if _resp ['success' ]:
226226 for _a_child in self .w ._api_admin_list_rows .get_children ():
227227 self .w ._api_admin_list_rows .remove (_a_child )
228- self .task_view_append ('清空全部任务: 成功.' )
228+ self .task_view_append (self . m . text . gettext ( 'flush all tasks: Done.' ) )
229229 except Exception as e :
230230 self .task_view_append (e )
231231
@@ -246,7 +246,7 @@ def task_delete(self, button, *data):
246246 _resp = _resp .json ()
247247 if _resp ['success' ]:
248248 self .w ._api_admin_list_rows .remove (data [0 ])
249- self .task_view_append ('%s: 删除成功 ' % data [1 ])
249+ self .task_view_append ('%s: removed. ' % data [1 ])
250250 except Exception as e :
251251 self .task_view_append (e )
252252
@@ -305,7 +305,7 @@ def scan_stop(self, button, taskid):
305305
306306 def scan_kill (self , button , taskid ):
307307 '''
308- @get("/scan/<taskid>/kill") kill -9 指定任务
308+ @get("/scan/<taskid>/kill") kill -9 <taskid>
309309 '''
310310 _host = self .m ._page4_api_server_entry .get_text ()
311311 _username = self .m ._page4_username_entry .get_text ().strip ()
@@ -376,7 +376,7 @@ def scan_log(self, button, taskid):
376376 if _logs :
377377 _mesg += _logs .strip ()
378378 else :
379- _mesg += "没有log ."
379+ _mesg += "no log ."
380380 else :
381381 _mesg += _resp ['message' ]
382382 except Exception as e :
0 commit comments