Commit a320b9e0 authored by ibuler's avatar ibuler

[Bugfix] 兼容py3

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