[Bugfix] 修改bug,使用py3编程

pull/462/head
GuangHongwei 2017-05-15 23:39:54 +08:00
parent 3c8d6fbe1b
commit 458989328e
13 changed files with 37 additions and 47 deletions

1
.gitignore vendored
View File

@ -22,3 +22,4 @@ host_rsa_key
*.bat *.bat
tags tags
tmp/* tmp/*
jumpserver.iml

View File

@ -43,8 +43,6 @@
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
{% include 'assets/_asset_import_modal.html' %}
{% include 'assets/_asset_bulk_update_modal.html' %}
{% endblock %} {% endblock %}
{% block custom_foot_js %} {% block custom_foot_js %}

View File

@ -55,7 +55,7 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView):
if self.username: if self.username:
filter_kwargs['user'] = self.username filter_kwargs['user'] = self.username
if self.ip: if self.ip:
filter_kwargs['ip'] = self.ip filter_kwargs['asset'] = self.ip
if self.system_user: if self.system_user:
filter_kwargs['system_user'] = self.system_user filter_kwargs['system_user'] = self.system_user
if self.keyword: if self.keyword:

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from __future__ import unicode_literals from __future__ import unicode_literals
from collections import OrderedDict from collections import OrderedDict
from six import string_types from six import string_types
import base64 import base64
@ -15,9 +15,9 @@ import hashlib
from email.utils import formatdate from email.utils import formatdate
import calendar import calendar
import threading import threading
from io import StringIO
import paramiko import paramiko
from passlib.hash import sha512_crypt
import sshpubkeys import sshpubkeys
from itsdangerous import TimedJSONWebSignatureSerializer, JSONWebSignatureSerializer, \ from itsdangerous import TimedJSONWebSignatureSerializer, JSONWebSignatureSerializer, \
BadSignature, SignatureExpired BadSignature, SignatureExpired
@ -25,10 +25,6 @@ from django.shortcuts import reverse as dj_reverse
from django.conf import settings from django.conf import settings
from django.utils import timezone from django.utils import timezone
try:
from io import StringIO
except ImportError:
from StringIO import StringIO
from .compat import to_bytes, to_string from .compat import to_bytes, to_string
@ -281,6 +277,7 @@ _ISO8601_FORMAT = "%Y-%m-%dT%H:%M:%S.000Z"
def to_unixtime(time_string, format_string): def to_unixtime(time_string, format_string):
time_string = time_string.decode("ascii")
with _STRPTIME_LOCK: with _STRPTIME_LOCK:
return int(calendar.timegm(time.strptime(time_string, format_string))) return int(calendar.timegm(time.strptime(time_string, format_string)))
@ -305,15 +302,9 @@ def iso8601_to_unixtime(time_string):
return to_unixtime(time_string, _ISO8601_FORMAT) return to_unixtime(time_string, _ISO8601_FORMAT)
# def http_to_unixtime(time_string):
# """把HTTP Date格式的字符串转换为UNIX时间自1970年1月1日UTC零点的秒数
#
# HTTP Date形如 `Sat, 05 Dec 2015 11:10:29 GMT` 。
# """
# return to_unixtime(time_string, "%a, %d %b %Y %H:%M:%S GMT")
def make_signature(access_key_secret, date=None): def make_signature(access_key_secret, date=None):
if isinstance(date, bytes):
date = bytes.decode(date)
if isinstance(date, int): if isinstance(date, int):
date_gmt = http_date(date) date_gmt = http_date(date)
elif date is None: elif date is None:

View File

@ -40,10 +40,7 @@ class Task(models.Model):
@property @property
def assets_json(self): def assets_json(self):
from assets.models import Asset return [asset._to_secret_json() for asset in self.total_assets]
return [Asset.objects.get(id=int(id_))._to_secret_json()
for id_ in self.total_assets
if Asset.objects.filter(id=int(id_))]
@property @property
def module_args(self): def module_args(self):

View File

@ -105,6 +105,7 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
success_message = _( success_message = _(
'Update asset permission <a href="{url}"> {name} </a> successfully.' 'Update asset permission <a href="{url}"> {name} </a> successfully.'
) )
success_url = reverse_lazy("perms:asset-permission-list")
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = { context = {

View File

@ -1,5 +1,5 @@
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"); @import url("https://fonts.css.network/css?family=Open+Sans:300,400,600,700");
@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"); @import url("https://fonts.css.network/css?family=Roboto:400,300,500,700");
/** {*/ /** {*/
/*box-sizing: border-box;*/ /*box-sizing: border-box;*/
/*}*/ /*}*/

