Skip to content
Snippets Groups Projects
test_storeStream.py 1.42 KiB
Newer Older
Manuela Kuhn's avatar
Manuela Kuhn committed
import os
import sys
import time


Manuela Kuhn's avatar
Manuela Kuhn committed
BASE_PATH   = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) ) ) )
Manuela Kuhn's avatar
Manuela Kuhn committed
API_PATH    = BASE_PATH + os.sep + "APIs"
SHARED_PATH = BASE_PATH + os.sep + "src" + os.sep + "shared"

Manuela Kuhn's avatar
Manuela Kuhn committed
print BASE_PATH

Manuela Kuhn's avatar
Manuela Kuhn committed
if not API_PATH in sys.path:
    sys.path.append ( API_PATH )
del API_PATH

from dataTransferAPI import dataTransfer


if not SHARED_PATH in sys.path:
    sys.path.append ( SHARED_PATH )
del SHARED_PATH

Manuela Kuhn's avatar
Manuela Kuhn committed
import helpers
Manuela Kuhn's avatar
Manuela Kuhn committed

#enable logging
logfilePath = os.path.join(BASE_PATH + os.sep + "logs")
Manuela Kuhn's avatar
Manuela Kuhn committed
logfile     = os.path.join(logfilePath, "testAPI.log")
helpers.initLogging(logfile, True, "DEBUG")
Manuela Kuhn's avatar
Manuela Kuhn committed

del BASE_PATH


signalHost = "zitpcx19282.desy.de"
#signalHost = "zitpcx22614.desy.de"
Manuela Kuhn's avatar
Manuela Kuhn committed
targets = ["zitpcx19282.desy.de", "50100", 0]
Manuela Kuhn's avatar
Manuela Kuhn committed

print
Manuela Kuhn's avatar
Manuela Kuhn committed
print "==== TEST: Stream all files and store them ===="
query = dataTransfer("stream", signalHost, useLog = True)

Manuela Kuhn's avatar
Manuela Kuhn committed
query.initiate(targets)
Manuela Kuhn's avatar
Manuela Kuhn committed

Manuela Kuhn's avatar
Manuela Kuhn committed


while True:
    try:
        result = query.get()
Manuela Kuhn's avatar
Manuela Kuhn committed
    except KeyboardInterrupt:
        break
    except Exception as e:
        print "Getting data failed."
        print "Error was: " + str(e)
        break
Manuela Kuhn's avatar
Manuela Kuhn committed

    try:
        query.store("/space/projects/live-viewer/data/target/testStore", result)
    except Exception as e:
Manuela Kuhn's avatar
Manuela Kuhn committed
        print "Storing data failed."
        print "Error was:", e
Manuela Kuhn's avatar
Manuela Kuhn committed
        break


query.stop()

print
Manuela Kuhn's avatar
Manuela Kuhn committed
print "==== TEST END: Stream all files and store them ===="