Skip to content

Commit

Permalink
python 3.6.6 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
guohongze committed Jul 19, 2018
1 parent b95694a commit 4ad8676
Show file tree
Hide file tree
Showing 32 changed files with 68 additions and 65 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
<br>
Adminset基于DevOps理念开发,以整合全部运维场景为己任。Adminset是一个真正的基于运维思维而开发的全自动化运维平台。<br>

## v0.20 新功能
## v0.3 新功能
python3.6语法兼容<br>
全新CMDB数据模型<br>
agent后台启动管理<br>
agent部署使用venv<br>
更新celery 4.1.0<br>


## 开发环境
Expand Down
2 changes: 1 addition & 1 deletion accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# update by [email protected]
from django import forms
from django.contrib import auth
from models import UserInfo, RoleList, PermissionList
from accounts.models import UserInfo, RoleList, PermissionList


class LoginUserForm(forms.Form):
Expand Down
4 changes: 2 additions & 2 deletions accounts/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from forms import PermissionListForm
from models import UserInfo, RoleList, PermissionList
from accounts.forms import PermissionListForm
from accounts.models import UserInfo, RoleList, PermissionList


def permission_verify():
Expand Down
4 changes: 2 additions & 2 deletions accounts/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from forms import RoleListForm
from models import RoleList
from accounts.forms import RoleListForm
from accounts.models import RoleList
from accounts.permission import permission_verify


Expand Down
4 changes: 2 additions & 2 deletions accounts/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from django.shortcuts import render, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib import auth
from forms import LoginUserForm, EditUserForm, ChangePasswordForm
from accounts.forms import LoginUserForm, EditUserForm, ChangePasswordForm
from django.contrib.auth import get_user_model
from forms import AddUserForm
from accounts.forms import AddUserForm
from django.core.urlresolvers import reverse
from accounts.permission import permission_verify

Expand Down
9 changes: 7 additions & 2 deletions adminset/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
import ConfigParser
try:
import configparser as cf
except Exception as msg:
print(msg)
import ConfigParser as cf

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adminset.settings')
app = Celery('adminset')

