Commit 2e1c7d2f authored by ibuler's avatar ibuler

修改模板显示

修改jumpserver.py   1.2 1.21
修改下载大文件
parent 78b55f98
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 2.7.8 (C:\Python27\python.exe)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
......
...@@ -132,7 +132,6 @@ def connect(host, port, user, password): ...@@ -132,7 +132,6 @@ def connect(host, port, user, password):
signal.signal(signal.SIGWINCH, sigwinch_passthrough) signal.signal(signal.SIGWINCH, sigwinch_passthrough)
size = getwinsize() size = getwinsize()
foo.setwinsize(size[0], size[1]) foo.setwinsize(size[0], size[1])
print "\033[32;1mLogin %s success!\033[0m" % host
foo.interact() foo.interact()
break break
elif index == 0: elif index == 0:
...@@ -259,19 +258,26 @@ def exec_cmd_servers(username): ...@@ -259,19 +258,26 @@ def exec_cmd_servers(username):
def connect_one(username, option): def connect_one(username, option):
ip = option.strip() ip_input = option.strip()
ip_all, ip_all_dict = ip_all_select(username) ip_all, ip_all_dict = ip_all_select(username)
ip_matched = match_ip(ip_all, ip) ip_matched = match_ip(ip_all, ip_input)
ip_len = len(ip_matched) ip_len = len(ip_matched)
if ip_len == 1: ip = ''
ip = ip_matched[0] if ip_len >= 1:
password = jm.decrypt(sth_select(username=username)) if ip_len == 1:
port = sth_select(ip=ip) ip = ip_matched[0]
print "Connecting %s ..." % ip else:
connect(ip, port, username, password) for one_ip in ip_matched:
elif ip_len > 1: if one_ip.endswith(ip_input):
for ip in ip_matched: ip = one_ip
print ip break
else:
print one_ip
if ip:
password = jm.decrypt(sth_select(username=username))
port = sth_select(ip=ip_input)
print "Connecting %s ..." % ip
connect(ip, port, username, password)
else: else:
print '\033[31mNo permision .\033[0m' print '\033[31mNo permision .\033[0m'
......
...@@ -18,6 +18,7 @@ import crypt ...@@ -18,6 +18,7 @@ import crypt
import hashlib import hashlib
from UserManage.forms import UserAddForm, GroupAddForm from UserManage.forms import UserAddForm, GroupAddForm
import paramiko import paramiko
from django.core.servers.basehttp import FileWrapper
base_dir = "/opt/jumpserver/" base_dir = "/opt/jumpserver/"
...@@ -940,11 +941,9 @@ def downFile(request): ...@@ -940,11 +941,9 @@ def downFile(request):
sftp = paramiko.SFTPClient.from_transport(t) sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(path, download_file) sftp.get(path, download_file)
if os.path.isfile(download_file): if os.path.isfile(download_file):
f = open(download_file) wrapper = FileWrapper(open(download_file))
data = f.read()
f.close()
response = HttpResponse(data, mimetype='application/octet-stream') response = HttpResponse(wrapper, mimetype='application/octet-stream')
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(path) response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(path)
return response return response
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<body> <body>
{% if msg %} {% if msg %}
<div class="alert alert-success"><b>成功:</b>{{ msg }}</div> <div class="alert alert-success" style="margin-left: auto;margin-right: auto;margin-top: 60px;width:500px;"><b>成功:</b>{{ msg }}</div>
{% endif %} {% endif %}
{% if error %} {% if error %}
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
<th>is_admin</th> <th>is_admin</th>
<th>is_superuser</th> <th>is_superuser</th>
<th>Email</th> <th>Email</th>
<th>Key</th> <th>密钥</th>
<th>修改</th> <th>用户信息</th>
<th>sudo</th> <th>sudo</th>
<th>sudo</th> <th>sudo</th>
</tr> </tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment