Beispiel #1
0
 def setUp(self):
     self.procBroker = subprocess.Popen(['python','-i', 'TestBroker.py','--verbose','--debug'],creationflags=subprocess.CREATE_NEW_CONSOLE)
     time.sleep(1)
     self.procServer1 = subprocess.Popen(['python', 'TestServer.py','ServerA','--verbose','--debug'],creationflags=subprocess.CREATE_NEW_CONSOLE)
     time.sleep(1)
     self.procServer2 = subprocess.Popen(['python', 'TestServer.py','ServerB'],creationflags=subprocess.CREATE_NEW_CONSOLE)
     time.sleep(1)
     brokerconn = "tcp://localhost:5559" 
     self.client = qweather.QWeatherClient(brokerconn,'testclient',debug=True,verbose=True)
import qweather
import numpy as np
import time
from subprocess import Popen, PIPE
import traceback
import sys
# from influxdb_client import InfluxDBClient
# from influxdb_client.client.write_api import SYNCHRONOUS

cnx = qweather.QWeatherClient("tcp://10.90.61.231:5559")

with Popen([
        'python', "Z:/Dataprogrammer/Qweather/Servers/GammaVacServer.py",
        "GammaVac", "TCPIP0::172.24.5.166::INSTR"
]) as vacprocess:
    time.sleep(5)
    try:
        vac = cnx.GammaVac
        while True:
            print(vac.get_pressure_0())
            time.sleep(0.5)
            # print(vac.get_pressure_1())
            time.sleep(0.5)
    except KeyboardInterrupt:
        print("Shutdown requested...exiting")
        # vacprocess.stdout.close()
    except Exception:
        traceback.print_exc(file=sys.stdout)
        # vacprocess.stdout.close()
    sys.exit(0)
Beispiel #3
0
import sys
import time
sys.path.append('../')
import subprocess
import qweather
import cProfile, pstats, io
pr = cProfile.Profile()

procBroker = subprocess.Popen(['python', 'TestBroker.py'])
time.sleep(1)
procServer1 = subprocess.Popen(['python', 'TestServer.py'])
time.sleep(1)
procServer2 = subprocess.Popen(['python', 'TestServer2.py'])
time.sleep(2)

brokerconn = "tcp://localhost:5559"
client = qweather.QWeatherClient(brokerconn, 'testclient')
T1 = client.TestServer
T2 = client.TestServer2
tic = time.time()
T1.long_operation(2, wait=False)
#T2.long_operation(3,wait=False)
print('took: ', time.time() - tic, 's to complete')
print('got a number:', T2.get_number())

#s = io.StringIO()
#sortby = 'cumulative'
#ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
#ps.print_stats()
#print(s.getvalue())
Beispiel #4
0
    ['python', '-i', 'TestServer.py', 'ServerA', '--verbose', '--debug'],
    creationflags=subprocess.CREATE_NEW_CONSOLE)
time.sleep(1)
procServer2 = subprocess.Popen(['python', 'TestServer.py', 'ServerB'],
                               creationflags=subprocess.CREATE_NEW_CONSOLE)
time.sleep(1)


def print_message(msg):
    print('msg> ', msg)


try:
    brokerconn = "tcp://localhost:5559"
    client = qweather.QWeatherClient(brokerconn,
                                     'testclient',
                                     debug=True,
                                     verbose=True)
    #print('listened')
    print('client created')
    time.sleep(2)
    T1 = client.ServerA
    T2 = client.ServerB
    print("Getting numbers")
    for i in range(1):
        print(T1.get_number())
        print(T2.get_number())
    print("Got numbers from two servers")

    print("Testing crashing function on server")
    print(T1.crashing_function())
    print("Crashing tested")
Beispiel #5
0
import time

sys.path.append('../')
import subprocess
import qweather
import cProfile, pstats, io
import asyncio

pr = cProfile.Profile()

procBroker = subprocess.Popen(['python', 'TestBroker.py'])
#await loop.create_task(asyncio.sleep(0.3))
time.sleep(0.3)
procServer1 = subprocess.Popen(['python', 'TestServer.py'])
#await loop.create_task(asyncio.sleep(0.3))
time.sleep(0.3)
procServer2 = subprocess.Popen(['python', 'TestServer2.py'])
#await loop.create_task(asyncio.sleep(0.3))
time.sleep(0.3)
brokerconn = "tcp://localhost:5559"

client = qweather.QWeatherClient(brokerconn, debug=False)
loop = client.loop
loop.create_task(client.run())

for i in range(2):
    a = loop.create_task(client.TestServer.get_number())
    b = loop.create_task(client.TestServer2.get_number())
    print('a: ', a)
    print('b: ', b)