Ejemplo n.º 1
0
import sys
import os

root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

"""
Let's assume we want access our in-app API. This is what DummyClient is for.
"""

client = DummyClient(Route(MyAPI, framework='dummy'),
                     access_key='secret key')
print "5 + 2 =", client.add(a=5, b=2)
try:
    print client.test()
except RemoteException, e:
    print "Remote exception raised:", unicode(e)
Ejemplo n.º 2
0
from mongoengine import connect
import sys
import os
import time

connect('simpleapitest')

root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy'))
print "Add?", client.add()
print "Get?", client.get()
Ejemplo n.º 3
0
from mongoengine import connect
import sys
import os
import time

connect('simpleapitest')

root = os.path.abspath(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy'))
print "Add?", client.add()
print "Get?", client.get()
Ejemplo n.º 4
0
import sys
import os

root = os.path.abspath(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy', debug=True))
try:
    client.add_one(a=1, b=5)
except RemoteException, e:
    print "Exception raised:", e
client.download(url="http://www.pizzabus.de")
Ejemplo n.º 5
0
import sys
import os
os.environ['SIMPLEAPI_DEBUG'] = '1' # activate simpleapi-wide debug
os.environ['SIMPLEAPI_DEBUG_LEVEL'] = 'call' # either call (for profiling every call) or all (for profiling all calls accumulated)

root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy'))
for i in xrange(3):
    client.add_one(a=1, b=5)
Ejemplo n.º 6
0
import sys
import os

root = os.path.abspath(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI
"""
Let's assume we want access our in-app API. This is what DummyClient is for.
"""

client = DummyClient(Route(MyAPI, framework='dummy'), access_key='secret key')
print "5 + 2 =", client.add(a=5, b=2)
try:
    print client.test()
except RemoteException, e:
    print "Remote exception raised:", unicode(e)
Ejemplo n.º 7
0
import sys
import os
import time

root = os.path.abspath(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy'))
for i in xrange(5):
    try:
        print len(client.download(url="http://www.pizzabus.de"))
    except RemoteException, e:
        print "Failure during request:", e
        time.sleep(.5)
Ejemplo n.º 8
0
import sys
import os
import time

root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    '../../../'))
sys.path.append(root)

from simpleapi import Route, DummyClient, RemoteException
from handlers import MyAPI

client = DummyClient(Route(MyAPI, framework='dummy'))
for i in xrange(5):
    try:
        print len(client.download(url="http://www.pizzabus.de"))
    except RemoteException, e:
        print "Failure during request:", e
        time.sleep(.5)