Skip to content

Commit

Permalink
small fixes & moa tree [something] works now
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiers committed Apr 1, 2011
1 parent 6e50786 commit dd67552
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
6 changes: 3 additions & 3 deletions lib/python/moa/plugin/adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@

def defineCommands(data):
data['commands']['adhoc'] = {
'desc' : 'Quickly create an adhoc analysis',
'desc' : 'Create an adhoc analysis',
'call' : createAdhoc,
'needsJob' : False,
'usage' : 'moa adhoc -t "title" -- echo "do something"'
}
data['commands']['simple'] = {
'desc' : 'Quickly create a "simple" adhoc analysis',
'desc' : 'Create a "simple" adhoc analysis',
'call' : createSimple,
'needsJob' : False,
'usage' : 'moa simple -t "title" -- echo "do something"'
}
data['commands']['map'] = {
'desc' : 'Quickly create a "map" adhoc analysis',
'desc' : 'Create a "map" adhoc analysis',
'call' : createMap,
'needsJob' : False,
'usage' : 'moa map -t "title" -- echo "do something"',
Expand Down
24 changes: 14 additions & 10 deletions lib/python/moa/plugin/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def defineCommands(data):
'log' : False
}
data['commands']['tree'] = {
'desc' : 'Print a directory tree with extra information',
'desc' : 'display a directory tree',
'call' : tree,
'needsJob' : False,
'log' : False
Expand All @@ -67,25 +67,29 @@ def defineCommands(data):
def tree(data):
wd = data.wd
filt = data.args[1:]

for path, dirs, files in os.walk(data.wd):
rpath = path.replace(wd, '')[1:]

if filt and not rpath:
for d in dirs:
if d in filt: continue
dirs.remove(d)

remove = set(dirs) - set(filt)
if not rpath and filt:
while True:
for r in remove:
if r in dirs:
dirs.remove(r)
break
else:
break

isMoa = '.moa' in dirs
while '.moa' in dirs: dirs.remove('.moa')
for d in dirs:
if d[0] == '.': dirs.remove(d)
dirs.sort()

if not rpath: lev = 0
else: lev = rpath.count('/') + 1

if not isMoa:
moa.ui.fprint('.. %s./%s' % (' ' * lev, rpath), f='jinja')
moa.ui.fprint('(..) %s./%s' % (' ' * lev, rpath), f='jinja')
continue
tag = '{{green}}M{{reset}}'
statusFile = os.path.join(path, '.moa', 'status')
Expand All @@ -99,7 +103,7 @@ def tree(data):
'error' : '{{red}}E{{reset}}',
'interrupted' : '{{blue}}I{{reset}}'
}.get(message, '{{green}}?{{reset}}')
moa.ui.fprint("%s%s %s./%s" % ( tag, status, ' ' * lev, rpath),
moa.ui.fprint("(%s%s) %s./%s" % ( tag, status, ' ' * lev, rpath),
f = 'jinja')


Expand Down
52 changes: 27 additions & 25 deletions lib/python/moa/plugin/moautil.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@
import moa.logger as l
import moa.ui

COPYTEST = '''
mkdir 10.test
cd 10.test
moa simple -t "test" -- echo "hello"
cd ..
moa cp 10.test 20 2>/dev/null
cd 20.test
output=`moa run`
[[ "$output" =~ "hello" ]] || (echo "invalid output"; false)
cd ..
pwd
moa cp 10.test 30.test2 2>/dev/null
cd 30.test2
output=`moa run`
[[ "$output" =~ "hello" ]] || (echo "invalid output"; false)
cd ../10.test
mkdir 05.subtest
cd 05.subtest
moa simple -t "test2" -- echo "subtest"
cd ../../
moa cp 10.test 40.test 2>/dev/null
[[ ! -d "40.test/05.subtest" ]] || (echo "subdirectory should not be there"; false)
moa cp -r 10.test 50.test 2>/dev/null
[[ -d "50.test/05.subtest" ]] || (echo "subdirectory is not there?"; false)
'''
def defineCommands(data):
data['commands']['cp'] = {
'desc' : 'Copy a moa job',
Expand Down Expand Up @@ -228,3 +203,30 @@ def _copyMoaDir(job, toDir):
if not os.path.exists(thisToDir):
os.makedirs(thisToDir)
shutil.copyfile(fromFile, toFile)

#Unittest scripts

COPYTEST = '''
mkdir 10.test
cd 10.test
moa simple -t "test" -- echo "hello"
cd ..
moa cp 10.test 20 2>/dev/null
cd 20.test
output=`moa run`
[[ "$output" =~ "hello" ]] || (echo "invalid output"; false)
cd ..
moa cp 10.test 30.test2 2>/dev/null
cd 30.test2
output=`moa run`
[[ "$output" =~ "hello" ]] || (echo "invalid output"; false)
cd ../10.test
mkdir 05.subtest
cd 05.subtest
moa simple -t "test2" -- echo "subtest"
cd ../../
moa cp 10.test 40.test 2>/dev/null
[[ ! -d "40.test/05.subtest" ]] || (echo "subdirectory should not be there"; false)
moa cp -r 10.test 50.test 2>/dev/null
[[ -d "50.test/05.subtest" ]] || (echo "subdirectory is not there?"; false)
'''
2 changes: 1 addition & 1 deletion lib/python/moa/plugin/newjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def defineCommands(data):
data['commands']['new'] = {
'desc' : "Create a new Moa job in the this directory",
'desc' : "Create a new Moa job",
'call' : newJob,
'needsJob' : False
}
Expand Down

0 comments on commit dd67552

Please sign in to comment.