Changeset 1295 for trunk/monitor


Ignore:
Timestamp:
11/06/06 22:22:03 (18 years ago)
Author:
mar637
Message:

merge form Release2.1.1 branch

Location:
trunk/monitor/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/monitor/cgi-bin/asapmon.py

    r1083 r1295  
    1010abspath= "/var/www/asapmon/"
    1111cgiloc = "/cgi-bin/asapmon/"
    12 tmppath = abspath+"tmp/"
     12tmppath = os.path.join(abspath,"tmp/")
    1313htmlloc = "/asapmon/"
    1414tmploc = "/asapmon/tmp/"
     
    2525logsink = WritableObject()
    2626logsink2 = WritableObject()
    27 sys.stdout =logsink
     27sys.stdout = logsink
    2828sys.stderr = logsink2
    2929import asap
     
    5353        out = []
    5454        for i in fi:
    55             out.append(p+"/"+fl.files[i])
     55            out.append(os.path.join(p,fl.files[i]))
    5656        return out
    5757
    5858    def decodeWindow(self,window):
    5959        if not len(window.strip()): return None,None
    60         x = window.split(",")
    61         return [float(x[0].strip()),float(x[1].strip())]
    62 
    63     def decodeWindows(self,window):
     60        x = window.split(", ")
     61        return [float(x[0].strip()), float(x[1].strip())]
     62
     63    def decodeWindows(self, window):
    6464        import re
    6565        p = re.compile("(\\[*\d+\\.*\d*,\d+\\.*\d*\\]*)")
    6666        r = re.compile("[\\[\\]]")
    67         return [self.decodeWindow(re.sub(r,'',s)) for s in re.findall(p,window)]
     67        return [self.decodeWindow(re.sub(r, '', s)) for s in re.findall(p, window)]
    6868
    6969    def setDefaultFields(self):
     
    8080        self.fields['imagename'] = ""
    8181        self.fields['cunit'] = 0
    82         self.fields['units'] = ["channel","km/s","GHz"]
     82        self.fields['units'] = ["channel", "km/s", "GHz"]
    8383        self.fields['baseline'] = 0
    8484        self.fields['cpolyorder'] = 0
     
    8787        self.fields['doppler'] = "RADIO"
    8888        self.fields['frame'] = "LSRK"
    89         self.fields['restn'] = [11,1]
     89        self.fields['restn'] = [11, 1]
    9090        self.fields['stokes'] = 0
    9191        self.fields['summary'] = ""
     
    9898
    9999    def getFormFields(self):
    100         self.fields['cunit'] = int(self.form.getfirst("unit",0))
    101         self.fields['frame'] = self.form.getfirst("frame","TOPO")
    102         self.fields['doppler'] = self.form.getfirst("doppler","RADIO")
     100        self.fields['cunit'] = int(self.form.getfirst("unit", 0))
     101        self.fields['frame'] = self.form.getfirst("frame", "TOPO")
     102        self.fields['doppler'] = self.form.getfirst("doppler", "RADIO")
    103103        self.fields['restn'] = []
    104104
    105         self.fields['plotwindow'] = self.form.getfirst("plotwindow","")
     105        self.fields['plotwindow'] = self.form.getfirst("plotwindow", "")
    106106        self.fields['baseline'] = int(self.form.has_key("baseline"))
    107         self.fields['cpolyorder'] = int(self.form.getfirst("polyorder",0))
     107        self.fields['cpolyorder'] = int(self.form.getfirst("polyorder", 0))
    108108        self.fields['quotient'] = int(self.form.has_key("quotient"))
    109         self.fields['doppler'] = self.form.getfirst("doppler","RADIO")
    110         self.fields['frame'] = self.form.getfirst("frame","LSRK")
    111         self.fields['cdir'] = int(self.form.getfirst("dlist",None))
     109        self.fields['doppler'] = self.form.getfirst("doppler", "RADIO")
     110        self.fields['frame'] = self.form.getfirst("frame", "LSRK")
     111        self.fields['cdir'] = int(self.form.getfirst("dlist", None))
    112112        self.fields['cfile'] = [int(k) for k in self.form.getlist("list")]
    113113        self.fields['average'] = int(self.form.has_key("average"))
     
    115115        self.fields['bin'] = int(self.form.has_key("bin"))
    116116        self.fields['debug'] = ""#self.fields['restn']
    117         self.fields['csource'] = self.form.getfirst("csource","")
     117        self.fields['csource'] = self.form.getfirst("csource", "")
    118118
    119119    def getRest(self):
     
    140140            for i in self.fields['nif']:
    141141                name = "rest%d" % i
    142                 self.fields['restn'].append(int(self.form.getfirst(name,0)))
     142                self.fields['restn'].append(int(self.form.getfirst(name, 0)))
    143143            restfs = self.getRest()
    144144
     
    151151                if i:
    152152                    # filter off scans
    153                     i = not re.search(re.compile("_[R,e,w]$"),i) and i
     153                    i = not re.search(re.compile("_[R, e, w]$"), i) and i
    154154                    if i:
    155155                        self.fields['sourcenames'].append(i)
     
    162162                if cs in self.fields['sourcenames']:
    163163                    ss = s.get_scan(self.fields['csource'])
    164                     if isinstance(ss,asap.scantable):
     164                    if isinstance(ss, asap.scantable):
    165165                        s = ss
    166166                    del ss
     
    172172            if self.fields['cunit'] == 1:
    173173                srest = s._getrestfreqs()
    174                 if isinstance(srest,tuple) and len(srest) != s.nif():
    175                     s.set_restfreqs(restfs,unit="GHz")
     174                if isinstance(srest, tuple) and len(srest) != s.nif():
     175                    s.set_restfreqs(restfs, unit="GHz")
    176176            s.set_unit(self.fields['units'][self.fields['cunit']])
    177             s.set_freqframe(self.form.getfirst("frame","LSRK"))
    178             s.set_doppler(self.form.getfirst("doppler","RADIO"))
     177            s.set_freqframe(self.form.getfirst("frame", "LSRK"))
     178            s.set_doppler(self.form.getfirst("doppler", "RADIO"))
    179179
    180180            # baseline
     
    189189                        self.fields['brangewindow'] = brstr
    190190                        m = s.create_mask(brange)
    191                         s.poly_baseline(mask=m,order=order)
     191                        s.poly_baseline(mask=m, order=order)
    192192                else:
    193193                    s.auto_poly_baseline(order=order)
     
    217217            asap.plotter = asap.asapplotter(False)
    218218            if outscans.nif() > 1:
    219                 asap.plotter.set_mode("p","i")
     219                asap.plotter.set_mode("p", "i")
    220220            else:
    221221                if outscans.npol() > 2:
    222                     asap.plotter.set_mode("t","p")
     222                    asap.plotter.set_mode("t", "p")
    223223                else:
    224                     asap.plotter.set_mode("p","t")
     224                    asap.plotter.set_mode("p", "t")
    225225            asap.plotter.plot(outscans)
    226226            if self.fields['stokes']:
     
    231231                sel.set_polarisations(pols)
    232232                asap.plotter.set_selection(sel)
    233             x0,x1 = self.decodeWindow(self.fields['plotwindow'])
    234             asap.plotter.set_range(x0,x1)
     233            x0, x1 = self.decodeWindow(self.fields['plotwindow'])
     234            asap.plotter.set_range(x0, x1)
    235235            imname = tmppath+"plot.png"
    236             asap.plotter.save(imname,dpi=96)
     236            asap.plotter.save(imname, dpi=96)
    237237            self.fields['imagename'] = tmploc+"plot.png"
    238         except RuntimeError,e:
     238        except RuntimeError, e:
    239239            self.fields['debug'] = e
    240240            return
  • trunk/monitor/cgi-bin/filelist.py

    r739 r1295  
    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.