PEP8 and default configuration

This commit is contained in:
Denis Zheleztsov 2017-09-04 12:37:09 +03:00
parent a80042a384
commit 09a271b5c5
2 changed files with 22 additions and 23 deletions

View File

@ -1,6 +1,4 @@
{ {
"api": "http://127.0.0.1:9076/v1",
"api": "http://10.8.0.34:9076/v1", "ws": "ws://127.0.0.1:7690/ws"
"ws": "ws://php.difrex.ru/ws"
} }

View File

@ -9,45 +9,49 @@ import requests
def action(name, method, data=None): def action(name, method, data=None):
with open('conf.json') as conf: with open('conf.json') as conf:
url = json.load(conf)["api"] + '/' + name url = json.load(conf)["api"] + '/' + name
if method == 'get': if method == 'get':
print 'start' print 'start'
try: res = requests.get(url).content try:
except: res = 'connection can\'t be established' res = requests.get(url).content
except:
res = 'connection can\'t be established'
print 'end' print 'end'
elif method == 'post': elif method == 'post':
print data print data
try: res = requests.post(url, data).content try:
except: res = 'connection can\'t be established' res = requests.post(url, data).content
except:
res = 'connection can\'t be established'
return res return res
def get_status(request):
def get_status(request):
my_status = action('status', 'get') my_status = action('status', 'get')
return JsonResponse(my_status, safe=False) return JsonResponse(my_status, safe=False)
def mount(request):
def mount(request):
if request.method == 'POST': if request.method == 'POST':
data = request.POST.dict() data = request.POST.dict()
res = action('mount', 'post', json.dumps(data)) res = action('mount', 'post', json.dumps(data))
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
def unmount(request):
def unmount(request):
data = request.GET.dict() data = request.GET.dict()
res = action('umount', 'post', json.dumps(data)) res = action('umount', 'post', json.dumps(data))
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
def resolve(request):
def resolve(request):
data = request.GET.dict() data = request.GET.dict()
res = action('resolve', 'post', json.dumps(data)) res = action('resolve', 'post', json.dumps(data))
print 'res' + res print 'res' + res
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
@login_required(login_url="/admin/login/?next=/") @login_required(login_url="/admin/login/?next=/")
def panel(request): def panel(request):
with open('conf.json') as conf: with open('conf.json') as conf:
@ -58,6 +62,3 @@ def panel(request):
my_status = action('status', 'get') my_status = action('status', 'get')
print '3' print '3'
return render(request, 'rbmd/index.html', {'ws': ws, 'metrics': metrics, 'status': my_status}) return render(request, 'rbmd/index.html', {'ws': ws, 'metrics': metrics, 'status': my_status})