From 62371a5ab0376e93524cbaf50fa1fd2717525233 Mon Sep 17 00:00:00 2001 From: tomas Date: Wed, 19 Jan 2005 05:07:35 +0000 Subject: [PATCH] XMLRPC test client rewritten to PHP. --- .../archiveServer/var/xmlrpc/testRunner.sh | 349 +++++++++++++++--- .../archiveServer/var/xmlrpc/xr_cli_test.php | 198 ++++++++++ .../archiveServer/var/xmlrpc/xr_cli_test.py | 134 ++++++- 3 files changed, 621 insertions(+), 60 deletions(-) create mode 100644 livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php diff --git a/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh b/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh index 4b16100fa..0238e3f69 100755 --- a/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh +++ b/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh @@ -23,80 +23,335 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.2 $ +# Version : $Revision: 1.3 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh,v $ #------------------------------------------------------------------------------- +#DEBUG=yes +#DEBUG_I=yes + COMM=$1 shift GUNID=$1 -XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $? -echo " archiveServer XMLRPC URL:" -echo $XMLRPC +#METADATA=" +#ěščřžé" +METADATA=" + +00:00:11" -TESTDIR=`dirname $0` -XR_CLI="$TESTDIR/xr_cli_test.py -s $XMLRPC" +echo "" +XRDIR=`dirname $0` +XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $? +echo "# storageServer XMLRPC URL: $XMLRPC" + +cd $XRDIR +#XR_CLI="./xr_cli_test.py -s ${XMLRPC}" +XR_CLI="php -q xr_cli_test.php -s ${XMLRPC}" login() { - echo "login:" - SESSID=`$XR_CLI login root q` + echo -n "# login: " + SESSID=`$XR_CLI login root q` || \ + { ERN=$?; echo $SESSID; exit $ERN; } echo "sessid: $SESSID" } -ping() { - echo "ping:" - $XR_CLI ping abcDef +test() { + echo "# test: " + $XR_CLI test $SESSID stringForUppercase || exit $? } -# existsAudioClip() { -# echo "existsAudioClip:" -# $XR_CLI existsAudioClip $SESSID $GUNID -# } - -downloadOpenClose() { - echo "downloadOpen:" - FURL=`$XR_CLI downloadOpen $SESSID $GUNID` - FURL="" - FURL=`echo "$FURL" | php -q` - echo $FURL -# ls -l `dirname $FURL` - echo "downloadClose:" - $XR_CLI downloadClose $SESSID $FURL -#$XR_CLI getAudioClip $SESSID $GUNID +existsAudioClip() { + echo -n "# existsAudioClip (${GUNID}): " + $XR_CLI existsAudioClip $SESSID $GUNID || exit $? } -# storeAudioClip() { -# echo "storeAudioClip:" -# MEDIA=../tests/ex1.mp3 -# METADATA=../tests/testStorage.xml -# RGUNID=`$XR_CLI storeAudioClip "$SESSID" 'X' "$MEDIA" "$METADATA"` -# echo $RGUNID -# } +storeAudioClip() { + MEDIA=../tests/ex1.mp3 + MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done + if [ $DEBUG_I ]; then echo "md5=$MD5"; fi + echo -n "# storeAudioClipOpen: " + RES=`$XR_CLI storeAudioClipOpen "$SESSID" '' "$METADATA" "stored file.mp3" "$MD5"` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN + if [ $DEBUG_I ]; then echo $URL; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# curl (PUT): " + curl -C 0 -T $MEDIA $URL || { ERN=$?; echo $RGUNID; exit $ERN; } + echo "status: $?" + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# storeAudioClipClose: " + RGUNID=`$XR_CLI storeAudioClipClose "$SESSID" "$TOKEN"` || \ + { ERN=$?; echo $RGUNID; exit $ERN; } + echo $RGUNID +} -# searchMetadata() { -# echo "searchMetadata:" -# # $XR_CLI searchMetadata $SESSID '../tests/srch_cri1.xml' -# $XR_CLI searchMetadata $SESSID 'John %' -# } +accessRawAudioData() { + echo -n "# accessRawAudioData: " + RES=`$XR_CLI accessRawAudioData $SESSID $GUNID` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN + if [ $DEBUG_I ]; then echo $URL; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# releaseRawAudioData: " + $XR_CLI releaseRawAudioData $SESSID $TOKEN || exit $? +} + +downloadRAD() { + echo -n "# downloadRawAudioDataOpen: " + RES=`$XR_CLI downloadRawAudioDataOpen $SESSID $GUNID` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN + if [ $DEBUG_I ]; then echo $URL; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# curl: " + curl -Ifs $URL > /dev/null || { ERN=$?; echo $URL; exit $ERN; } + echo "status: $?" + echo -n "# downloadRawAudioDataClose: " + $XR_CLI downloadRawAudioDataClose $SESSID $TOKEN || exit $? +} + +downloadMeta() { + echo -n "# downloadMetadataOpen: " + RES=`$XR_CLI downloadMetadataOpen $SESSID $GUNID` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN + if [ $DEBUG_I ]; then echo $URL; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# curl: " + METAOUT=`curl -fs $URL;` || { ERN=$?; echo $RES; exit $ERN; } + echo "OK" + if [ $DEBUG_I ]; then echo $METAOUT; echo -n "Press enter ..."; read KEY; fi + echo -n "# metadata check:" + if [ "x$METAOUT" != "x$METADATA" ] ; then + echo " NOT MATCH" + echo " Expected:"; echo $METADATA + echo " Downloaded:"; echo $METAOUT + exit 1 + else + echo " OK" + fi + echo -n "# downloadMetadataClose: " + $XR_CLI downloadMetadataClose $SESSID $TOKEN || exit $? +} + +deleteAudioClip() { + echo -n "# deleteAudioClip: " + $XR_CLI deleteAudioClip $SESSID $GUNID || exit $? +} + +updateAudioClipMetadata() { + echo -n "#updateAudioClipMetadata: " + $XR_CLI updateAudioClipMetadata $SESSID $GUNID "$METADATA" || exit $? +} + +getAudioClip() { + echo -n "#getAudioClip: " + $XR_CLI getAudioClip $SESSID $GUNID || exit $? +} + +searchMetadata() { + echo -n "# searchMetadata: " +# $XR_CLI searchMetadata $SESSID '../tests/srch_cri1.xml' || exit $? + $XR_CLI searchMetadata $SESSID 'John %' || exit $? +} + +PLID="123456789abcdef8" + +createPlaylist() { + echo -n "# createPlaylist: " + $XR_CLI createPlaylist $SESSID $PLID "newPlaylist.xml" || exit $? +} + +accessPlaylist() { + echo -n "# accessPlaylist: " + RES=`$XR_CLI accessPlaylist $SESSID $PLID` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN + if [ $DEBUG_I ]; then echo $URL; fi + echo "# curl: " + CURLOUT=`curl -fs $URL;` || { ERN=$?; echo $RES; exit $ERN; } + if [ $DEBUG ]; then echo $CURLOUT; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo "# status: $?" + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + echo -n "# releasePlaylist: " + $XR_CLI releasePlaylist $SESSID $TOKEN || exit $? +} + +editPlaylist() { + DATE=`date '+%H:%M:%S'` + PLAYLIST=" + + + XY $DATE + + + " + echo -n "# editPlaylist: " + RES=`$XR_CLI editPlaylist $SESSID $PLID` || \ + { ERN=$?; echo $RES; exit $ERN; } + unset URL + for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done + echo $TOKEN +# deletePlaylist + if [ $DEBUG_I ]; then echo $URL; fi + if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi + if [ $DEBUG_I ]; then echo " Playlist:"; echo $PLAYLIST; fi + echo -n "# savePlaylist: " + $XR_CLI savePlaylist $SESSID $TOKEN "$PLAYLIST" || exit $? +} + +existsPlaylist() { + echo -n "# existsPlaylist (${PLID}): " + $XR_CLI existsPlaylist $SESSID $PLID || exit $? +} + +deletePlaylist() { + echo -n "# deletePlaylist (${PLID}): " + $XR_CLI deletePlaylist $SESSID $PLID + # || exit $? + echo "# status: $?" +} + +prefTest() { + PREFKEY="testKey" + PREFVAL="test preference value" + echo -n "# savePref: " + $XR_CLI savePref $SESSID "$PREFKEY" "$PREFVAL"|| exit $? + echo -n "# loadPref: " + VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \ + { ERN=$?; echo $VAL; exit $ERN; } + echo "$VAL " + if [ "x$VAL" != "x$PREFVAL" ] ; then + echo " NOT MATCH" + echo " Expected:"; echo $PREFVAL + echo " Returned:"; echo $VAL + exit 1 + else + echo "# pref value check: OK" + fi + echo -n "# delPref: " + $XR_CLI delPref $SESSID "$PREFKEY"|| exit $? + if [ $DEBUG ]; then + echo -n "# loadPref: " + VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || echo $? + else + echo $VAL + fi +} logout() { - echo "logout:" - $XR_CLI logout $SESSID + echo -n "# logout: " + $XR_CLI logout $SESSID || exit $? +} + +preferenceTest(){ + echo "#XMLRPC preference test" + login + prefTest + logout + echo "#XMLRPC: preference: OK." + echo "" +} + +playlistTest(){ + echo "#XMLRPC playlists test" + login + existsPlaylist + deletePlaylist + createPlaylist + existsPlaylist + accessPlaylist + editPlaylist + accessPlaylist + deletePlaylist + existsPlaylist + logout + echo "#XMLRPC: playlists: OK." + echo "" +} + +storageTest(){ + echo "#XMLRPC: storage test" + login + storeAudioClip + GUNID=$RGUNID + existsAudioClip + accessRawAudioData + downloadRAD + downloadMeta + deleteAudioClip + existsAudioClip + logout + echo "#XMLRPC: storage: OK." + echo "" } usage(){ - echo "Usage: $0 [args]" - echo -e "commands:\n test, ...\n" + echo "Usage: $0 [] [args]" + echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData" + echo -e " storeAudioClip\n deleteAudioClip\n updateAudioClipMetadata" + echo -e " getAudioClip\n searchMetadata\n" + echo -e " preferences\n playlists\n storage\n" } -if [ "$COMM" == "ping" ]; then - ping -elif [ "x$COMM" == "x" ]; then -# echo "No action" +if [ "$COMM" == "test" ]; then login - downloadOpenClose + test logout +elif [ "$COMM" == "existsAudioClip" ]; then + login + existsAudioClip + logout +elif [ "$COMM" == "accessRawAudioData" ]; then + login + accessRawAudioData + logout +elif [ "$COMM" == "storeAudioClip" ]; then + login + storeAudioClip + logout +elif [ "$COMM" == "deleteAudioClip" ]; then + login + deleteAudioClip + logout +elif [ "$COMM" == "updateAudioClipMetadata" ]; then + login + updateAudioClipMetadata + logout +elif [ "$COMM" == "getAudioClip" ]; then + login + getAudioClip + logout +elif [ "$COMM" == "searchMetadata" ]; then + login + searchMetadata + logout +elif [ "$COMM" == "preferences" ]; then + preferenceTest +elif [ "$COMM" == "playlists" ]; then + playlistTest +elif [ "$COMM" == "storage" ]; then + storageTest +elif [ "x$COMM" == "x" ]; then + storageTest +# playlistTest +# preferenceTest elif [ "$COMM" == "help" ]; then usage else diff --git a/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php b/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php new file mode 100644 index 000000000..15ada655e --- /dev/null +++ b/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php @@ -0,0 +1,198 @@ + array('m'=>"system.listMethods", 'p'=>NULL), + "methodHelp" => array('m'=>"system.methodHelp", 'p'=>0), + "methodSignature" => array('m'=>"system.methodSignature", 'p'=>0), + "test" => + array('m'=>"archive.test", 'p'=>array('sessid', 'teststring')), + "authenticate" => array('m'=>"archive.authenticate", + 'p'=>array('login', 'pass'), 'r'=>'authenticate'), + "login" => array('m'=>"archive.login", + 'p'=>array('login', 'pass'), 'r'=>'sessid'), + "logout" => array('m'=>"archive.logout", + 'p'=>array('sessid'), 'r'=>'status'), + + "storeAudioClipOpen" => array('m'=>"archive.storeAudioClipOpen", + 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'), + 'r'=>array('url', 'token') + ), + "storeAudioClipClose" => array('m'=>"archive.storeAudioClipClose", + 'p'=>array('sessid', 'token'), 'r'=>'gunid'), + "accessRawAudioData" => array('m'=>"archive.accessRawAudioData", + 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), + "releaseRawAudioData" => array('m'=>"archive.releaseRawAudioData", + 'p'=>array('sessid', 'token'), 'r'=>'status'), + "downloadRawAudioDataOpen" => + array('m'=>"archive.downloadRawAudioDataOpen", + 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), + "downloadRawAudioDataClose" => + array('m'=>"archive.downloadRawAudioDataClose", + 'p'=>array('sessid', 'token'), 'r'=>'gunid'), + "downloadMetadataOpen" => array('m'=>"archive.downloadMetadataOpen", + 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), + "downloadMetadataClose" => array('m'=>"archive.downloadMetadataClose", + 'p'=>array('sessid', 'token'), 'r'=>'gunid'), + + "deleteAudioClip" => + array('m'=>"archive.deleteAudioClip", + 'p'=>array('sessid', 'gunid'), 'r'=>'status'), + "existsAudioClip" => array('m'=>"archive.existsAudioClip", + 'p'=>array('sessid', 'gunid'), 'r'=>'exists'), + "getAudioClip" => array('m'=>"archive.getAudioClip", + 'p'=>array('sessid', 'gunid'), 'r'=>'metadata'), + "updateAudioClipMetadata" => array('m'=>"archive.updateAudioClipMetadata", + 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), + "searchMetadata" => array('m'=>"archive.searchMetadata", 'p'=>NULL), + "resetStorage" => array('m'=>"archive.resetStorage", 'p'=>array()), + + "createPlaylist" => array('m'=>"archive.createPlaylist", + 'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'), + "editPlaylist" => array('m'=>"archive.editPlaylist", + 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), + "savePlaylist" => array('m'=>"archive.savePlaylist", + 'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'), + "deletePlaylist" => array('m'=>"archive.deletePlaylist", + 'p'=>array('sessid', 'plid'), 'r'=>'status'), + "accessPlaylist" => array('m'=>"archive.accessPlaylist", + 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), + "releasePlaylist" => array('m'=>"archive.releasePlaylist", + 'p'=>array('sessid', 'token'), 'r'=>'plid'), + "existsPlaylist" => array('m'=>"archive.existsPlaylist", + 'p'=>array('sessid', 'plid'), 'r'=>'exists'), + "playlistIsAvailable" => array('m'=>"archive.playlistIsAvailable", + 'p'=>array('sessid', 'plid'), 'r'=>'available'), + + "loadPref" => array('m'=>"archive.loadPref", + 'p'=>array('sessid', 'key'), 'r'=>'value'), + "savePref" => array('m'=>"archive.savePref", + 'p'=>array('sessid', 'key', 'value'), 'r'=>'status'), + "delPref" => array('m'=>"archive.delPref", + 'p'=>array('sessid', 'key'), 'r'=>'status'), + "openPut" => array('m'=>"archive.openPut", 'p'=>array()), + "closePut" => array('m'=>"archive.closePut", 'p'=>array()), +); + + +$fullmethod = $infos[$method]['m']; +$pinfo = $infos[$method]['p']; +if(is_null($pinfo)){ + $parr = NULL; +}elseif(!is_array($pinfo)){ + $parr = $pars[0]; + #echo "pinfo not null and not array.\n"; exit; +}elseif(count($pinfo) == 0){ + $parr = array(); +}else{ + $parr = array(); $i=0; + foreach($pinfo as $it){ + $parr[$it] = $pars[$i++]; + } +} +if($method == 'searchMetadata'){ + $parr = array( + 'sessid'=>$pars[0], + 'criteria'=>array( + 'filetype'=>'audioclip', + 'operator'=>'and', + 'limit'=> 0, + 'offset'=> 0, + 'conditions'=>array( + array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2]) + ) + ), + ); +} +$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr))); + +if($verbose){ + echo "parr:\n"; + var_dump($parr); + echo "message:\n"; + echo $msg->serialize()."\n"; +} + +$res = $client->send($msg); +if($res->faultCode() > 0) { + echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n"; + exit(1); +} + +if($verbose){ + echo "result:\n"; + echo $res->serialize(); +} + +$resp = XML_RPC_decode($res->value()); +if(isset($infos[$method]['r'])){ + $pom = $infos[$method]['r']; + if(is_array($pom)){ + foreach($pom as $k=>$it) $pom[$k] = $resp[$it]; + echo join(' ', $pom)."\n"; + }else switch($pom){ + case"status": + case"exists": + echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n"; + break; + default: + echo "{$resp[$pom]}\n"; + } +}else{ + print_r($resp); +# echo"\n"; +} + +?> diff --git a/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.py b/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.py index 0353fdfed..26c555a57 100755 --- a/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.py +++ b/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.py @@ -24,7 +24,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.1 $ +# Version : $Revision: 1.2 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/xmlrpc/Attic/xr_cli_test.py,v $ # #------------------------------------------------------------------------------ @@ -34,15 +34,25 @@ import sys if len(sys.argv)<3: print """ - Usage: xr_cli_pok.py [-v] [-s http:////xmlrpc/xrGreenBox.php] + Usage: xr_cli_pok.py [-v] [-s http:////xmlrpc/xrLocStor.php] commands and args: listMethods methodHelp methodSignature - ping + test login + authenticate logout + ... """ +# existsAudioClip +# storeAudioClip +# deleteAudioClip +# updateAudioClipMetadata +# searchMetadata +# accessRawAudioData +# releaseRawAudioData +# getAudioClip sys.exit(1) pars = sys.argv @@ -54,7 +64,7 @@ if pars[1]=="-s": pars.pop(1) serverPath = pars.pop(1) else: - serverPath = 'http://localhost:80/storage/xmlrpc/xrLocStor.php' + serverPath = 'http://localhost:80/livesupportArchiveServer/xmlrpc/xrArchive.php' server = Server(serverPath) method = pars.pop(1) pars.pop(0) @@ -63,7 +73,6 @@ if verbose: print "pars: " print pars print "result:" -#sys.exit(0) try: if method=="listMethods": @@ -72,18 +81,117 @@ try: print server.system.methodHelp(pars[0]) elif method=="methodSignature": print server.system.methodSignature(pars[0]) - elif method=="ping": - print server.archive.ping({'par':pars[0]}) + elif method=="test": + print server.archive.test({'sessid':pars[0], 'teststring':pars[1]}) + elif method=="authenticate": + print server.archive.authenticate( + {'login':pars[0], 'pass':pars[1]} + )['authenticate'] elif method=="login": - print server.archive.login({'login':pars[0], 'pass':pars[1]}) + print server.archive.login( + {'login':pars[0], 'pass':pars[1]} + )['sessid'] elif method=="logout": print server.archive.logout({'sessid':pars[0]}) - elif method=="downloadOpen": - print server.archive.downloadOpen({'sessid':pars[0], 'gunid':pars[1]}) - elif method=="downloadClose": - print server.archive.downloadClose({'sessid':pars[0], 'url':pars[1]}) + elif method=="storeAudioClipOpen": + r = server.archive.storeAudioClipOpen({ + 'sessid':pars[0], 'gunid':pars[1], 'metadata':pars[2], + 'fname':pars[3], 'chsum':pars[4] + }) + print r['url']+'\n'+r['token'] + elif method=="storeAudioClipClose": + print server.archive.storeAudioClipClose( + {'sessid':pars[0], 'token':pars[1]} + )['gunid'] + elif method=="accessRawAudioData": + r = server.archive.accessRawAudioData( + {'sessid':pars[0], 'gunid':pars[1]} + ) + print r['url']+'\n'+r['token'] + elif method=="releaseRawAudioData": + print server.archive.releaseRawAudioData( + {'sessid':pars[0], 'token':pars[1]} + ) + elif method=="downloadRawAudioDataOpen": + r = server.archive.downloadRawAudioDataOpen( + {'sessid':pars[0], 'gunid':pars[1]} + ) + print r['url']+'\n'+r['token'] + elif method=="downloadRawAudioDataClose": + print server.archive.downloadRawAudioDataClose( + {'sessid':pars[0], 'token':pars[1]} + ) + elif method=="downloadMetadataOpen": + r = server.archive.downloadMetadataOpen( + {'sessid':pars[0], 'gunid':pars[1]} + ) + print r['url']+'\n'+r['token'] + elif method=="downloadMetadataClose": + print server.archive.downloadMetadataClose( + {'sessid':pars[0], 'token':pars[1]} + ) + elif method=="deleteAudioClip": + print server.archive.deleteAudioClip( + {'sessid':pars[0], 'gunid':pars[1]} + ) + elif method=="existsAudioClip": + print server.archive.existsAudioClip( + {'sessid':pars[0], 'gunid':pars[1]} + ) + elif method=="updateAudioClipMetadata": + print server.archive.updateAudioClipMetadata( + {'sessid':pars[0], 'gunid':pars[1], 'metadata':pars[2]} + ) + elif method=="searchMetadata": +# print server.archive.searchMetadata({'sessid':pars[0], 'criteria':pars[1]}) + print server.archive.searchMetadata( + {'sessid':pars[0], + 'criteria':{ + 'filetype':'audioclip', + 'operator':'and', + 'conditions':[ + {'cat':pars[1], 'op':'partial', 'val':pars[2]} + ] + } + } + ) + elif method=="existsPlaylist": + print server.archive.existsPlaylist({'sessid':pars[0], 'plid':pars[1]}) + elif method=="playlistIsAvailable": + print server.archive.playlistIsAvailable( + {'sessid':pars[0], 'plid':pars[1]} + ) + elif method=="createPlaylist": + print server.archive.createPlaylist( + {'sessid':pars[0], 'plid':pars[1], 'fname':pars[2]} + ) + elif method=="editPlaylist": + r = server.archive.editPlaylist({'sessid':pars[0], 'plid':pars[1]}) + print r['url']+'\n'+r['token'] + elif method=="savePlaylist": + print server.archive.savePlaylist( + {'sessid':pars[0], 'token':pars[1], 'newPlaylist':pars[2]} + ) + elif method=="deletePlaylist": + print server.archive.deletePlaylist({'sessid':pars[0], 'plid':pars[1]}) + elif method=="accessPlaylist": + r = server.archive.accessPlaylist({'sessid':pars[0], 'plid':pars[1]}) + print r['url']+'\n'+r['token'] + elif method=="releasePlaylist": + print server.archive.releasePlaylist( + {'sessid':pars[0], 'token':pars[1]} + ) + elif method=="getAudioClip": + r = server.archive.getAudioClip({'sessid':pars[0], 'gunid':pars[1]}) + print r['metadata'] + elif method=="resetStorage": + print server.archive.resetStorage({}) + elif method=="openPut": + r = server.archive.openPut({}); print r['url']+'\n'+r['token'] + elif method=="closePut": + print server.archive.closePut({'token':pars[0], 'chsum':pars[1]}) else: print "Unknown command: "+method sys.exit(1) except Error, v: - print "XML-RPC Error:",v + sys.exit(v)