diff --git a/auto_pt/urls.py b/auto_pt/urls.py index b00f810..2872dbf 100644 --- a/auto_pt/urls.py +++ b/auto_pt/urls.py @@ -43,4 +43,6 @@ urlpatterns = [ path(r'get_helper_license', views.get_helper_license, name='get_helper_license'), path(r'downloading_status', views.downloading_status, name='downloading_status'), path(r'do_sql', views.do_sql, name='do_sql'), + path(r'exec_shell_command', views.exec_shell_command, name='exec_shell_command'), + path(r'exec_shell_command', views.exec_shell_command, name='exec_shell_command'), ] diff --git a/auto_pt/views.py b/auto_pt/views.py index 9d24dfe..2799aec 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -1132,7 +1132,19 @@ def save_config_api(request): msg='配置文件保存成功!' ).to_dict(), safe=False) except Exception as e: - raise return JsonResponse(data=CommonResponse.error( msg='获取配置文件信息失败!' ).to_dict(), safe=False) + + +def exec_shell_command(request): + if request.method == 'GET': + return render(request, 'auto_pt/shell.html') + else: + content = json.loads(request.body) + logger.info(content) + p = subprocess.getoutput(content.get('shell')) + logger.info(p) + return JsonResponse(data=CommonResponse.success( + data=p + ).to_dict(), safe=False) diff --git a/ptools/settings.py b/ptools/settings.py index 9fdccf0..79723e2 100644 --- a/ptools/settings.py +++ b/ptools/settings.py @@ -292,6 +292,10 @@ SIMPLEUI_CONFIG = { 'name': '日志查看', 'icon': 'fab fa-blogger', 'url': '/tasks/show_log_list' + }, { + 'name': '简易终端', + 'icon': 'fa fa-terminal', + 'url': '/tasks/exec_shell_command' }, ] }] } diff --git a/templates/auto_pt/shell.html b/templates/auto_pt/shell.html new file mode 100644 index 0000000..8869183 --- /dev/null +++ b/templates/auto_pt/shell.html @@ -0,0 +1,120 @@ +{% load static %} + + + + + + + Title + {% include 'admin/includes/css-part.html' %} + + + +
+
+ + + + 发送 + + 更新代码 + 更新依赖 + 初始化代码 + 初始化xpath + + +
+
+

+    
+
+{% include 'admin/includes/js-part.html' %} + + + + \ No newline at end of file