From 0f1625db3815b5e388e0863b7806256036c31da4 Mon Sep 17 00:00:00 2001 From: tomas Date: Thu, 6 Jan 2005 01:10:01 +0000 Subject: [PATCH] Search method with structured query support added. (http://bugs.campware.org/view.php?id=481) (+probably: http://bugs.campware.org/view.php?id=513) +solved: http://bugs.campware.org/view.php?id=522 --- .../modules/storageServer/bin/resetStorage.sh | 41 +++++++++ .../modules/storageServer/doc/index.html | 38 ++++++++ .../modules/storageServer/doc/search.html | 67 +++++++++++++++ .../modules/storageServer/var/BasicStor.php | 61 ++++++------- .../modules/storageServer/var/GreenBox.php | 20 ++--- .../modules/storageServer/var/LocStor.php | 49 +++++++---- .../modules/storageServer/var/StoredFile.php | 20 ++++- .../storageServer/var/xmlrpc/testRunner.sh | 9 +- .../storageServer/var/xmlrpc/xrLocStor.php | 23 ++--- .../storageServer/var/xmlrpc/xr_cli_test.py | 86 ++++++++++++++----- 10 files changed, 310 insertions(+), 104 deletions(-) create mode 100755 livesupport/modules/storageServer/bin/resetStorage.sh create mode 100644 livesupport/modules/storageServer/doc/index.html create mode 100644 livesupport/modules/storageServer/doc/search.html diff --git a/livesupport/modules/storageServer/bin/resetStorage.sh b/livesupport/modules/storageServer/bin/resetStorage.sh new file mode 100755 index 000000000..16793455e --- /dev/null +++ b/livesupport/modules/storageServer/bin/resetStorage.sh @@ -0,0 +1,41 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# 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/storageServer/bin/resetStorage.sh,v $ +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# This script does httpd writeable directories setup +#------------------------------------------------------------------------------- + +reldir=`dirname $0`/.. +WWW_ROOT=`cd $reldir/var/install; php -q getWwwRoot.php` || exit $? +echo "# storageServer root URL: $WWW_ROOT" + +$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \ + resetStorage || exit $? + +echo "# resetStorage: OK" +exit 0 diff --git a/livesupport/modules/storageServer/doc/index.html b/livesupport/modules/storageServer/doc/index.html new file mode 100644 index 000000000..611efcae6 --- /dev/null +++ b/livesupport/modules/storageServer/doc/index.html @@ -0,0 +1,38 @@ + + + + + storageServer documentation + + + +

Preface

+This document is part of the +LiveSupport +project, Copyright © 2004 Media +Development Loan Fund, under the GNU GPL.
+ +

Scope

+This document collects storageServer documentation, both +generated and handwritten.
+

Introduction

+The links below provide useful documentation for the storageServer +developer or user.
+

Static documentation.

+ +

Generated documentation

+ +
+ + diff --git a/livesupport/modules/storageServer/doc/search.html b/livesupport/modules/storageServer/doc/search.html new file mode 100644 index 000000000..a3a3d4306 --- /dev/null +++ b/livesupport/modules/storageServer/doc/search.html @@ -0,0 +1,67 @@ + + + + + storageServer search query format description + + + +

Preface

+This document is part of the +LiveSupport +project, Copyright © 2004 Media +Development Loan Fund, under the GNU GPL.
+ +

Scope

+This document describes search query format for searching in storageServer +metadata database.
+

Introduction

+How to call search methods: + + +

Criteria format (php/xmlrpc)

+Type: hash/struct with following fields:
+ + +

Return value

+Hash/struct with fields:
+ + + +
+ + diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php index 23b676a40..1ebe43baf 100644 --- a/livesupport/modules/storageServer/var/BasicStor.php +++ b/livesupport/modules/storageServer/var/BasicStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ ------------------------------------------------------------------------------*/ @@ -48,7 +48,7 @@ require_once "Transport.php"; * Core of LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * @see Alib */ class BasicStor extends Alib{ @@ -487,69 +487,64 @@ class BasicStor extends Alib{ } /** - * Search in local metadata database.
- * TODO: NOT FINISHED
- * It will support structured queries - array of mode and query parts. - * Mode is "match all" or "match any". - * Query parts is array of [fieldname, operator, value] entities. + * Search in local metadata database. * - * @param criteria string, search query - - * only one SQL LIKE term supported now. - * It will be searched in all literal object values - * in metadata database - * @return array of gunid strings + * @param criteria hash, search criteria - see + * format description + * @return hash, field 'results' is an array with gunid strings + * of files have been found */ function bsLocalSearch($criteria) { - $types = array('and'=>'AND', 'or'=>'OR'); + $operators = array('and'=>'AND', 'or'=>'OR'); $ops = array('full'=>"='%s'", 'partial'=>"like '%%%s%%'", 'prefix'=>"like '%s%%'", '<'=>"< '%s'", '='=>"= '%s'", '>'=>"> '%s'", '<='=>"<= '%s'", '>='=>">= '%s'" ); -# var_dump($criteria); - echo "\n"; - $type = strtolower($criteria['type']); - $conds = $criteria['conds']; - $whereArr = array(); + $operator = strtolower($criteria['operator']); + $conds = $criteria['conditions']; + $whereArr = array(); foreach($conds as $cond){ $cat = strtolower($cond['cat']); - $opVal = sprintf($ops[$cond['op']], strtolower($cond['val'])); + $opVal = sprintf($ops[$cond['op']], + addslashes(strtolower($cond['val']))); + // escape % for sprintf in whereArr construction: + $cat = str_replace("%", "%%", $cat); + $opVal = str_replace("%", "%%", $opVal); $sqlCond = " - %s.predicate = '".str_replace("%", "%%", $cat)."' AND - %s.objns='_L' AND lower(%s.object) ".str_replace("%", "%%", $opVal)."\n + %s.predicate = '{$cat}' AND + %s.objns='_L' AND lower(%s.object) {$opVal}\n "; -# echo "$sqlCond\n"; $whereArr[] = "$sqlCond"; } - if($type == 'and'){ + if($operator == 'and'){ + // operator: and $from = array(); $joinArr = array(); foreach($whereArr as $i=>$v){ $from[] = "{$this->mdataTable} md$i"; $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i"); $joinArr[] = "md$i.gunid = md".($i+1).".gunid"; } + // there are n-1 join condtions for join n tables - remove last: array_pop($joinArr); + // query construcion: $sql = "SELECT to_hex(md0.gunid)as gunid \nFROM ".join(", ", $from). "\nWHERE ".join(' AND ', $whereArr); + // add join conditions if there are any: if(count($joinArr)>0){ $sql .= " AND ".join(" AND ", $joinArr); } }else{ + // operator: or foreach($whereArr as $i=>$v){ $whereArr[$i] = sprintf($v, "md", "md", "md"); } + // query construcion: $sql = "\nSELECT to_hex(gunid)as gunid \n". "FROM {$this->mdataTable} md \nWHERE ".join(' OR ', $whereArr); } - echo "$sql\n"; -# var_dump($whereArr); - $sql0 = "SELECT to_hex(md.gunid)as gunid - FROM {$this->filesTable} f, {$this->mdataTable} md - WHERE f.gunid=md.gunid AND md.objns='_L' AND - md.object like '%$criteria%' - GROUP BY md.gunid - "; $res = $this->dbc->getCol($sql); if(!is_array($res)) $res = array(); - // $res = array_map("StoredFile::_normalizeGunid", $res); // TODO: correct! - return $res; + $res = array_map(array("StoredFile", "_normalizeGunid"), $res); +# return array('sql'=>$sql, 'results'=>$res); + return array('results'=>$res); } /* --------------------------------------------------------- info methods */ diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php index b4619991b..68f88a93c 100644 --- a/livesupport/modules/storageServer/var/GreenBox.php +++ b/livesupport/modules/storageServer/var/GreenBox.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ ------------------------------------------------------------------------------*/ @@ -35,7 +35,7 @@ require_once "BasicStor.php"; * LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.16 $ + * @version $Revision: 1.17 $ * @see BasicStor */ class GreenBox extends BasicStor{ @@ -258,19 +258,13 @@ class GreenBox extends BasicStor{ } /** - * Search in local metadata database.
- * TODO: NOT FINISHED
- * It will support structured queries - array of mode and query parts. - * Mode is "match all" or "match any". - * Query parts is array of [fieldname, operator, value] entities. + * Search in local metadata database. * - * - * @param criteria string, search query - - * only one SQL LIKE term supported now. - * It will be searched in all literal object values - * in metadata database + * @param criteria hash, search criteria - see + * format description * @param sessid string, session id - * @return array of gunid strings + * @return hash, field 'results' is an array with gunid strings + * of files have been found */ function localSearch($criteria, $sessid='') { diff --git a/livesupport/modules/storageServer/var/LocStor.php b/livesupport/modules/storageServer/var/LocStor.php index 3dae01997..edfd9abff 100644 --- a/livesupport/modules/storageServer/var/LocStor.php +++ b/livesupport/modules/storageServer/var/LocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.15 $ + Version : $Revision: 1.16 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,13 @@ class LocStor extends GreenBox{ * * @param sessid string * @param gunid string - * @param metadata string with metadata XML + * @param metadata string, metadata XML string + * @param fname string, human readable menmonic file name + * with extension corresponding to filetype * @param chsum string, md5 checksum of media file * @return struct {url:writable URL for HTTP PUT, token:access token */ - function storeAudioClipOpen($sessid, $gunid, $metadata, $chsum) + function storeAudioClipOpen($sessid, $gunid, $metadata, $fname, $chsum) { // test if specified gunid exists: if(!preg_match("|^([0-9a-fA-F]{16})?$|", $gunid)){ @@ -71,12 +73,12 @@ class LocStor extends GreenBox{ if(PEAR::isError($res)) return $res; }else{ // gunid doesn't exists - do insert - $tmpid = uniqid(''); + $tmpFname = uniqid(''); $parid = $this->_getHomeDirId($sessid); if(PEAR::isError($parid)) return $parid; if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) return $res; - $oid = $this->addObj($tmpid , 'File', $parid); + $oid = $this->addObj($tmpFname , 'File', $parid); if(PEAR::isError($oid)) return $oid; $ac =& StoredFile::insert( &$this, $oid, '', '', $metadata, 'string', @@ -86,11 +88,15 @@ class LocStor extends GreenBox{ $res = $this->removeObj($oid); return $ac; } - $res = $this->renameFile($oid, $ac->gunid, $sessid); if(PEAR::isError($res)) return $res; } $res = $ac->setState('incomplete'); if(PEAR::isError($res)) return $res; + if($fname == ''){ + $fname = "newFile"; + } + $res = $this->renameFile($oid, $fname, $sessid); + if(PEAR::isError($res)) return $res; return $this->bsOpenPut($chsum, $ac->gunid); } @@ -105,11 +111,11 @@ class LocStor extends GreenBox{ { $ac =& StoredFile::recallByToken(&$this, $token); if(PEAR::isError($ac)){ return $ac; } - $fname = $this->bsClosePut($token); - if(PEAR::isError($fname)){ $ac->delete(); return $fname; } - $res = $ac->replaceRawMediaData($fname); + $tmpFname = $this->bsClosePut($token); + if(PEAR::isError($tmpFname)){ $ac->delete(); return $tmpFname; } + $res = $ac->replaceRawMediaData($tmpFname); if(PEAR::isError($res)){ return $res; } - if(file_exists($fname)) @unlink($fname); + if(file_exists($tmpFname)) @unlink($tmpFname); $res = $ac->setState('ready'); if(PEAR::isError($res)) return $res; return $ac->gunid; @@ -341,17 +347,20 @@ class LocStor extends GreenBox{ { $this->deleteData(); $rootHD = $this->getObjId('root', $this->storId); - $this->login('root', $this->config['tmpRootPass']); - $s = $this->sessid; +# $this->login('root', $this->config['tmpRootPass']); +# $s = $this->sessid; include"../tests/sampleData.php"; $res = array(); foreach($sampleData as $k=>$it){ list($media, $meta) = $it; - $r = $this->putFile($rootHD, "file".($k+1), $media, $meta, $s); +# $r = $this->putFile($rootHD, "file".($k+1), $media, $meta, $s); + $r = $this->bsPutFile( + $rootHD, basename($media), $media, $meta, '', 'audioclip' + ); if(PEAR::isError($r)){ return $r; } $res[] = $this->_gunidFromId($r); } - $this->logout($this->sessid); +# $this->logout($this->sessid); return $res; } @@ -362,9 +371,10 @@ class LocStor extends GreenBox{ * * @param sessid string, session ID * @param playlistId string, playlist global unique ID + * @param fname string, human readable menmonic file name * @return string, playlist global unique ID */ - function createPlaylist($sessid, $playlistId) + function createPlaylist($sessid, $playlistId, $fname) { $ex = $this->existsPlaylist($sessid, $playlistId); if(PEAR::isError($ex)){ return $ex; } @@ -373,12 +383,12 @@ class LocStor extends GreenBox{ 'LocStor.php: createPlaylist: already exists' ); } - $tmpid = uniqid(''); + $tmpFname = uniqid(''); $parid = $this->_getHomeDirId($sessid); if(PEAR::isError($parid)) return $parid; if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) return $res; - $oid = $this->addObj($tmpid , 'File', $parid); + $oid = $this->addObj($tmpFname , 'File', $parid); if(PEAR::isError($oid)) return $oid; $ac =& StoredFile::insert(&$this, $oid, '', '', '', @@ -388,7 +398,10 @@ class LocStor extends GreenBox{ $res = $this->removeObj($oid); return $ac; } - $res = $this->renameFile($oid, $ac->gunid, $sessid); + if($fname == ''){ + $fname = "newFile.xml"; + } + $res = $this->renameFile($oid, $fname, $sessid); if(PEAR::isError($res)) return $res; $res = $ac->setState('ready'); if(PEAR::isError($res)) return $res; diff --git a/livesupport/modules/storageServer/var/StoredFile.php b/livesupport/modules/storageServer/var/StoredFile.php index 93339c958..ba9c01692 100644 --- a/livesupport/modules/storageServer/var/StoredFile.php +++ b/livesupport/modules/storageServer/var/StoredFile.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.12 $ + Version : $Revision: 1.13 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $ ------------------------------------------------------------------------------*/ @@ -550,6 +550,9 @@ class StoredFile{ */ function _getExt() { + $fname = $this->_getFileName(); + $ext = substr($fname, strrpos($fname, '.')+1); + if($ext !== FALSE) return $ext; switch(strtolower($this->mime)){ case"audio/mpeg": $ext="mp3"; break; @@ -611,6 +614,21 @@ class StoredFile{ "); } + /** + * Get mnemonic file name + * + * @param gunid string, optional, global unique id of file + * @return string, see install() + */ + function _getFileName($gunid=NULL) + { + if(is_null($gunid)) $gunid = $this->gunid; + return $this->dbc->getOne(" + SELECT name FROM {$this->filesTable} + WHERE gunid=x'$gunid'::bigint + "); + } + /** * Get and optionaly create subdirectory in real filesystem for storing * raw media data diff --git a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh index d18e3c449..ba19c19ea 100755 --- a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh +++ b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh @@ -23,7 +23,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.11 $ +# Version : $Revision: 1.12 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $ #------------------------------------------------------------------------------- @@ -65,13 +65,11 @@ existsAudioClip() { } storeAudioClip() { -# echo -n "# storeAudioClip: " -# MEDIA=../tests/ex1.mp3 MEDIA=var/tests/ex1.mp3 MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done echo "md5=$MD5" echo -n "# storeAudioClipOpen: " - RES=`$XR_CLI storeAudioClipOpen "$SESSID" '' "$METADATA" "$MD5"` || \ + 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 @@ -127,7 +125,6 @@ downloadMeta() { echo $URL if [ $DEBUG ]; then echo -n "Press enter ..."; read KEY; fi echo -n "# curl: " -# curl -Ifs $URL > /dev/null || { ERN=$?; echo $RES; exit $ERN; } METAOUT=`curl -fs $URL;` || { ERN=$?; echo $RES; exit $ERN; } echo "OK" if [ $DEBUG ]; then echo $METAOUT; echo -n "Press enter ..."; read KEY; fi @@ -169,7 +166,7 @@ PLID="123456789abcdef2" createPlaylist() { echo -n "# createPlaylist: " - $XR_CLI createPlaylist $SESSID $PLID || exit $? + $XR_CLI createPlaylist $SESSID $PLID "newPlaylist.xml" || exit $? } accessPlaylist() { diff --git a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php index c125f4d08..51409973c 100644 --- a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php +++ b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.13 $ + Version : $Revision: 1.14 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -225,8 +225,10 @@ class XR_LocStor extends LocStor{ * * * On success, returns a XML-RPC struct: @@ -254,7 +256,7 @@ class XR_LocStor extends LocStor{ list($ok, $r) = $this->_xr_getPars($input); if(!$ok) return $r; $res = $this->storeAudioClipOpen( - $r['sessid'], $r['gunid'], $r['metadata'], $r['chsum'] + $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['chsum'] ); if(PEAR::isError($res)){ return new XML_RPC_Response(0, 805, @@ -646,6 +648,7 @@ class XR_LocStor extends LocStor{ * * * On success, returns a XML-RPC struct with single field: @@ -671,7 +674,7 @@ class XR_LocStor extends LocStor{ { list($ok, $r) = $this->_xr_getPars($input); if(!$ok) return $r; - $res = $this->createPlaylist($r['sessid'], $r['plid']); + $res = $this->createPlaylist($r['sessid'], $r['plid'], $r['fname']); if(PEAR::isError($res)){ return new XML_RPC_Response(0, 805, "xr_createPlaylist: ".$res->getMessage(). @@ -1153,15 +1156,13 @@ class XR_LocStor extends LocStor{ * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. @@ -1190,7 +1191,7 @@ class XR_LocStor extends LocStor{ " ".$res->getUserInfo() ); } - return new XML_RPC_Response(XML_RPC_encode(array('results'=>$res))); + return new XML_RPC_Response(XML_RPC_encode($res)); } /** diff --git a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py index b8c5e7f84..632daa674 100755 --- a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py +++ b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py @@ -24,7 +24,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.9 $ +# Version : $Revision: 1.10 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $ # #------------------------------------------------------------------------------ @@ -73,7 +73,6 @@ if verbose: print "pars: " print pars print "result:" -#sys.exit(0) try: if method=="listMethods": @@ -85,59 +84,103 @@ try: elif method=="test": print server.locstor.test({'sessid':pars[0], 'teststring':pars[1]}) elif method=="authenticate": - print server.locstor.authenticate({'login':pars[0], 'pass':pars[1]})['authenticate'] + print server.locstor.authenticate( + {'login':pars[0], 'pass':pars[1]} + )['authenticate'] elif method=="login": - print server.locstor.login({'login':pars[0], 'pass':pars[1]})['sessid'] + print server.locstor.login( + {'login':pars[0], 'pass':pars[1]} + )['sessid'] elif method=="logout": print server.locstor.logout({'sessid':pars[0]}) elif method=="storeAudioClipOpen": - r = server.locstor.storeAudioClipOpen({'sessid':pars[0], 'gunid':pars[1], 'metadata':pars[2], 'chsum':pars[3]}) + r = server.locstor.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.locstor.storeAudioClipClose({'sessid':pars[0], 'token':pars[1]})['gunid'] + print server.locstor.storeAudioClipClose( + {'sessid':pars[0], 'token':pars[1]} + )['gunid'] elif method=="accessRawAudioData": - r = server.locstor.accessRawAudioData({'sessid':pars[0], 'gunid':pars[1]}) + r = server.locstor.accessRawAudioData( + {'sessid':pars[0], 'gunid':pars[1]} + ) print r['url']+'\n'+r['token'] elif method=="releaseRawAudioData": - print server.locstor.releaseRawAudioData({'sessid':pars[0], 'token':pars[1]}) + print server.locstor.releaseRawAudioData( + {'sessid':pars[0], 'token':pars[1]} + ) elif method=="downloadRawAudioDataOpen": - r = server.locstor.downloadRawAudioDataOpen({'sessid':pars[0], 'gunid':pars[1]}) + r = server.locstor.downloadRawAudioDataOpen( + {'sessid':pars[0], 'gunid':pars[1]} + ) print r['url']+'\n'+r['token'] elif method=="downloadRawAudioDataClose": - print server.locstor.downloadRawAudioDataClose({'sessid':pars[0], 'token':pars[1]}) + print server.locstor.downloadRawAudioDataClose( + {'sessid':pars[0], 'token':pars[1]} + ) elif method=="downloadMetadataOpen": - r = server.locstor.downloadMetadataOpen({'sessid':pars[0], 'gunid':pars[1]}) + r = server.locstor.downloadMetadataOpen( + {'sessid':pars[0], 'gunid':pars[1]} + ) print r['url']+'\n'+r['token'] elif method=="downloadMetadataClose": - print server.locstor.downloadMetadataClose({'sessid':pars[0], 'token':pars[1]}) + print server.locstor.downloadMetadataClose( + {'sessid':pars[0], 'token':pars[1]} + ) elif method=="deleteAudioClip": - print server.locstor.deleteAudioClip({'sessid':pars[0], 'gunid':pars[1]}) + print server.locstor.deleteAudioClip( + {'sessid':pars[0], 'gunid':pars[1]} + ) elif method=="existsAudioClip": - print server.locstor.existsAudioClip({'sessid':pars[0], 'gunid':pars[1]}) + print server.locstor.existsAudioClip( + {'sessid':pars[0], 'gunid':pars[1]} + ) elif method=="updateAudioClipMetadata": - print server.locstor.updateAudioClipMetadata({'sessid':pars[0], 'gunid':pars[1], 'metadata':pars[2]}) + print server.locstor.updateAudioClipMetadata( + {'sessid':pars[0], 'gunid':pars[1], 'metadata':pars[2]} + ) elif method=="searchMetadata": # print server.locstor.searchMetadata({'sessid':pars[0], 'criteria':pars[1]}) - print server.locstor.searchMetadata({'sessid':pars[0], 'criteria':{'type':'and', 'conds':['a', 'b']}}) + print server.locstor.searchMetadata( + {'sessid':pars[0], + 'criteria':{ + 'filetype':'audioclip', + 'operator':'and', + 'conditions':[ + {'cat':pars[1], 'op':'partial', 'val':pars[2]} + ] + } + } + ) elif method=="existsPlaylist": print server.locstor.existsPlaylist({'sessid':pars[0], 'plid':pars[1]}) elif method=="playlistIsAvailable": - print server.locstor.playlistIsAvailable({'sessid':pars[0], 'plid':pars[1]}) + print server.locstor.playlistIsAvailable( + {'sessid':pars[0], 'plid':pars[1]} + ) elif method=="createPlaylist": - print server.locstor.createPlaylist({'sessid':pars[0], 'plid':pars[1]}) + print server.locstor.createPlaylist( + {'sessid':pars[0], 'plid':pars[1], 'fname':pars[2]} + ) elif method=="editPlaylist": r = server.locstor.editPlaylist({'sessid':pars[0], 'plid':pars[1]}) print r['url']+'\n'+r['token'] elif method=="savePlaylist": - print server.locstor.savePlaylist({'sessid':pars[0], 'token':pars[1], 'newPlaylist':pars[2]}) + print server.locstor.savePlaylist( + {'sessid':pars[0], 'token':pars[1], 'newPlaylist':pars[2]} + ) elif method=="deletePlaylist": print server.locstor.deletePlaylist({'sessid':pars[0], 'plid':pars[1]}) elif method=="accessPlaylist": r = server.locstor.accessPlaylist({'sessid':pars[0], 'plid':pars[1]}) print r['url']+'\n'+r['token'] elif method=="releasePlaylist": - print server.locstor.releasePlaylist({'sessid':pars[0], 'token':pars[1]}) - + print server.locstor.releasePlaylist( + {'sessid':pars[0], 'token':pars[1]} + ) elif method=="getAudioClip": r = server.locstor.getAudioClip({'sessid':pars[0], 'gunid':pars[1]}) print r['metadata'] @@ -151,5 +194,4 @@ try: print "Unknown command: "+method sys.exit(1) except Error, v: -# print "XML-RPC Error:",v sys.exit(v)