mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 兼容py3
parent
b913bce398
commit
a320b9e05e
|
@ -3,7 +3,6 @@
|
|||
{% block modal_id %}asset_import_modal{% endblock %}
|
||||
{% block modal_title%}{% trans "Import asset" %}{% endblock %}
|
||||
{% block modal_body %}
|
||||
<p class="text-success">{% trans "Download template or use export excel format" %}</p>
|
||||
<form method="post" action="{% url 'assets:asset-import' %}" id="fm_asset_import" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% load bootstrap %}
|
||||
{% load bootstrap3 %}
|
||||
{#{% load bootstrap %}#}
|
||||
{% block custom_head_css_js %}
|
||||
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
|
||||
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
|
||||
|
@ -34,13 +35,15 @@
|
|||
<form id="groupForm" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<h3 class="widget-head-color-box">资产组信息</h3>
|
||||
{{ form.name|bootstrap_horizontal }}
|
||||
{{ form.comment|bootstrap_horizontal }}
|
||||
{% bootstrap_field form.name layout="horizontal" %}
|
||||
{% bootstrap_field form.comment layout="horizontal" %}
|
||||
{# {{ form.name|bootstrap_horizontal }}#}
|
||||
{# {{ form.comment|bootstrap_horizontal }}#}
|
||||
<div class="hr-line-dashed"></div>
|
||||
<h3 class="widget-head-color-box">用户选择的资产</h3>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" id="asset_on_count">已选({{ assets_count }})</label>
|
||||
<div class="col-sm-9" id="asset_sed">
|
||||
<label class="col-sm-3 control-label" id="asset_on_count">已选({{ assets_count }})</label>
|
||||
<div class="col-sm-8" id="asset_sed">
|
||||
<div class="form-asset-on" id="add_asset">
|
||||
<p id="asset_on_p">
|
||||
{% for asset in assets_on_list %}
|
||||
|
|
|
@ -209,7 +209,7 @@ class AssetExportView(View):
|
|||
@staticmethod
|
||||
def get_asset_attr(asset, attr):
|
||||
if attr in ['admin_user', 'idc']:
|
||||
return getattr(asset, attr).name
|
||||
return getattr(asset, attr)
|
||||
elif attr in ['status', 'type', 'env']:
|
||||
return getattr(asset, 'get_{}_display'.format(attr))()
|
||||
else:
|
||||
|
@ -225,7 +225,7 @@ class AssetExportView(View):
|
|||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = 'Asset'
|
||||
header = ['hostname', 'ip', 'port', 'admin_user', 'idc', 'cpu', 'memory', 'disk',
|
||||
header = ['hostname', 'ip', 'port', 'admin_user', 'idc', 'memory', 'disk',
|
||||
'mac_address', 'other_ip', 'remote_card_ip', 'os', 'cabinet_no',
|
||||
'cabinet_pos', 'number', 'status', 'type', 'env', 'sn', 'comment']
|
||||
ws.append(header)
|
||||
|
|
|
@ -47,7 +47,6 @@ class JSONResponseMixin(object):
|
|||
|
||||
|
||||
class IDInFilterMixin(object):
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
id_list = self.request.query_params.get('id__in')
|
||||
if id_list:
|
||||
|
@ -55,7 +54,6 @@ class IDInFilterMixin(object):
|
|||
try:
|
||||
ids = json.loads(id_list)
|
||||
except Exception as e:
|
||||
print e
|
||||
return queryset
|
||||
if isinstance(ids, list):
|
||||
queryset = queryset.filter(id__in=ids)
|
||||
|
|
|
@ -26,9 +26,9 @@ from django.conf import settings
|
|||
from django.utils import timezone
|
||||
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
from io import StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
from StringIO import StringIO
|
||||
|
||||
from .compat import to_bytes, to_string
|
||||
|
||||
|
@ -183,7 +183,7 @@ def timesince(dt, since='', default="just now"):
|
|||
|
||||
|
||||
def ssh_key_string_to_obj(text):
|
||||
key_f = StringIO.StringIO(text)
|
||||
key_f = StringIO(text)
|
||||
key = None
|
||||
try:
|
||||
key = paramiko.RSAKey.from_private_key(key_f)
|
||||
|
@ -223,7 +223,7 @@ def ssh_key_gen(length=2048, type='rsa', password=None, username='jumpserver', h
|
|||
if hostname is None:
|
||||
hostname = os.uname()[1]
|
||||
|
||||
f = StringIO.StringIO()
|
||||
f = StringIO()
|
||||
|
||||
try:
|
||||
if type == 'rsa':
|
||||
|
|
|
@ -60,6 +60,7 @@ INSTALLED_APPS = [
|
|||
'applications.apps.ApplicationsConfig',
|
||||
'rest_framework',
|
||||
'bootstrapform',
|
||||
'bootstrap3',
|
||||
'captcha',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
|
|
|
@ -26,10 +26,6 @@ C.HOST_KEY_CHECKING = False
|
|||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class AnsibleError(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
# Jumpserver not use playbook
|
||||
class PlayBookRunner(object):
|
||||
"""
|
||||
|
|
|
@ -17,10 +17,10 @@ from common.utils import reverse, get_object_or_none
|
|||
from .models import User
|
||||
|
||||
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
# try:
|
||||
# from io import StringIO
|
||||
# except ImportError:
|
||||
# from StringIO import StringIO
|
||||
|
||||
|
||||
logger = logging.getLogger('jumpserver')
|
||||
|
|
|
@ -171,7 +171,6 @@ class UserBulkImportView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
try:
|
||||
error = form.errors.values()[-1][-1]
|
||||
except Exception as e:
|
||||
print e
|
||||
error = _('Invalid file.')
|
||||
data = {
|
||||
'success': False,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
openssl brew install libtiff libjpeg webp little-cms2
|
|
@ -23,7 +23,7 @@ def start_django():
|
|||
http_port = CONFIG.HTTP_LISTEN_PORT or '8080'
|
||||
os.chdir(apps_dir)
|
||||
print('start django')
|
||||
subprocess.call('python2.7 ./manage.py runserver %s:%s' % (http_host, http_port), shell=True)
|
||||
subprocess.call('python ./manage.py runserver %s:%s' % (http_host, http_port), shell=True)
|
||||
|
||||
|
||||
def start_celery():
|
||||
|
|
Loading…
Reference in New Issue