from filex.forms import HostPathNameForm, RenameForm, FavoriteForm, HostPathForm, ExtractForm, HostItemsForm, \
CompressForm
-from filex.ftp import FTPOperation, FTPException
+from filex.ftp import FTPOperation, FTPError
from filex.models import Favorite
from filex.uploadhandler import with_ftp_upload_handler
try:
return self.handle(FTPOperation(request.session['proxy']), form.cleaned_data)
- except FTPException as e:
+ except FTPError as e:
status = 400
if 'No such file or directory' in e.message:
status = 404
for path in params['dirs']:
try:
ftp.rmdir(url + path)
- except FTPException as e:
+ except FTPError as e:
fail[path] = e.message
else:
done.append(path)
for path in params['files']:
try:
ftp.delete(url + path)
- except FTPException as e:
+ except FTPError as e:
fail[path] = e.message
else:
done.append(path)
form_class = RenameForm
def handle(self, ftp, params):
- print params
ftp.move(make_url(params, 'src'), make_url(params, 'dst'))
return JsonResponse({'success': True})
def make_url(params, *parts):
- return 'gsiftp://' + params['host'] + (os.path.join(*[params[part] for part in parts]) if parts else '')
+ return 'gsiftp://{}/{}'.format(params['host'], os.path.join(*[params[part] for part in parts]) if parts else '')
@require_POST
instance = form.save()
return JsonResponse({'group': 'usr', 'host': instance.host, 'path': instance.path,
- 'value': instance.host + instance.path})
+ 'value': instance.host + '/' + instance.path})
return JsonResponse({'error': form.errors}, status=400)