Showing the changes to python (8 of 8 files). Show all
Unified · Split
Empty file added.
| @@ -0,0 +1,25 @@ | ||
| 1 | +from config import * | |
| 2 | + | |
| 3 | +class run_broadcast: | |
| 4 | + def __init__(self,command,*args): | |
| 5 | + for host in REMOTEHOSTS: | |
| 6 | + command(host,args[0],args[1:]) | |
| 7 | + | |
| 8 | +def remote_sync(host,path='',options=''): | |
| 9 | + optstring = '' | |
| 10 | + for i in options: | |
| 11 | + optstring = "%s %s" % (optstring,i) | |
| 12 | + print RSYNC_CMD,optstring,RSYNC_OPT,' --delete', | |
| 13 | + print '%s%s%s%s%s' % (path,'/ ',host,':',path) | |
| 14 | + | |
| 15 | + | |
| 16 | +def fetch_results(host,path='',options=''): | |
| 17 | + optstring = '' | |
| 18 | + for i in options: | |
| 19 | + optstring = "%s %s" % (optstring,i) | |
| 20 | + print RSYNC_CMD,optstring,RSYNC_OPT,' --update', | |
| 21 | + print '%s%s%s%s%s' % (host,':',path,'/ ',path) | |
| 22 | + | |
| 23 | +def remote_queue(host,command,options=''): | |
| 24 | + print 'oarsub -p "hostname = \'',host,'\'',command | |
| 25 | + | |
| @@ -0,0 +1,21 @@ | ||
| 1 | + | |
| 2 | +filefound = 0 | |
| 3 | +try: | |
| 4 | + filename = "/etc/aubio-bench.conf" | |
| 5 | + execfile(filename) | |
| 6 | + filefound = 1 | |
| 7 | +except IOError: | |
| 8 | + print "no system wide configuration file found in", filename | |
| 9 | + | |
| 10 | +try: | |
| 11 | + import os | |
| 12 | + filename = "%s%s%s" % (os.getenv('HOME'),os.sep,".aubio-bench.conf") | |
| 13 | + execfile(filename) | |
| 14 | + filefound = 1 | |
| 15 | +except IOError: | |
| 16 | + print "no user configuration file found in", filename | |
| 17 | + | |
| 18 | +if filefound == 0: | |
| 19 | + import sys | |
| 20 | + print "error: no configuration file found at all" | |
| 21 | + sys.exit(1) | |
| @@ -0,0 +1,48 @@ | ||
| 1 | +from config import * | |
| 2 | +import commands,sys | |
| 3 | +import re | |
| 4 | + | |
| 5 | +def runcommand(cmd,debug=0): | |
| 6 | + if VERBOSE >= VERBOSE_CMD or debug: print cmd | |
| 7 | + if debug: return | |
| 8 | + status, output = commands.getstatusoutput(cmd) | |
| 9 | + if status == 0 or VERBOSE >= VERBOSE_OUT: | |
| 10 | + output = output.split('\n') | |
| 11 | + if VERBOSE >= VERBOSE_OUT: | |
| 12 | + for i in output: | |
| 13 | + if i: print i | |
| 14 | + if not status == 0: | |
| 15 | + print 'error:',status,output | |
| 16 | + print 'command returning error was',cmd | |
| 17 | + sys.exit(1) | |
| 18 | + return output | |
| 19 | + | |
| 20 | +def list_files(datapath,filter='f'): | |
| 21 | + cmd = '%s%s%s%s' % ('find ',datapath,' -type ',filter) | |
| 22 | + return runcommand(cmd) | |
| 23 | + | |
| 24 | +def mkdir(path): | |
| 25 | + cmd = '%s%s' % ('mkdir -p ',path) | |
| 26 | + return runcommand(cmd) | |
| 27 | + | |
| 28 | +def act_on_data (action,datapath,respath,suffix='.txt',filter='f'): | |
| 29 | + """ execute action(datafile,resfile) on all files in datapath """ | |
| 30 | + dirlist = list_files(datapath,filter=filter) | |
| 31 | + respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] | |
| 32 | + if(respath_in_datapath and suffix == ''): | |
| 33 | + print 'error: respath in datapath and no suffix used' | |
| 34 | + sys.exit(1) | |
| 35 | + for i in dirlist: | |
| 36 | + s = re.split(datapath, i,maxsplit=1)[1] | |
| 37 | + j = "%s%s%s%s"%(respath,'/',s,suffix) | |
| 38 | + action(i,j) | |
| 39 | + | |
| 40 | +def act_on_results (action,datapath,respath,filter='d'): | |
| 41 | + """ execute action(respath) an all subdirectories in respath """ | |
| 42 | + dirlist = list_files(datapath,filter='d') | |
| 43 | + respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] | |
| 44 | + if(respath_in_datapath and not filter == 'd' and suffix == ''): | |
| 45 | + print 'warning: respath is in datapath' | |
| 46 | + for i in dirlist: | |
| 47 | + s = re.split(datapath, i ,maxsplit=1)[1] | |
| 48 | + action("%s%s%s"%(respath,'/',s)) | |
| @@ -0,0 +1,9 @@ | ||
| 1 | +#! /usr/bin/python | |
| 2 | + | |
| 3 | +from aubio.bench.broadcast import * | |
| 4 | + | |
| 5 | +run_broadcast(remote_sync,'/home/testing') | |
| 6 | +run_broadcast(remote_sync,'/home/testing','-n') | |
| 7 | +run_broadcast(fetch_results,'/home/testing','-n') | |
| 8 | + | |
| 9 | +run_broadcast(remote_queue,'echo coucou') | |
| @@ -0,0 +1,35 @@ | ||
| 1 | +#! /usr/bin/python | |
| 2 | + | |
| 3 | +from aubio.bench.config import * | |
| 4 | +from aubio.bench.node import * | |
| 5 | + | |
| 6 | +datapath = "%s%s" % (DATADIR,'/onset/DB') | |
| 7 | +respath = '/var/tmp/DB-testings' | |
| 8 | + | |
| 9 | +MODES = 'hfc', 'complexdomain', 'energy', 'phase', 'specdiff', 'kl', 'mkl' | |
| 10 | +THRESHOLD = range(1,14,1) | |
| 11 | + | |
| 12 | +# prepareresultpath | |
| 13 | +act_on_results(mkdir,datapath,respath,filter='d') | |
| 14 | + | |
| 15 | +def compute_data(input,output): | |
| 16 | + aubiocmd = "%s%s %s%s" % \ | |
| 17 | + ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/examples/aubioonset") | |
| 18 | + for m in MODES: | |
| 19 | + for k in THRESHOLD: | |
| 20 | + cmd = "%s --input \"%s\" --onset %s --threshold %s > \"%s--%s--%s.txt\"" \ | |
| 21 | + % (aubiocmd,input,m,k/10.,output,m,k/10.) | |
| 22 | + runcommand(cmd,debug=1) | |
| 23 | + | |
| 24 | + | |
| 25 | +# computedata | |
| 26 | +act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'') | |
| 27 | + | |
| 28 | +# gatherdata | |
| 29 | +#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') | |
| 30 | +# gatherthreshold | |
| 31 | +# gathermodes | |
| 32 | +# comparediffs | |
| 33 | +# gatherdiffs | |
| 34 | + | |
| 35 | + | |
| @@ -0,0 +1,34 @@ | ||
| 1 | +#! /usr/bin/python | |
| 2 | + | |
| 3 | +#from conf.aubio_benchrc import * | |
| 4 | +from aubio.bench.config import * | |
| 5 | +from aubio.bench.node import * | |
| 6 | +import os | |
| 7 | + | |
| 8 | +datapath = "%s%s" % (DATADIR,'/pitch/isolated/piano/011pfnof') | |
| 9 | +respath = '/var/tmp/isolated/testing' | |
| 10 | + | |
| 11 | +MODES = 'yin', 'mcomb', 'fcomb', 'schmitt' | |
| 12 | + | |
| 13 | +# prepareresultpath | |
| 14 | +act_on_results(mkdir,datapath,respath,filter='d') | |
| 15 | + | |
| 16 | +def compute_data(input,output): | |
| 17 | + aubiocmd = "%s%s %s%s" % \ | |
| 18 | + ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/python/aubiopitch") | |
| 19 | + for m in MODES: | |
| 20 | + cmd = "%s --input \"%s\" --mode %s --verbose --units midi > \"%s--%s.txt\"" \ | |
| 21 | + % (aubiocmd,input,m,output,m) | |
| 22 | + runcommand(cmd,debug=0) | |
| 23 | + | |
| 24 | + | |
| 25 | +# computedata | |
| 26 | +act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'') | |
| 27 | + | |
| 28 | +# gatherdata | |
| 29 | +#act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') | |
| 30 | +# gatherthreshold | |
| 31 | +# gathermodes | |
| 32 | +# comparediffs | |
| 33 | +# gatherdiffs | |
| 34 | + | |
| @@ -0,0 +1,13 @@ | ||
| 1 | +#! /usr/bin/python | |
| 2 | + | |
| 3 | +from aubio.bench.node import * | |
| 4 | + | |
| 5 | +datapath = '/var/www' | |
| 6 | +respath = '/var/tmp' | |
| 7 | + | |
| 8 | +def my_print(input,output): | |
| 9 | + cmd = "%s %s %s" % ("time sleep 0.3; echo",input,output) | |
| 10 | + return runcommand(cmd,debug=0) | |
| 11 | + | |
| 12 | +act_on_results(mkdir,datapath,respath,filter='d') | |
| 13 | +act_on_data(my_print,datapath,respath,suffix='.txt') | |