View File

@ -1,5 +1,5 @@
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"); @import url("https://fonts.css.network/css?family=Open+Sans:300,400,600,700");
@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"); @import url("https://fonts.css.network/css?family=Roboto:400,300,500,700");
/* /*
* *
* INSPINIA - Responsive Admin Theme * INSPINIA - Responsive Admin Theme

View File

@ -5,7 +5,7 @@
// Load the fonts // Load the fonts
Highcharts.createElement('link', { Highcharts.createElement('link', {
href: 'http://fonts.googleapis.com/css?family=Unica+One', href: 'https://fonts.css.network/css?family=Unica+One',
rel: 'stylesheet', rel: 'stylesheet',
type: 'text/css' type: 'text/css'
}, null, document.getElementsByTagName('head')[0]); }, null, document.getElementsByTagName('head')[0]);

View File

@ -5,7 +5,7 @@
// Load the fonts // Load the fonts
Highcharts.createElement('link', { Highcharts.createElement('link', {
href: 'http://fonts.googleapis.com/css?family=Dosis:400,600', href: 'https://fonts.css.network/css?family=Dosis:400,600',
rel: 'stylesheet', rel: 'stylesheet',
type: 'text/css' type: 'text/css'
}, null, document.getElementsByTagName('head')[0]); }, null, document.getElementsByTagName('head')[0]);

View File

@ -5,7 +5,7 @@
// Load the fonts // Load the fonts
Highcharts.createElement('link', { Highcharts.createElement('link', {
href: 'http://fonts.googleapis.com/css?family=Signika:400,700', href: 'https://fonts.css.network/css?family=Signika:400,700',
rel: 'stylesheet', rel: 'stylesheet',
type: 'text/css' type: 'text/css'
}, null, document.getElementsByTagName('head')[0]); }, null, document.getElementsByTagName('head')[0]);

View File

@ -161,10 +161,12 @@ def refresh_token(token, user, expiration=3600):
def generate_token(request, user): def generate_token(request, user):
expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600 expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600
remote_addr = request.META.get('REMOTE_ADDR', '') remote_addr = request.META.get('REMOTE_ADDR', '')
remote_addr = base64.b16encode(remote_addr).replace('=', '') if not isinstance(remote_addr, bytes):
remote_addr = remote_addr.encode("utf-8")
remote_addr = base64.b16encode(remote_addr) #.replace(b'=', '')
token = cache.get('%s_%s' % (user.id, remote_addr)) token = cache.get('%s_%s' % (user.id, remote_addr))
if not token: if not token:
token = uuid.uuid4().get_hex() token = uuid.uuid4().hex
print('Set cache: %s' % token) print('Set cache: %s' % token)
cache.set(token, user.id, expiration) cache.set(token, user.id, expiration)
cache.set('%s_%s' % (user.id, remote_addr), token, expiration) cache.set('%s_%s' % (user.id, remote_addr), token, expiration)

View File

@ -1,19 +1,19 @@
Django==1.11 Django>=1.11
django-bootstrap3==8.2.2 django-bootstrap3>=8.2.2
Pillow==4.1.0 Pillow>=4.1.0
djangorestframework==3.6.2 djangorestframework>=3.6.2
ForgeryPy ForgeryPy
openpyxl==2.4.0 openpyxl>=2.4.0
celery==4.0.2 celery>=4.0.2
paramiko==2.1.2 paramiko>=2.1.2
ansible==2.2.2.0 ansible>=2.2.2.0
django-simple-captcha==0.5.5 django-simple-captcha>=0.5.5
django-formtools==2.0 django-formtools>=2.0
sshpubkeys==2.2.0 sshpubkeys>=2.2.0
djangorestframework-bulk==0.2.1 djangorestframework-bulk>=0.2.1
django-redis-cache==1.7.1 django-redis-cache>=1.7.1
requests==2.13.0 requests>=2.13.0
itsdangerous==0.24 itsdangerous>=0.24
eventlet eventlet
django-filter==1.0.2 django-filter>=1.0.2
passlib==1.7.1 passlib>=1.7.1