Example #1
0
def flatSelectForm(request, path):
    '''Form for selecting flats'''
    context = {
        'improc': SecondPassProcessor(path),
        'path': Filesystem.getVirtualPath(path)
    }
    return render(request, 'reduction/flatFrameSelect.html', context)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
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
Example #6
0
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
Example #7
0
 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)
Example #8
0
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
Example #9
0
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
Example #10
0
def flatSelectForm(request, path):
    '''Form for selecting flats'''
    context = {'improc':SecondPassProcessor(path), 'path':Filesystem.getVirtualPath(path)}
    return render(request, 'reduction/flatFrameSelect.html',context)