Ignore:
Timestamp:
07/10/10 09:40:54 (10 years ago)
Author:
astephen
Message:

Now we can have multiple basedirs set in the config file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/cows_wps/controllers/dirlist.py

    r7008 r7576  
    2828            return "ERROR: Please provide a valid proc_id." 
    2929 
     30        """ 
    3031        try: 
    3132            proc_config = createProcessConfig(proc_id)["Capabilities"] 
     
    4243        elif dr.find(basedir) < 0 and dr != basedir: 
    4344            return "ERROR: Invalid directory or not allowed." 
     45        """ 
     46        try: 
     47            proc_config = createProcessConfig(proc_id)["Capabilities"] 
     48            basedirs = proc_config["DataInputs"]["FilePath"]["basedir"] 
     49        except: 
     50            return "Unrecognised proc_id: %s" % proc_id 
     51 
     52        basedirs = [basedir.rstrip("/") for basedir in basedirs] 
     53 
     54        dr = os.path.split(path)[0] 
     55        top_dir = os.path.split(dr)[-1] 
     56 
     57        if not os.path.isdir(dr) or top_dir[0] == ".": 
     58            return "ERROR: Please provide a valid directory." 
     59        elif len([basedir for basedir in basedirs if dr.find(basedir) > -1]) == 0 and dr not in basedirs: 
     60             return "ERROR: Invalid directory or not allowed." 
    4461 
    4562        items = [os.path.join(dr, x) for x in os.listdir(dr) if x[0] != "."] 
Note: See TracChangeset for help on using the changeset viewer.