Browse Source

fix: code lint

master
xuxiaofei 4 years ago
parent
commit
70ff8e033c
  1. 1
      .pylintrc
  2. 6
      .vscode/settings.json
  3. 1
      vislib/views/dashboard.py
  4. 31
      vislib/views/source.py

1
.pylintrc

@ -3,3 +3,4 @@
ignore=migrations ignore=migrations
disable= disable=
C0114, # missing-module-docstring C0114, # missing-module-docstring
indent-string=' '

6
.vscode/settings.json

@ -1,3 +1,7 @@
{ {
"python.linting.pylintEnabled": true "python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--disable=C0103",
"--disable=C0111"
]
} }

1
vislib/views/dashboard.py

@ -17,7 +17,6 @@ def createDashboard(request):
body = json.loads(body_unicode) body = json.loads(body_unicode)
name = body['name'] name = body['name']
desc = body.get('desc', '') desc = body.get('desc', '')
content = body.get('content', '')
creator = request.user creator = request.user
dashboard_id = uuid.uuid4() dashboard_id = uuid.uuid4()

31
vislib/views/source.py

@ -1,13 +1,13 @@
import json import json
from django.shortcuts import render import uuid
from django.http import JsonResponse from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.core import serializers from django.core import serializers
from vislib.models import SourceDataBase, SourceDataTable
from django.utils import timezone from django.utils import timezone
from common.utils.aes import pc
from MySQLdb import _mysql from MySQLdb import _mysql
import uuid from py_vislib.vislib.models import SourceDataBase, SourceDataTable
from py_vislib.common.utils.aes import pc
def default_datetime(): def default_datetime():
now = timezone.now() now = timezone.now()
@ -58,7 +58,7 @@ def updateSource(request):
source.port = body.get('port', 3306) source.port = body.get('port', 3306)
source.username = body.get('username') source.username = body.get('username')
if body.get('password'): if body.get('password'):
source.password = pc.encrypt(body.get('password')) source.password = pc.encrypt(body.get('password')).decode('utf-8')
else: else:
source = serializers.serialize('json', [source]) source = serializers.serialize('json', [source])
source = json.loads(source)[0]['fields'] source = json.loads(source)[0]['fields']
@ -71,11 +71,11 @@ def updateSource(request):
@csrf_exempt @csrf_exempt
def sourceList(request): def sourceList(request):
sourceList = SourceDataBase.objects.filter(creator=request.user) sources = SourceDataBase.objects.filter(creator=request.user)
sourceList = serializers.serialize('json', sourceList) sources = serializers.serialize('json', sources)
sourceList = json.loads(sourceList) sources = json.loads(sources)
sourceArr = [] sourceArr = []
for source in sourceList: for source in sources:
source['fields']['source_id'] = source['pk'] source['fields']['source_id'] = source['pk']
source['fields']['password'] = None source['fields']['password'] = None
sourceArr.append(source['fields']) sourceArr.append(source['fields'])
@ -83,11 +83,11 @@ def sourceList(request):
@csrf_exempt @csrf_exempt
def sourceDetail(request, sourceId): def sourceDetail(request, sourceId):
sourceDetail = SourceDataBase.objects.get(source_id=sourceId) sourceItem = SourceDataBase.objects.get(source_id=sourceId)
sourceDetail = serializers.serialize('json', [sourceDetail]) sourceItem = serializers.serialize('json', [sourceItem])
sourceDetail = json.loads(sourceDetail)[0] sourceItem = json.loads(sourceItem)[0]
return JsonResponse({'code': 20000, 'message': 'success', 'data':sourceDetail['fields'] }) return JsonResponse({'code': 20000, 'message': 'success', 'data':sourceItem['fields'] })
@csrf_exempt @csrf_exempt
def sourceTables(request, sourceId): def sourceTables(request, sourceId):
@ -99,7 +99,7 @@ def sourceTables(request, sourceId):
for table in tables: for table in tables:
json_data.append(table['fields']) json_data.append(table['fields'])
except: finally:
source = SourceDataBase.objects.get(source_id=sourceId) source = SourceDataBase.objects.get(source_id=sourceId)
source = serializers.serialize('json', [source]) source = serializers.serialize('json', [source])
source = json.loads(source)[0]['fields'] source = json.loads(source)[0]['fields']
@ -165,8 +165,7 @@ def sourceLinkedTables(request, sourceId):
json_data = [] json_data = []
for table in tables: for table in tables:
json_data.append(table['fields']) json_data.append(table['fields'])
finally:
except:
json_data = [] json_data = []

Loading…
Cancel
Save