XMLRPC test client rewritten to PHP.
This commit is contained in:
parent
4f5ba7085f
commit
62371a5ab0
3 changed files with 621 additions and 60 deletions
|
@ -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="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
#<metadata><title>ěščřžé</title></metadata>"
|
||||
METADATA="<?xml version=\"1.0\"?>
|
||||
<audioClip><metadata xmlns=\"http://www.streamonthefly.org/\"
|
||||
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
||||
xmlns:dcterms=\"http://purl.org/dc/terms/\">
|
||||
<dcterms:extent>00:00:11</dcterms:extent></metadata></audioClip>"
|
||||
|
||||
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="<?echo urldecode(\"$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="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<smil><head><metadata>
|
||||
<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/metadata/dublin_core#\">
|
||||
<dc:title>XY $DATE</dc:title>
|
||||
</rdf:RDF>
|
||||
</metadata></head><body><seq>
|
||||
<audio src=\"123456789abcdefa\"/>
|
||||
<audio src=\"123456789abcdefb\"/>
|
||||
</seq></body></smil>"
|
||||
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 <command> [args]"
|
||||
echo -e "commands:\n test, ...\n"
|
||||
echo "Usage: $0 [<command>] [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
|
||||
|
|
198
livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php
Normal file
198
livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/xmlrpc/xr_cli_test.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
include_once "../xmlrpc/XML/RPC.php";
|
||||
|
||||
$pars = $argv;
|
||||
array_shift($pars);
|
||||
$verbose = FALSE;
|
||||
if($pars[0] == '-v'){ $verbose = TRUE; array_shift($pars); }
|
||||
if($pars[0] == '-s'){
|
||||
array_shift($pars);
|
||||
$serverPath = array_shift($pars);
|
||||
}else $serverPath = 'http://localhost:80/livesupportArchiveServer/xmlrpc/xrLocStor.php';
|
||||
|
||||
#$serverPath = "http://localhost:80/livesupportArchiveServerCVS/xmlrpc/xrLocStor.php";
|
||||
|
||||
$url = parse_url($serverPath);
|
||||
$client = new XML_RPC_Client($url['path'], $url['host']);
|
||||
$method = array_shift($pars);
|
||||
|
||||
if($verbose){
|
||||
echo "serverPath: $serverPath\n";
|
||||
echo "host: {$url['host']}, path: {$url['path']}\n";
|
||||
echo "method: $method\n";
|
||||
echo "pars:\n";
|
||||
var_dump($pars);
|
||||
}
|
||||
|
||||
$infos = array(
|
||||
"listMethods" => 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";
|
||||
}
|
||||
|
||||
?>
|
|
@ -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://<server>/<path>/xmlrpc/xrGreenBox.php] <command> <args>
|
||||
Usage: xr_cli_pok.py [-v] [-s http://<server>/<path>/xmlrpc/xrLocStor.php] <command> <args>
|
||||
commands and args:
|
||||
listMethods
|
||||
methodHelp <method>
|
||||
methodSignature <method>
|
||||
ping <string>
|
||||
test <session_id> <teststring>
|
||||
login <username> <password>
|
||||
authenticate <username> <password>
|
||||
logout <session_id>
|
||||
...
|
||||
"""
|
||||
# existsAudioClip <session_id> <global_unique_id>
|
||||
# storeAudioClip <session_id> <global_unique_id> <media_file_path> <metadata_file_path>
|
||||
# deleteAudioClip <session_id> <global_unique_id>
|
||||
# updateAudioClipMetadata <session_id> <global_unique_id> <metadata_file_path>
|
||||
# searchMetadata <session_id> <criteria>
|
||||
# accessRawAudioData <session_id> <global_unique_id>
|
||||
# releaseRawAudioData <session_id> <tmp_link_path>
|
||||
# getAudioClip <session_id> <global_unique_id>
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue