PEP8 and default configuration
This commit is contained in:
parent
a80042a384
commit
09a271b5c5
@ -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"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
print 'end'
|
except:
|
||||||
elif method == 'post':
|
res = 'connection can\'t be established'
|
||||||
print data
|
print 'end'
|
||||||
try: res = requests.post(url, data).content
|
elif method == 'post':
|
||||||
except: res = 'connection can\'t be established'
|
print data
|
||||||
|
try:
|
||||||
|
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:
|
||||||
@ -57,7 +61,4 @@ def panel(request):
|
|||||||
print '2'
|
print '2'
|
||||||
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})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user