diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index 95f847518..ca765bbd2 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -795,9 +795,6 @@ def addPerm(request): context_instance=RequestContext(request)) - - - @login_required def chgPass(request): """修改登录密码""" @@ -911,21 +908,24 @@ def upFile(request): port = asset.port jm = PyCrypt(key) user = User.objects.get(username=username) - t = paramiko.Transport((host, port)) - t.connect(username=username, password=jm.decrypt(user.ldap_password)) - sftp = paramiko.SFTPClient.from_transport(t) - sftp.put(filename, '%s/%s' % (path, upload_file.name)) - msg = u'上传成功,位于 %s主机,位置 %s.' % (host, path) - uplog_dir = os.path.join(log_dir, 'upload') - if not os.path.isdir(uplog_dir): - os.mkdir(uplog_dir) - filename = os.path.join(uplog_dir, time.strftime('%Y%m%d')) - f = open(filename, 'a') - f.write('DateTime: %s User: %s Host: %s File: %s' % - (time.strftime('%Y/%m/%d %H:%M:%S'), username, host, path)) - f.close() - - return render_to_response('info.html', {'msg': msg}) + try: + t = paramiko.Transport((host, port)) + t.connect(username=username, password=jm.decrypt(user.ldap_password)) + sftp = paramiko.SFTPClient.from_transport(t) + sftp.put(filename, '%s/%s' % (path, upload_file.name)) + msg = u'上传成功,位于 %s主机,位置 %s.' % (host, path) + uplog_dir = os.path.join(log_dir, 'upload') + if not os.path.isdir(uplog_dir): + os.mkdir(uplog_dir) + filename = os.path.join(uplog_dir, '%s.log' % time.strftime('%Y%m%d')) + f = open(filename, 'a') + f.write('DateTime: %s User: %s Host: %s File: %s\n' % + (time.strftime('%Y/%m/%d %H:%M:%S'), username, host, path)) + f.close() + except paramiko.AuthenticationException: + error = u'密码不对 或者 你用的admin用户' + + return render_to_response('info.html', {'msg': msg, 'error': error}) else: return render_to_response('info.html', {'error': u"上传失败"}) @@ -956,9 +956,9 @@ def downFile(request): downlog_dir = os.path.join(log_dir, 'download') if not os.path.isdir(downlog_dir): os.mkdir(downlog_dir) - filename = os.path.join(downlog_dir, time.strftime('%Y%m%d')) + filename = os.path.join(downlog_dir, '%s.log' % time.strftime('%Y%m%d')) f = open(filename, 'a') - f.write('DateTime: %s User: %s Host: %s File: %s' % + f.write('DateTime: %s User: %s Host: %s File: %s\n' % (time.strftime('%Y/%m/%d %H:%M:%S'), username, host, path)) f.close() wrapper = FileWrapper(open(download_file)) diff --git a/webroot/AutoSa/templates/addVPN.html b/webroot/AutoSa/templates/addVPN.html deleted file mode 100644 index 07c7501c0..000000000 --- a/webroot/AutoSa/templates/addVPN.html +++ /dev/null @@ -1,3 +0,0 @@ -{% extends 'base.html' %} -{% block content %} -{% endblock %} \ No newline at end of file diff --git a/webroot/AutoSa/templates/assets_edit.html b/webroot/AutoSa/templates/assets_edit.html deleted file mode 100644 index f57a076a8..000000000 --- a/webroot/AutoSa/templates/assets_edit.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "base.html" %} -{% block content %} -
编号 | -IP | -主机名 | -cpu | -内存 | -硬盘 | -操作系统 | -详情 | -编辑 | -删除 | -
---|---|---|---|---|---|---|---|---|---|
{{ post.s_num }} | -{{ post.s_ip }} | -{{ post.s_hostname }} | -{{ post.s_cpu }} | -{{ post.s_mem }} | -{{ post.s_disk }} | -{{ post.s_system }} | -详情 | -编辑 | -删除 | -