Changeset 1282


Ignore:
Timestamp:
11/03/06 16:25:43 (18 years ago)
Author:
mar637
Message:

added filter to only list files with proper project codes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/Release2.1.1b/monitor/cgi-bin/filelist.py

    r739 r1282  
    11#!/usr/bin/python
    22import os
     3import sre
    34from obsconfig import observatory
    45
    56class FileList:
    67
    7     def __init__(self, loc=None):
     8    def __init__(self, loc=None, projectcode=None):
    89        self.message ="""Content-Type: text/xml
    910
    1011<?xml version="1.0" encoding="ISO-8859-1"?>"""
    11 
    1212        self.error = None
    1313        if loc is None:
     
    2121                loc = observatory['rpfpath'][loc]
    2222        if os.path.exists(loc) and os.path.isdir(loc):
    23             self.files = filter(lambda x: x.lower().endswith("rpf"), os.listdir(loc))
     23            rx = sre.compile("\d{4}-\d{2}-d{2}_\d{4}-M\d{3}.rpf.*")
     24            self.files = [ f for f in os.listdir(loc) if sre.match(rx, f) ]
     25            if projectcode is not None:
     26                self.files = [ f for f in self.files if sre.match(projectcode,
     27                                                                  f) ]
    2428            if len(self.files) == 0:
    2529                self.error = "No rpfits files found"
     
    4246    import cgi
    4347    form = cgi.FieldStorage()
     48    pfilter = None
     49    if form.has_key('project'):
     50        pfilter = form.getfirst("project", None)
    4451    if form.has_key('path'):
    4552        pathindex = form.getfirst("path",0)
    46         print FileList(pathindex)
     53        print FileList(pathindex, pfilter)
    4754    else:
    4855        print FileList()
Note: See TracChangeset for help on using the changeset viewer.