#!/usr/bin/python
import os
from obsconfig import observatory
class FileList:
def __init__(self, loc=None):
self.message ="""Content-Type: text/xml
"""
self.error = None
if loc is None:
loc = observatory['rpfpath'][0]
else:
loc = int(loc)
if loc< 0 or loc >=len(observatory['rpfpath']):
self.error = "Invalid Path"
return
else:
loc = observatory['rpfpath'][loc]
if os.path.exists(loc) and os.path.isdir(loc):
self.files = filter(lambda x: x.lower().endswith("rpf"), os.listdir(loc))
if len(self.files) == 0:
self.error = "No rpfits files found"
else:
self.error = "Invalid Path"
def __str__(self):
if self.error:
self.message += "