def post(self, request, *args, **kwargs): '''respond to post when a form was submitted''' if 'path' not in request.POST: return HttpResponseBadRequest() try: path = Filesystem.getTruePath(request.POST['path']) except: context = self.get_context_data(error='Invalid path, try again') return self.render_to_response(context) return self.handler(request, path)
def post(self, request, *args, **kwargs): '''respond to post when a form was submitted''' if 'path' not in request.POST: return HttpResponseBadRequest() try: path = Filesystem.getTruePath(request.POST['path']) except: context = self.get_context_data(error='Invalid path, try again') return self.render_to_response(context) return self.handler(request,path)
def post(self,request): '''method to wrap the code for getting the true path and calling the actual code, which takes too paramaters, the request object and the path and returns an HttpResponse''' if 'path' in request.POST: try: path = Filesystem.getTruePath(request.POST['path']) except (ValueError, Filesystem.DoesNotExist, IOError): logger.debug(traceback.format_exc()) logger.info("Attempted access to invalid path: "+request.POST['path']) return HttpResponseBadRequest(self.invalidPathResult, mimetype=self.error_mimetype) return self.innerView(request,path) else: return HttpResponseBadRequest(self.noPathResult, mimetype=self.error_mimetype)
def applyFlats(request,path): '''apply the given flats to the supplied path''' try: flats = json.loads(request.POST['flats']) for filt,flat in flats.items(): flats[filt] = Filesystem.getTruePath(flat) improc = SecondPassProcessor(path) improc.applyFlats(flats) return okJSONResponse() except ValueError as e: return errorJSONResponse(str(e)) except Exception as e: #an unexpected exception logger.debug(traceback.format_exc()) #log the traceback raise e
def applyFlats(request, path): '''apply the given flats to the supplied path''' try: flats = json.loads(request.POST['flats']) for filt, flat in flats.items(): flats[filt] = Filesystem.getTruePath(flat) improc = SecondPassProcessor(path) improc.applyFlats(flats) return okJSONResponse() except ValueError as e: return errorJSONResponse(str(e)) except Exception as e: #an unexpected exception logger.debug(traceback.format_exc()) #log the traceback raise e
def post(self, request): '''method to wrap the code for getting the true path and calling the actual code, which takes too paramaters, the request object and the path and returns an HttpResponse''' if 'path' in request.POST: try: path = Filesystem.getTruePath(request.POST['path']) except (ValueError, Filesystem.DoesNotExist, IOError): logger.debug(traceback.format_exc()) logger.info("Attempted access to invalid path: " + request.POST['path']) return HttpResponseBadRequest(self.invalidPathResult, mimetype=self.error_mimetype) return self.innerView(request, path) else: return HttpResponseBadRequest(self.noPathResult, mimetype=self.error_mimetype)
def secondPass(request,path): '''perform the second pass over the folder i.e. apply flats and apply world coordinate system ''' try: if 'flats' not in request.POST: return HttpResponseBadRequest("No flats specified") flats = json.loads(request.POST['flats']) for filt,flat in flats.items(): flats[filt] = Filesystem.getTruePath(flat) doSecondPass(path,flats) return okJSONResponse() except ValueError as e: return errorJSONResponse(str(e)) except Exception as e: #an unexpected exception logger.debug(traceback.format_exc()) #log the traceback raise e
def secondPass(request, path): '''perform the second pass over the folder i.e. apply flats and apply world coordinate system ''' try: if 'flats' not in request.POST: return HttpResponseBadRequest("No flats specified") flats = json.loads(request.POST['flats']) for filt, flat in flats.items(): flats[filt] = Filesystem.getTruePath(flat) doSecondPass(path, flats) return okJSONResponse() except ValueError as e: return errorJSONResponse(str(e)) except Exception as e: #an unexpected exception logger.debug(traceback.format_exc()) #log the traceback raise e