# redis connect code
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
config = ConfigParser.ConfigParser()
config = cf.ConfigParser()
config.read(os.path.join(BASE_DIR, 'adminset.conf'))
redis_host = config.get('redis', "redis_host")
redis_port = config.get("redis", "redis_port")
Expand Down
8 changes: 6 additions & 2 deletions adminset/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"""

import os
import ConfigParser
try:
import ConfigParser as cp
except ImportError as e:
import configparser as cp



# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

config = ConfigParser.ConfigParser()
config = cp.ConfigParser()
config.read(os.path.join(BASE_DIR, 'adminset.conf'))

# Quick-start development settings - unsuitable for production
Expand Down
4 changes: 2 additions & 2 deletions adminset/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
import views
from adminset.views import index

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^$', index, name='index'),
url(r'^cmdb/', include('cmdb.urls')),
url(r'^navi/', include('navi.urls')),
url(r'^admin/', admin.site.urls),
Expand Down
4 changes: 2 additions & 2 deletions appconf/appowner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.shortcuts import render, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from models import AppOwner
from forms import AppOwnerForm
from appconf.models import AppOwner
from appconf.forms import AppOwnerForm
from accounts.permission import permission_verify


Expand Down
4 changes: 2 additions & 2 deletions appconf/authinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.shortcuts import render, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from models import AuthInfo
from forms import AuthInfoForm
from appconf.models import AuthInfo
from appconf.forms import AuthInfoForm
from accounts.permission import permission_verify


Expand Down
4 changes: 2 additions & 2 deletions appconf/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.shortcuts import render, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from models import Product
from forms import ProductForm
from appconf.models import Product
from appconf.forms import ProductForm
from accounts.permission import permission_verify


Expand Down
2 changes: 1 addition & 1 deletion appconf/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from appconf.models import Project
from forms import ProjectForm
from appconf.forms import ProjectForm
from accounts.permission import permission_verify
import csv
import datetime
Expand Down
2 changes: 1 addition & 1 deletion appconf/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url, include
import product, project, appowner, authinfo
from appconf import product, project, appowner, authinfo

urlpatterns = [
url(r'^$', product.product_list, name='appconf'),
Expand Down
2 changes: 1 addition & 1 deletion cmdb/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib import admin
from models import Host, HostGroup, IpSource, Idc, InterFace, UserInfo
from cmdb.models import Host, HostGroup, IpSource, Idc, InterFace, UserInfo


class HostAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion cmdb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# 2017.3 update by [email protected]
from django.http import HttpResponse
from models import Host, HostGroup, ASSET_TYPE, ASSET_STATUS
from cmdb.models import Host, HostGroup, ASSET_TYPE, ASSET_STATUS
from django.core.paginator import Paginator, EmptyPage, InvalidPage
from django.views.decorators.csrf import csrf_exempt
from lib.common import token_verify
Expand Down
4 changes: 2 additions & 2 deletions cmdb/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from django.contrib.auth.decorators import login_required
from django.db.models import Q
from django.shortcuts import HttpResponse, render
from forms import AssetForm
from models import ASSET_STATUS, ASSET_TYPE, Host, HostGroup, Idc, Cabinet
from cmdb.forms import AssetForm
from cmdb.models import ASSET_STATUS, ASSET_TYPE, Host, HostGroup, Idc, Cabinet

try:
reload(sys) # Python 2
Expand Down
4 changes: 2 additions & 2 deletions cmdb/cabinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-

from django.shortcuts import render
from models import Cabinet
from forms import CabinetForm
from cmdb.models import Cabinet
from cmdb.forms import CabinetForm
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify
from django.http import HttpResponseRedirect
Expand Down
4 changes: 2 additions & 2 deletions cmdb/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-

from django.shortcuts import render
from models import HostGroup
from forms import GroupForm
from cmdb.models import HostGroup
from cmdb.forms import GroupForm
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify
from django.http import HttpResponseRedirect
Expand Down
2 changes: 1 addition & 1 deletion cmdb/idc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

from django.shortcuts import render
from forms import IdcForm
from cmdb.forms import IdcForm
from .models import Idc, Cabinet
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify
Expand Down
8 changes: 4 additions & 4 deletions delivery/delivery.py → delivery/deli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from django.shortcuts import render, HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from models import Delivery
from forms import DeliveryFrom
from delivery.models import Delivery
from delivery.forms import DeliveryFrom
from accounts.permission import permission_verify
from .tasks import deploy
from delivery.tasks import deploy
import os
from time import sleep
import json
Expand Down
3 changes: 2 additions & 1 deletion delivery/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django import forms
from django.forms import widgets
from models import Delivery
from delivery.models import Delivery


class DeliveryFrom(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion delivery/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

from django.db import models
from appconf.models import Project, AuthInfo
Expand Down
2 changes: 1 addition & 1 deletion delivery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from subprocess import Popen, PIPE
from .models import Delivery
from delivery.models import Delivery
import os
import shutil
from time import sleep
Expand Down
23 changes: 11 additions & 12 deletions delivery/urls.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url, include
import delivery
import tasks
from delivery import deli, tasks
urlpatterns = [
url(r'^$', delivery.delivery_list, name='delivery'),
url(r'^add/$', delivery.delivery_add, name='delivery_add'),
url(r'^ist/$', delivery.delivery_list, name='delivery_list'),
url(r'^status/(?P<project_id>\d+)/$', delivery.status, name='delivery_status'),
url(r'^edit/(?P<project_id>\d+)/$', delivery.delivery_edit, name='delivery_edit'),
url(r'^log/(?P<project_id>\d+)/$', delivery.log, name='delivery_log'),
url(r'^log2/(?P<project_id>\d+)/$', delivery.log2, name='delivery_log2'),
url(r'^deploy/(?P<project_id>\d+)/$', delivery.delivery_deploy, name='delivery_deploy'),
url(r'^taskstop/(?P<project_id>\d+)/$', delivery.task_stop, name='delivery_taskstop'),
url(r'^delete/$', delivery.delivery_del, name='delivery_del'),
url(r'^$', deli.delivery_list, name='delivery'),
url(r'^add/$', deli.delivery_add, name='delivery_add'),
url(r'^ist/$', deli.delivery_list, name='delivery_list'),
url(r'^status/(?P<project_id>\d+)/$', deli.status, name='delivery_status'),
url(r'^edit/(?P<project_id>\d+)/$', deli.delivery_edit, name='delivery_edit'),
url(r'^log/(?P<project_id>\d+)/$', deli.log, name='delivery_log'),
url(r'^log2/(?P<project_id>\d+)/$', deli.log2, name='delivery_log2'),
url(r'^deploy/(?P<project_id>\d+)/$', deli.delivery_deploy, name='delivery_deploy'),
url(r'^taskstop/(?P<project_id>\d+)/$', deli.task_stop, name='delivery_taskstop'),
url(r'^delete/$', deli.delivery_del, name='delivery_del'),
]
2 changes: 1 addition & 1 deletion delivery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from django.views.generic.base import TemplateView
from django.shortcuts import render
from models import Delivery
from delivery.models import Delivery


def index(request):
Expand Down
2 changes: 1 addition & 1 deletion monitor/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

from django.shortcuts import render, HttpResponse
from api import GetSysData
from monitor.api import GetSysData
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify
from cmdb.models import Host
Expand Down
2 changes: 1 addition & 1 deletion monitor/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from accounts.permission import permission_verify
import json
import time
from api import GetSysData
from monitor.api import GetSysData
TIME_SECTOR = (
3600,
3600*3,
Expand Down
4 changes: 1 addition & 3 deletions monitor/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url, include
from . import system, manage
import api

from monitor import system, manage, api

urlpatterns = [
url(r'^system/$', system.index, name='monitor'),
Expand Down
2 changes: 1 addition & 1 deletion navi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .models import navi
from django.shortcuts import render
from forms import navi_form
from navi.forms import navi_form
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ django==1.11.9
sh==1.12.9
mysqlclient==1.3.12
pytest==3.0.7
celery==4.1.0
django-celery-beat==1.0.1
celery==4.2.0
django-celery-beat==1.1.1
gunicorn==19.7.1
redis==2.10.5
psutil==5.2.2
Expand Down
2 changes: 1 addition & 1 deletion setup/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.auth.decorators import login_required
from accounts.permission import permission_verify
from cmdb.api import get_object
from forms import PeriodicTaskForm, IntervalForm, CrontabForm, TaskResultForm
from setup.forms import PeriodicTaskForm, IntervalForm, CrontabForm, TaskResultForm
from subprocess import Popen, PIPE
import os, time

Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
ight hidden-xs">
</div>
<!-- Default to the left bar -->
<a href="http://adminset.cn" target="view_window">AdminSet</a> v0.26-beta
<a href="http://adminset.cn" target="view_window">AdminSet</a> v0.31-beta
</footer>

0 comments on commit 4ad8676

Please sign in to comment.