def pre_run(): afe = atm90e26() afe.setup('spi') afe.reset() ser = '12345678' server_config = { 'provisioning_token_path': './provisioning_token.json', 'url_base': 'http://192.168.0.102:9090/pwrmon', 'credentials_path': './credentials.json', 'params_path': './device_params.json', 'device_name': 'pipowermeter_proto_0', 'device_type': 'atm90e26_i2c_meter', 'device_serial': ser.encode('ascii'), } sconn = ServerConnection.ServerConnection(server_config) cfg = {k: base_config[k] for k in base_config} cfg['afe'] = afe cfg['sconn'] = sconn if False: synchronizeSystemClock() return cfg
def unregister_host(): """request that this machine get removed from the automation database""" print "\n>> Sending request to automation server to be removed from database" sc = ServerConnection.ServerConnection() msg = sc.remove_host_request() if msg.code == 'ack': print "success" else: print "WARNING: could not remove this host from the database: " + \ str(msg.error)
def start(self): """ This method is called to start a client or server service. This method allow to initialize and configure a client or server service and create a socket connection between several client to a server. """ if self.configuration['role'] == "client": print("") self.client = ClientConnection.ClientConnection(self.configuration) self.client.connection() self.client.client() elif self.configuration['role'] == "server": print("") self.server = ServerConnection.ServerConnection(self.configuration) self.server.connection() self.server.server()
def pre_run(): kdevs = kromek.discover() print('Discovered %s' % kdevs) if len(kdevs) <= 0: print('No devices?') return try: kconn = kromek.connect(kdevs[0]) except: print('Could not connect to kromek device.') return None try: cconn = Camera.Camera() except: print('Could not create camera instance.') return None try: ser = kromek.get_value(kconn, param='serial') except: return None server_config = { 'provisioning_token_path': './provisioning_token.json', 'url_base': 'https://irc-dev.lbl.gov/demo1', 'credentials_path': './credentials.json', 'params_path': './device_params.json', 'device_name': fileIntoString('device_name.txt'), 'device_type': 'kromek_d3s+picamera', 'device_serial': ser['serial'].encode('ascii'), } sconn = ServerConnection.ServerConnection(server_config) cfg = {k: base_config[k] for k in base_config} cfg['kconn'] = kconn cfg['sconn'] = sconn cfg['cconn'] = cconn cconn.setParams(cfg['camera']) if True: synchronizeSystemClock() return cfg
def register_host(module, testbed_id): """request that this machine get added to the automation database""" print "\n>> Sending request to automation server to be added to database" sc = ServerConnection.ServerConnection() msg = sc.add_host_request() if msg.code == 'ack': print "success" msg = sc.map_host_capability_request(module) if msg.code == 'ack': print("resource is mapped with capability %s" % module) if testbed_id: msg = sc.add_host_resourcepool_request() print msg.code else: print "WARNING: could not add this host to the database: " + \ str(msg.error) else: print "WARNING: could not add this host to the database: " + \ str(msg.error)
def __init__(self): self._connection = ServerConnection.ServerConnection() self._account = Account.Account()
import datetime import unittest from ServerConnection import * from NoDataFoundError import * from DailyScores import * date = datetime.date(2017, 12, 12) server = ServerConnection("http://data.nba.net/data/10s/prod/v1", date) class TestDailyScores(unittest.TestCase): def test_init_correct(self): self.assertIsNotNone(DailyScores(" ", " ")) def test_get_scores_correct(self): self.assertIsNotNone( DailyScores(server.get_daily_scores(), server.get_date()).get_scores()) def test_get_scores_wrong_scores(self): try: DailyScores(" ", server.get_date()).get_scores() except TypeError: pass def test_show_wrong_date(self): try: a = DailyScores(server.get_daily_scores(), 21) a.show(a.get_scores()) except AttributeError: pass