修改模板显示

修改jumpserver.py   1.2 1.21
修改下载大文件
pull/2/head
ibuler 10 years ago
parent 78b55f981c
commit 2e1c7d2fb8

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<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" />
</component>
</module>

@ -132,7 +132,6 @@ def connect(host, port, user, password):
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
size = getwinsize()
foo.setwinsize(size[0], size[1])
print "\033[32;1mLogin %s success!\033[0m" % host
foo.interact()
break
elif index == 0:
@ -259,19 +258,26 @@ def exec_cmd_servers(username):
def connect_one(username, option):
ip = option.strip()
ip_input = option.strip()
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)
if ip_len == 1:
ip = ip_matched[0]
password = jm.decrypt(sth_select(username=username))
port = sth_select(ip=ip)
print "Connecting %s ..." % ip
connect(ip, port, username, password)
elif ip_len > 1:
for ip in ip_matched:
print ip
ip = ''
if ip_len >= 1:
if ip_len == 1:
ip = ip_matched[0]
else:
for one_ip in ip_matched:
if one_ip.endswith(ip_input):
ip = one_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:
print '\033[31mNo permision .\033[0m'

@ -18,6 +18,7 @@ import crypt
import hashlib
from UserManage.forms import UserAddForm, GroupAddForm
import paramiko
from django.core.servers.basehttp import FileWrapper
base_dir = "/opt/jumpserver/"
@ -940,11 +941,9 @@ def downFile(request):
sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(path, download_file)
if os.path.isfile(download_file):
f = open(download_file)
data = f.read()
f.close()
wrapper = FileWrapper(open(download_file))
response = HttpResponse(data, mimetype='application/octet-stream')
response = HttpResponse(wrapper, mimetype='application/octet-stream')
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(path)
return response

@ -38,7 +38,7 @@
<body>
{% 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 %}
{% if error %}

@ -17,8 +17,8 @@
<th>is_admin</th>
<th>is_superuser</th>
<th>Email</th>
<th>Key</th>
<th>修改</th>
<th>密钥</th>
<th>用户信息</th>
<th>sudo</th>
<th>sudo</th>
</tr>

Loading…
Cancel
Save