Skip to content

Commit

Permalink
Sanity checks on filesets
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Nov 28, 2012
1 parent 7b58741 commit 0d8f9b7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions moa/filesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

from moa.sysConf import sysConf

def tmpE(message):
moa.ui.error("Template error")
moa.ui.exitError(message)

def prepare(job):

try:
Expand All @@ -36,6 +40,29 @@ def prepare(job):
if not job.template.has_key('filesets'):
return

#do some sanity checking first
tinf = job.template.filesets
nosets = 0
for fs in tinf:
fsi = tinf[fs]
if not fsi.category in ['input', 'output', 'prerequisite']:
tmpE('Fileset "%s" has invalid category "%s"' % (
fs, fsi.category))
if not fsi.type in ['map', 'single', 'set']:
tmpE('Fileset "%s" has invalid type "%s"' % (
fs, fsi.type))

if fsi.type == 'set':
nosets += 1
elif fsi.type == 'map':
if not 'source' in fsi:
tmpE(('Fileset "%s" is of type map but has no "source" '
'configured') % (
fs))

if nosets > 1:
tmpE('More than one "set" fileset defined')

if len(job.template.filesets.keys()) > 0:
job.conf['moa_filesets'] = []
job.conf.doNotSave.append('moa_filesets')
Expand Down

0 comments on commit 0d8f9b7

Please sign in to comment.