Exemplo n.º 1
0
import sys, json, time
import raws_json
from raws_json.raws_service import RawsService, Feed, Query, RequestError
from raws_json.meta.meta import *
from raws_json.meta.vocab import Vocab
from raws_json.rass.service import RassService
from raws_json.meta.service import MetaService

# initialize client
rass = RassService(username = USER, password = PWD, server = RASS_SERVER)
meta = MetaService(username = USER, password = PWD)

try:
    # upload some files to the the 'meta_sample' dir on the CDN (so we can attach metadata to them)
    item1 = rass.createItem("meta_sample/", "elephants_dream.mp4", LOCAL_FILE)
    item1b = rass.createItem("meta_sample/", "elephants_dream.jpg", LOCAL_FILE)
    print "Created item instances : %s + %s " % (item1["entry"]["id"], item1b["entry"]["id"])
    item2 = rass.createItem("meta_sample/", "big_buck_bunny.mp4", LOCAL_FILE)
    print "Created item instance : %s " % item2["entry"]["id"]
    item3 = rass.createItem("meta_sample/", "sintel.mp4", LOCAL_FILE)
    print "Created item instance : %s " % item3["entry"]["id"]
    item4 = rass.createItem("meta_sample/", "yo_frankie.mp4", LOCAL_FILE) # we will not attach metadata to this item
    print "Created item instance : %s " % item4["entry"]["id"]

    # create vocabs
    if not meta.vocabExists(name = "media"):
        vocab_obj = Vocab(name = "media", description = "Media RSS", xml_namespace = "http://search.yahoo.com/mrss/")
        vocab = meta.createVocab(vocab_obj.to_entry())
        print "Created vocab instance : %s " % vocab["entry"]["id"]
    if not meta.vocabExists(name = "myvocab"):
Exemplo n.º 2
0
import sys, json, time
import raws_json
from raws_json.raws_service import RawsService, Feed, Query, RequestError
from raws_json.rass.service import RassService

try:
    # initialize client
    rass = RassService(username = USER, password = PWD, server = RASS_SERVER)

    # create a dir on the CDN
    dir = rass.createDir("crud_test/", True)
    print "Created dir with relative path = '%s'" % dir["entry"]["content"]["params"]["path"]

    # upload a file to a sub-directory (which will be created if it doesn't exist)
    item = rass.createItem("crud_test/subdir/", "filename.mp4", LOCAL_FILE)
    print "Created item with relative path = '%s' and size = %s" % (item["entry"]["content"]["params"]["path"], dir["entry"]["content"]["params"]["size"])
    
    # get list of all files in "crud_test/subdir/"
    print "Getting a list of all files in 'crud_test/subdir/' ..."
    feed = rass.getDirList(path = "crud_test/subdir/", query = Query(params = {"kind":"file"}))
    feed_obj = Feed(feed)
    for item in feed_obj.entries:
        print ".. found file with path = '%s', item instance url = %s" % (item["entry"]["content"]["params"]["path"], item["entry"]["id"])
        
    # check if file exists
    if rass.itemExists(item["entry"]["content"]["params"]["path"]):
        # delete file from CDN
        rass.deleteItem(item["entry"]["content"]["params"]["path"])

    # check if dir exists