X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=filex%2Fviews.py;h=a85c26588f2a43fa9469745ef76d946de8b5eda6;hb=273c0546c3f3154497c6554efeba805d9bbde526;hp=1a02ddb483b6c38a4a270382f4a93751acdf5e95;hpb=2e226ed0e2a8bbf0cedbcaf5fff9e2906e858588;p=qcg-portal.git diff --git a/filex/views.py b/filex/views.py index 1a02ddb..a85c265 100644 --- a/filex/views.py +++ b/filex/views.py @@ -197,7 +197,7 @@ def compress(request): path = request.POST.get('path') files = request.POST.getlist('files') archive = request.POST.get('archive') - if not host or not path or not files: + if not host or not path or not files or not archive: raise SuspiciousOperation("No path or host or files or archive given!") server = 'gsiftp://' + host @@ -209,3 +209,25 @@ def compress(request): return JsonResponse({'msg': e.message}, status=400) else: return JsonResponse({'success': True}) + + +@require_POST +def extract(request): + check_auth(request) + + # TODO data validation + host = request.POST.get('host') + archive = request.POST.get('archive') + dst = request.POST.get('dst') + if not host or not archive or not dst: + raise SuspiciousOperation("No path or host or files or archive given!") + + server = 'gsiftp://' + host + + try: + # consume generator with command output + list(FTPOperation(request.session['proxy']).extract(server, archive, dst)) + except FTPException as e: + return JsonResponse({'msg': e.message}, status=400) + else: + return JsonResponse({'success': True})