def publish_json(index, row, j, columns):
    dict_json= dict()
    dict_val= dict()
    for i in columns[1:]:
        dict_val[i]= row[i]

    dict_json["instanceId"]= j
    dict_json["timestamp"]= row[0]
    dict_json["typeId"]= "uni-stuttgart.data-center/server"
    dict_json["value"]= dict_val

    # print(dict_json)
    json_data= json.dumps(dict(dict_json))
    # print("type of published data",type(json_data))
    print(json_data)

    Publisher.publisher("guest","guest",json_data,j,row[0])
Exemplo n.º 2
0
class Book:
    title = None
    year_pub = None
    location_code = None
    publisher = Publisher.Publisher()
    authors = {}

    def get_title(self):
        return self.title

    def set_title(self, title):
        self.title = title

    def get_year_pub(self):
        return self.year_pub

    def set_year_pub(self, year_pub):
        self.year_pub = year_pub

    def get_location_code(self):
        return self.location_code

    def set_location_code(self, location_code):
        self.location_code = location_code

    def set_publisher(self, publisher):
        self.publisher.set_publisher(publisher)

    def add_author(self, name):
        author = Author.Author(name)
        self.authors.update({author: author.get_name()})

    def print_authors(self):
        for author in self.authors:
            print(self.authors[author])

    def to_string(self):
        return "\nTitle: " + self.get_title() + \
               "\nYear Published: " + str(self.get_year_pub()) + \
               "\nLocation Code: " + self.get_location_code() + \
               "\nPublisher: " + self.publisher.get_publisher()
#!/usr/bin/env python

from Publisher import *

ip = "10.100.7.38"  # IP address of the server
port = 7713  # Thrift listen port of the server
username = "******"  # username
password = "******"  # passowrd

publisher = Publisher()

# Initialize publisher with ip and port of server
publisher.init(ip, port)

# Connect to server with username and password
publisher.connect(username, password)

# Define stream definition
streamDefinition = "{ 'name':'org.wso2.iot.statistics.device.pin.data', 'version':'1.0.0', 'nickName': 'IoT Connected Device Pin Data', 'description': 'Pin Data Received', 'tags': ['arduino', 'led13'], 'metaData':[ {'name':'ipAdd','type':'STRING'},{'name':'deviceType','type':'STRING'},{'name':'owner','type':'STRING'}, {'name':'time','type':'STRING'}], 'payloadData':[ {'name':'macAddress','type':'STRING'}, {'name':'pin','type':'STRING'}, {'name':'pinValue','type':'STRING'}, {'name':'description','type':'STRING'}] }"
publisher.defineStream(streamDefinition)

# Publish sample message
publisher.publish("Test message form python client")

# Disconnect
publisher.disconnect()
Exemplo n.º 4
0
    def NewPublisher(self, run, process, compare, all, job, location, grid,
                     jobid):
        os.chdir(Configuration.variables["HomeDirectory"] + '/bin/')
        if job.upper() == "BATCH":
            if location.upper() != 'CERN':
                condor_status = 0
                while condor_status == 0:
                    Unfinished_Job = 0
                    #for jobid in self.__jobNumber[process]:
                    status, output = commands.getstatusoutput('condor_q ' +
                                                              jobid)
                    if jobid in output:
                        Unfinished_Job = Unfinished_Job + 1
                    if Unfinished_Job == 0:
                        condor_status = 1
                        print "All jobs for " + process + " are done"
                    if Unfinished_Job > 0:
                        time.sleep(15)
            else:
                bsub_status = 0
                while bsub_status == 0:
                    Unfinished_Job = 0
                    status, output = commands.getstatusoutput('bjobs ')
                    if 'No unfinished job' in output:
                        bsub_status = 1
                        print "All jobs for " + process + " are done"
                    else:
                        time.sleep(15)

            for generator in os.listdir(
                    Configuration.variables["HomeDirectory"] +
                    'DropBox/scratch/' + process):
                for sub_gen in os.listdir(
                        Configuration.variables["HomeDirectory"] +
                        'DropBox/scratch/' + process + '/' + generator + '/'):
                    for subdir in os.listdir(
                            Configuration.variables["HomeDirectory"] +
                            'DropBox/scratch/' + process + '/' + generator +
                            '/' + sub_gen + '/'):
                        if '.root' in subdir or '.log' in subdir:
                            if os.path.isdir(Configuration.
                                             variables["ReleaseDirectory"] +
                                             generator + '/' + sub_gen + '/' +
                                             process + '/') == False:
                                os.makedirs(Configuration.
                                            variables["ReleaseDirectory"] +
                                            generator + '/' + sub_gen + '/' +
                                            process + '/')
                            shutil.copyfile(
                                Configuration.variables["HomeDirectory"] +
                                'DropBox/scratch/' + process + '/' +
                                generator + '/' + sub_gen + '/' + subdir,
                                Configuration.variables["ReleaseDirectory"] +
                                generator + '/' + sub_gen + '/' + process +
                                '/' + subdir)
                    #os.system('rm '+Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process+'/'+generator+'/'+sub_gen+'/*')

        if grid.upper() == 'TRUE':
            cooked_crab = []
            sub_jobs = 0
            total_jobs = 0
            jobs_done = 0
            while len(cooked_crab) < 1:
                if sub_jobs > 3:
                    print "More than 3 jobs in queue, sleeping for 3 minutes"
                    print "Jobs left: ", int(
                        total_jobs
                    ) - jobs_done - sub_jobs, "Out of: ", total_jobs
                    time.sleep(180)
                else:
                    print "Sleeping for one minute, waiting for CRAB"
                    if total_jobs != 0:
                        print "Jobs left: ", int(
                            total_jobs
                        ) - jobs_done - sub_jobs, "Out of: ", total_jobs
                    time.sleep(60)

                #for jobid in self.__crab_List:
                if jobid in cooked_crab:
                    continue
                crab_status, crab_output = commands.getstatusoutput(
                    'crab -status -c ' + jobid)
                if crab_status != 0:
                    print "Something went wrong here."
                else:
                    total_jobs = 0
                    jobs_done = 0
                    sub_jobs = 0
                    for line in crab_output.split('\n'):
                        if '>>>' in line:
                            if 'TOTAL JOBS' in line.upper():
                                total_jobs = line.split(' ')[1]
                                #print total_jobs, "Total Jobs"
                        if 'CLEARED' in line.upper(
                        ) or 'DONE' in line.upper() and '>>>' not in line:
                            jobs_done = jobs_done + 1
                        if 'SUBMITTED' in line.upper():
                            sub_jobs = sub_jobs + 1

                    if int(total_jobs) == 0:
                        print "Crab must not have been submitted properly"
                        cooked_crab.append(jobid)
                    elif int(total_jobs) == jobs_done:
                        print "Crab job: " + jobid + " done!"
                        out_stat, out_out = commands.getstatusoutput(
                            'crab -getoutput -c ' + jobid)
                        out_file = self.CrabCrusher(jobid + '/res/')
                        cooked_crab.append(jobid)
                        if out_file == None:
                            print "No root files in scracth"
                        else:
                            proc = out_file.split('/')[-5]
                            gen = out_file.split('/')[-4]
                            rel = out_file.split('/')[-3]
                            if os.path.isdir(Configuration.
                                             variables['ReleaseDirectory'] +
                                             gen + '/' + rel + '/' + proc +
                                             '/') == False:
                                os.makedirs(Configuration.
                                            variables['ReleaseDirectory'] +
                                            gen + '/' + rel + '-preGen/' +
                                            proc + '/')
                            shutil.copyfile(
                                out_file,
                                Configuration.variables['ReleaseDirectory'] +
                                gen + '/' + rel + '-preGen/' + proc + '/')

        print "Begin Publishing", process
        ### Publishes and compares, may be able to replace 'data' too ###
        gen_List = os.listdir(Configuration.variables["ReleaseDirectory"])
        if compare.upper() == "SAME" or compare.upper() == "ALL":
            for List in gen_List:
                if compare.upper(
                ) == "SAME" and List not in run and run.upper() != "ALL":
                    continue
                if 'CVS' in List:
                    continue
                sub_dir = os.listdir(
                    Configuration.variables["ReleaseDirectory"] + List)
                for i in range(len(sub_dir) - 1):
                    for j in range(i + 1, len(sub_dir)):
                        if sub_dir[i] == sub_dir[j]:
                            continue
                        if os.path.isdir(
                                Configuration.variables["ReleaseDirectory"] +
                                List + '/' + sub_dir[i] + '/' +
                                process) == False:
                            continue
                        if os.path.isdir(
                                Configuration.variables["ReleaseDirectory"] +
                                List + '/' + sub_dir[j] + '/' +
                                process) == False:
                            continue
                        web_dir = Configuration.variables[
                            "WebDirectory"] + sub_dir[i] + '/' + sub_dir[
                                j] + '/' + process + '/'
                        if os.path.isdir(web_dir) == True:
                            continue
                        if os.path.isdir(
                                Configuration.variables["WebDirectory"] +
                                sub_dir[j] + '/' + sub_dir[i] + '/' + process +
                                '/') and os.listdir(
                                    Configuration.variables["WebDirectory"] +
                                    sub_dir[j] + '/' + sub_dir[i] + '/' +
                                    process + '/') < 2:
                            continue
                        for rel_file in os.listdir(
                                Configuration.variables["ReleaseDirectory"] +
                                List + '/' + sub_dir[i] + '/' + process):
                            if '.root' in rel_file:
                                for ref_file in os.listdir(
                                        Configuration.
                                        variables["ReleaseDirectory"] + List +
                                        '/' + sub_dir[j] + '/' + process):
                                    if '.root' in ref_file:
                                        if os.path.isdir(web_dir) == False:
                                            os.makedirs(web_dir)

                                        Publisher.StaticWeb().plot(
                                            Configuration.
                                            variables["ReleaseDirectory"] +
                                            List + '/' + sub_dir[i] + '/' +
                                            process + '/' + rel_file,
                                            Configuration.
                                            variables["ReleaseDirectory"] +
                                            List + '/' + sub_dir[j] + '/' +
                                            process + '/' + ref_file, web_dir,
                                            process + '--' + sub_dir[i] +
                                            '--' + sub_dir[j], '', sub_dir[i],
                                            sub_dir[j])
                                        Publisher.StaticWeb().index(
                                            sub_dir[i], sub_dir[j], process,
                                            web_dir)

        # Compares new release to old ones.... #
        if compare.upper() != "SAME":  # or compare.upper() == "ALL":
            for i in range(len(gen_List) - 1):
                for j in range(i + 1, len(gen_List)):
                    if compare.upper() != "ALL":
                        if compare.upper(
                        ) not in gen_List[i] and compare.upper() != "OPPOSITE":
                            continue
                        if compare.upper(
                        ) not in gen_List[j] and compare.upper() != "OPPOSITE":
                            continue
                        if run.upper() != "ALL":
                            if run.upper() not in gen_List[i] or run.upper(
                            ) not in gen_List[j]:
                                continue
                        if gen_List[i] == 'CVS' or gen_List[j] == 'CVS':
                            continue
                    rel_List = os.listdir(
                        Configuration.variables["ReleaseDirectory"] +
                        gen_List[i])
                    ref_List = os.listdir(
                        Configuration.variables["ReleaseDirectory"] +
                        gen_List[j])
                    for rel_dir in rel_List:
                        if os.path.isdir(
                                Configuration.variables["ReleaseDirectory"] +
                                gen_List[i] + '/' + rel_dir + '/' +
                                process) == False:
                            continue
                        for ref_dir in ref_List:
                            if os.path.isdir(Configuration.
                                             variables["ReleaseDirectory"] +
                                             gen_List[j] + '/' + ref_dir +
                                             '/' + process) == False:
                                continue
                            if ref_dir == rel_dir:
                                continue
                            if all.upper() == "FALSE":
                                if ref_dir != self.__release_List[gen_List[
                                        j]] and ref_dir != self.__release_List[gen_List[
                                            i]] and rel_dir != self.__release_List[
                                                gen_List[
                                                    j]] and rel_dir != self.__release_List[
                                                        gen_List[i]]:
                                    continue
                            web_dir = Configuration.variables[
                                "WebDirectory"] + rel_dir + '/' + ref_dir + '/' + process + '/'
                            if os.path.exists(
                                    web_dir) and os.listdir(web_dir) < 2:
                                continue
                            if os.path.exists(
                                    Configuration.variables["WebDirectory"] +
                                    ref_dir + '/' + rel_dir + '/' + process +
                                    '/'):
                                continue
                            rel_loc = Configuration.variables[
                                "ReleaseDirectory"] + gen_List[
                                    i] + '/' + rel_dir + '/' + process + '/'
                            ref_loc = Configuration.variables[
                                "ReleaseDirectory"] + gen_List[
                                    j] + '/' + ref_dir + '/' + process + '/'
                            print gen_List[i], gen_List[j]
                            for rel_file in os.listdir(rel_loc):
                                if '.root' in rel_file:
                                    for ref_file in os.listdir(ref_loc):
                                        if '.root' in ref_file:
                                            if os.path.isdir(web_dir) == False:
                                                os.makedirs(web_dir)

                                            Publisher.StaticWeb().plot(
                                                rel_loc + '/' + rel_file,
                                                ref_loc + '/' + ref_file,
                                                web_dir, process + '--' +
                                                rel_dir + '--' + ref_dir, '',
                                                rel_dir, ref_dir)
                                            Publisher.StaticWeb().index(
                                                rel_dir, ref_dir, process,
                                                web_dir)
Exemplo n.º 5
0
    def NewPublisher(self, run, process, compare, all, job):
        os.chdir(Configuration.variables["HomeDirectory"]+'/bin/')
        if job.upper() != "LOCAL":
            condor_status = 0
            while condor_status == 0:
                Unfinished_Job = 0
                for jobid in self.__jobNumber[process]:
                    status, output = commands.getstatusoutput('condor_q '+jobid)
                    if jobid in output:
                        Unfinished_Job = Unfinished_Job + 1 
                if Unfinished_Job == 0:
                    condor_status = 1
                    print "All jobs for " +process+ " are done" 
                if Unfinished_Job > 0:
                    time.sleep(15)
            for generator in os.listdir(Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process):
                for sub_gen in os.listdir(Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process+'/'+generator+'/'):
                    for subdir in os.listdir(Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process+'/'+generator+'/'+sub_gen+'/'):
                        if '.root' in subdir or '.log' in subdir:
                            if os.path.isdir(Configuration.variables['ReleaseDirectory']+generator+'/'+sub_gen+'/'+process+'/') == False:
                                os.makedirs(Configuration.variables['ReleaseDirectory']+generator+'/'+sub_gen+'/'+process+'/')
                            shutil.copyfile(Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process+'/'+generator+'/'+sub_gen+'/'+subdir, Configuration.variables['ReleaseDirectory']+generator+'/'+sub_gen+'/'+process+'/'+subdir)
                    #os.system('rm '+Configuration.variables["HomeDirectory"]+'DropBox/scratch/'+process+'/'+generator+'/'+sub_gen+'/*')
                
        #print "Begin Publishing" , process
        ### Publishes and compares, may be able to replace 'data' too ###
        gen_List = os.listdir(Configuration.variables['ReleaseDirectory'])
        if compare.upper() == "SAME" or compare.upper() == "ALL":
            for List in gen_List:
                if compare.upper() == "SAME" and List not in run and run.upper() != "ALL":
                    continue
                sub_dir = os.listdir(Configuration.variables['ReleaseDirectory']+List)
                for i in range(len(sub_dir) - 1):
                    for j in range(i+1, len(sub_dir)):
                        if sub_dir[i] == sub_dir[j]:
                            continue
                        if os.path.isdir(Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[i]+'/'+process) == False:
                            continue
                        if os.path.isdir(Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[j]+'/'+process) == False:
                            continue
                        web_dir = Configuration.variables["WebDirectory"]+sub_dir[i]+'/'+sub_dir[j]+'/'+process+'/'
                        if os.path.isdir(web_dir) == True:
                            continue
                        if os.path.isdir(Configuration.variables["WebDirectory"]+sub_dir[j]+'/'+sub_dir[i]+'/'+process+'/') and os.listdir(Configuration.variables["WebDirectory"]+sub_dir[j]+'/'+sub_dir[i]+'/'+process+'/') < 2:
                            continue 
                        for rel_file in os.listdir(Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[i]+'/'+process):
                            if '.root' in rel_file:
                                for ref_file in os.listdir(Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[j]+'/'+process):
                                    if '.root' in ref_file:
                                        if os.path.isdir(web_dir) == False:
                                            os.makedirs(web_dir)
                                        
                                        Publisher.StaticWeb().plot(Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[i]+'/'+process+'/'+rel_file, Configuration.variables['ReleaseDirectory']+List+'/'+sub_dir[j]+'/'+process+'/'+ref_file, web_dir, process+'--'+sub_dir[i]+'--'+sub_dir[j], '', sub_dir[i], sub_dir[j])
                                        Publisher.StaticWeb().index(sub_dir[i], sub_dir[j], process, web_dir)
                                              

        # Compares new release to old ones.... #
        if compare.upper() != "SAME":# or compare.upper() == "ALL":
            for i in range(len(gen_List) - 1):
                for j in range(i+1,len(gen_List)):
                    if compare.upper() != "ALL":
                        if compare.upper() not in gen_List[i] and compare.upper() != "OPPOSITE":
                            continue
                        if compare.upper() not in gen_List[j] and compare.upper() != "OPPOSITE":
                            continue
                        if run.upper() != "ALL":
                            if run.upper() not in gen_List[i] or run.upper() not in gen_List[j]:
                                continue
                    rel_List = os.listdir(Configuration.variables['ReleaseDirectory']+gen_List[i])
                    ref_List = os.listdir(Configuration.variables['ReleaseDirectory']+gen_List[j])
                    for rel_dir in rel_List:
                        if os.path.isdir(Configuration.variables['ReleaseDirectory']+gen_List[i]+'/'+rel_dir+'/'+process) == False:
                            continue
                        for ref_dir in ref_List:
                            if os.path.isdir(Configuration.variables['ReleaseDirectory']+gen_List[j]+'/'+ref_dir+'/'+process) == False:
                                continue
                            if ref_dir == rel_dir:
                                continue 
                            if all.upper() == "FALSE":
                                if ref_dir != self.__release_List[gen_List[j]] and ref_dir != self.__release_List[gen_List[i]] and rel_dir != self.__release_List[gen_List[j]] and rel_dir != self.__release_List[gen_List[i]]:
                                    continue
                            web_dir = Configuration.variables["WebDirectory"]+rel_dir+'/'+ref_dir+'/'+process+'/'
                            if os.path.exists(web_dir) and os.listdir(web_dir) < 2:
                                continue
                            if os.path.exists(Configuration.variables["WebDirectory"]+ref_dir+'/'+rel_dir+'/'+process+'/'):
                                continue
                            rel_loc = Configuration.variables['ReleaseDirectory']+gen_List[i]+'/'+rel_dir+ '/' + process+'/'
                            ref_loc = Configuration.variables['ReleaseDirectory']+gen_List[j]+'/'+ref_dir+ '/' + process+'/'
                            #print gen_List[i], gen_List[j]
                            for rel_file in os.listdir(rel_loc):
                                if '.root' in rel_file:
                                    for ref_file in os.listdir(ref_loc):
                                        if '.root' in ref_file:
                                            if os.path.isdir(web_dir) == False:
                                                os.makedirs(web_dir)
                                            
                                            Publisher.StaticWeb().plot(rel_loc+'/'+rel_file, ref_loc+'/'+ref_file, web_dir, process+'--'+rel_dir+'--'+ref_dir, '', rel_dir, ref_dir)
                                            Publisher.StaticWeb().index(rel_dir, ref_dir, process, web_dir)
Exemplo n.º 6
0
    def __init__(self):
        # initialize tcp_communicator for communicating with QT via TCP

        # pi ip address (comment for testing)
        ip = "10.0.1.55"

        # local ip address (uncomment for testing)
        # ip = "0.0.0.0"

        tcpPort = 9005

        # streaming enable or disable
        streamingEnable = True

        # streaming attributes
        streamingIP = "10.0.1.54"
        streamingPort1 = "1234"
        streamingPort2 = "5678"
        streamingPort3 = "4321"
        streamingPort4 = "8765"

        # initialize tcp communicator
        self.tcp_communicator = TcpCommunicator(ip,
                                                tcpPort,
                                                streamingIP,
                                                streamingPort1,
                                                streamingPort2,
                                                streamingPort3,
                                                streamingPort4,
                                                streamingEnable,
                                                bind=True)

        # initialize hat with default address and frequency (comment when testing)
        hat_address = 0x40
        frequency = 50
        self.hat = Hat(hat_address, frequency)
        # self.pressureSensor = Sensor()
        self.liftBagCommunicator = Lift_Bag_Communicator({
            "x": 0,
            "y": 0,
            "z": 0,
            "r": 0,
            "up": 0,
            "down": 0,
            "l": 0,
            "bag": 0
        })

        # initialize dummy hat for testing without the pi
        # self.hat = Dummy_Hat()

        thruster_base_pwm = 305
        camera_base_pwm = 400

        # adding devices to hat -- args: (device name, channel, base pwm)
        self.hat.addDevice("top_rear_thruster", 9, thruster_base_pwm)
        self.hat.addDevice("top_front_thruster", 7, thruster_base_pwm)
        self.hat.addDevice("left_rear_thruster", 3, thruster_base_pwm)
        self.hat.addDevice("right_rear_thruster", 5, thruster_base_pwm)
        self.hat.addDevice("left_front_thruster", 11, thruster_base_pwm)
        self.hat.addDevice("right_front_thruster", 0, thruster_base_pwm)
        self.hat.addDevice("camera_servo", 15, camera_base_pwm)
        self.hat.addDevice("light", 13, 0)

        # list of system components
        components = []

        # motion equation component -- args (hat, angle zeros)
        self.motion = Motion(self.hat, {
            "x": 0,
            "y": 0,
            "z": 0,
            "r": 0,
            "up": 0,
            "down": 0,
            "l": 0,
            "bag": 0
        })
        components.append(self.liftBagCommunicator)
        components.append(self.motion)

        # publisher
        self.publisher = Publisher()

        # bind component listeners to TCP and I2C events in publisher
        for component in components:
            self.publisher.registerEventListener("TCP", component.update)
            self.publisher.registerEventListener("TCP ERROR", component.update)

        self.publisher.registerEventListener("CLOCK", self.motion.update)
        self.publisher.registerEventListener("CLOCK", self.hat.update)
        self.publisher.registerEventListener("HAT", self.hat.update)
        self.publisher.registerEventListener(
            "SENSOR", self.tcp_communicator.sendFeedback)
        self.publisher.registerEventListener(
            "BAG", self.tcp_communicator.sendToLiftBag)

        self.tcp_communicator.registerCallBack(self.publisher.trigger_event)
        self.motion.registerCallBack(self.publisher.trigger_event)
        self.liftBagCommunicator.registerCallBack(self.publisher.trigger_event)
        # self.pressureSensor.registerCallBack(self.publisher.trigger_event)

        # create interrupter and bind to I2C event trigger callback
        # (when commented, pwms are only updated in the hat on change)
        # self.interrupter = Interrupter(self.publisher.trigger_event, "SENSOR")
        self.interrupter = Dummy_Interrupter(self.publisher.trigger_event,
                                             "SENSOR", 'dummy;data')

        # Main loop
        self.tcp_communicator.mainLoop()
import time

BAM_IP = 'localhost'					# IP address of the BAM/CEP server
BAM_PORT = 7713							# Thrift listen port of the server
BAM_UNAME = 'admin'						# Username to connect to server
BAM_PASSWRD = 'admin' 					# Passowrd to connect to server
BT_PORT = "/dev/ttyACM0"			# Port to which the Bluetooth Device is bound


bluetoothSerial = serial.Serial( BT_PORT, baudrate=9600 )

#while True:
#	print bluetoothSerial.readline()


publisher = Publisher()

# Initialize publisher with ip and port of server
publisher.init(BAM_IP, BAM_PORT)

# Connect to server with username and password
publisher.connect(BAM_UNAME, BAM_PASSWRD)

print "WAIT...."
# Define stream definition
streamDefinition = "{'name':'org_wso2_iot_statistics_device_pin_data','version':'1.0.0','nickName': 'IoT Connected Device Pin Data','description': 'Pin Data Received','tags': ['arduino', 'led13'],'metaData':[{'name':'ipAdd','type':'STRING'},      {'name':'deviceType','type':'STRING'},    {'name':'owner','type':'STRING'},{'name':'requestTime','type':'LONG'}],'payloadData':[ {'name':'macAddress','type':'STRING'}, {'name':'pin','type':'STRING'},{'name':'pinValue','type':'STRING'}, {'name':'description','type':'STRING'}]}";

publisher.defineStream(streamDefinition)
myPublisher = BAMPublisher()

class _Getch:
Exemplo n.º 8
0
import serial
import time
import datetime
import thread
import time

BAM_IP = 'localhost'					# IP address of the BAM/CEP server
BAM_PORT = 7713							# Thrift listen port of the server
BAM_UNAME = 'admin'						# Username to connect to server
BAM_PASSWRD = 'admin' 					# Passowrd to connect to server
BT_PORT = "/dev/rfcomm1"			# Port to which the Bluetooth Device is bound


bluetoothSerial = serial.Serial( BT_PORT, baudrate=9600 )

publisher = Publisher()

# Initialize publisher with ip and port of server
publisher.init(BAM_IP, BAM_PORT)

# Connect to server with username and password
publisher.connect(BAM_UNAME, BAM_PASSWRD)

print "WAIT...."
# Define stream definition
streamDefinition = "{'name':'org_wso2_iot_statistics_device_pin_data','version':'1.0.0','nickName': 'IoT Connected Device Pin Data','description': 'Pin Data Received','tags': ['arduino', 'led13'],'metaData':[{'name':'ipAdd','type':'STRING'},      {'name':'deviceType','type':'STRING'},    {'name':'owner','type':'STRING'},{'name':'requestTime','type':'LONG'}],'payloadData':[ {'name':'macAddress','type':'STRING'}, {'name':'pin','type':'STRING'},{'name':'pinValue','type':'STRING'}, {'name':'description','type':'STRING'}]}";

publisher.defineStream(streamDefinition)
myPublisher = BAMPublisher()

class _Getch:
Exemplo n.º 9
0
from Publisher import *
from BAMPublisher import *

import serial
import time
import datetime

BAM_IP = 'localhost'					# IP address of the BAM/CEP server
BAM_PORT = 7713							# Thrift listen port of the server
BAM_UNAME = 'admin'						# Username to connect to server
BAM_PASSWRD = 'admin' 					# Passowrd to connect to server
BT_PORT = "/dev/rfcomm1"			# Port to which the Bluetooth Device is bound


publisher = Publisher()

# Initialize publisher with ip and port of server
publisher.init(BAM_IP, BAM_PORT)

# Connect to server with username and password
publisher.connect(BAM_UNAME, BAM_PASSWRD)
print "WAIT...."
# Define stream definition
streamDefinition = "{'name':'org_wso2_iot_statistics_device_pin_data','version':'1.0.0','nickName': 'IoT Connected Device Pin Data','description': 'Pin Data Received','tags': ['arduino', 'led13'],'metaData':[{'name':'ipAdd','type':'STRING'},      {'name':'deviceType','type':'STRING'},    {'name':'owner','type':'STRING'},{'name':'requestTime','type':'LONG'}],'payloadData':[ {'name':'macAddress','type':'STRING'}, {'name':'pin','type':'STRING'},{'name':'pinValue','type':'STRING'}, {'name':'description','type':'STRING'}]}";

publisher.defineStream(streamDefinition)
myPublisher = BAMPublisher()

bluetoothSerial = serial.Serial( BT_PORT ,baudrate=9600  )
def handle_script_Publisher(args):
    print("Calling functions from Publisher")
    Publisher.main(args)
Exemplo n.º 11
0
	"ProcessedDataset=",
	"pset="
]

# config params for CRAB
cfg_params = {}
cfg_params["USER.copy_data"] = 1
cfg_params["USER.publish_data"] = 1
cfg_params["CMSSW.datasetpath"] = "NONE"
cfg_params["CMSSW.dataset_pu"] = None

options,args = getopt.getopt(sys.argv[1:],"",long_options)

for option,value in options:
	if option == "--dbs-url":
		cfg_params["USER.dbs_url_for_publication"] = value
	elif option == "--ProcessedDataset":
		cfg_params["USER.publish_data_name"] = value
	elif option == "--pset":
		cfg_params["CMSSW.pset"] = value


# initialize some global stuff the CRAB publisher depends on
Publisher.common.work_space = WorkSpace.WorkSpace(os.getcwd(),cfg_params)
Publisher.common.debugLevel = 0
Publisher.common.logger = CrabLogger.CrabLogger(args)
Publisher.common.logger.debug_level = 6

p = Publisher.Publisher(cfg_params)
p.run()
Exemplo n.º 12
0
 def __init__(self):
     self.pub = Publisher(self.update, self.rate)
Exemplo n.º 13
0
--- src/robotide/publish/publisher.py.orig	2019-06-28 07:27:57 UTC
+++ src/robotide/publish/publisher.py
@@ -18,10 +18,10 @@ if PY3:
     from robotide.utils import basestring, unicode
 
 try:
-    from pubsub import Publisher
+    from wx.lib.pubsub import Publisher
     WxPublisher = Publisher()
 except ImportError:
-    from pubsub import pub
+    from wx.lib.pubsub import pub
     WxPublisher = pub.getDefaultPublisher()
 
 
Exemplo n.º 14
0
#!/usr/bin/env python

from Publisher import *

ip = '10.100.7.38'  # IP address of the server
port = 7713  # Thrift listen port of the server
username = '******'  # username
password = '******'  # passowrd

publisher = Publisher()

# Initialize publisher with ip and port of server
publisher.init(ip, port)

# Connect to server with username and password
publisher.connect(username, password)

# Define stream definition
streamDefinition = "{ 'name':'org.wso2.iot.statistics.device.pin.data', 'version':'1.0.0', 'nickName': 'IoT Connected Device Pin Data', 'description': 'Pin Data Received', 'tags': ['arduino', 'led13'], 'metaData':[ {'name':'ipAdd','type':'STRING'},{'name':'deviceType','type':'STRING'},{'name':'owner','type':'STRING'}, {'name':'time','type':'STRING'}], 'payloadData':[ {'name':'macAddress','type':'STRING'}, {'name':'pin','type':'STRING'}, {'name':'pinValue','type':'STRING'}, {'name':'description','type':'STRING'}] }"
publisher.defineStream(streamDefinition)

# Publish sample message
publisher.publish("Test message form python client")

# Disconnect
publisher.disconnect()
Exemplo n.º 15
0
'''
    This is controller class which would decide the publisher and subscriber flow.
'''
from Publisher import *
from SubscriberOne import *
from SubscriberTwo import *

if __name__ == '__main__':

    pub = Publisher()

    subOne = SubscriberOne()
    subTwo = SubscriberTwo()

    pub.attach(subOne)
    pub.attach(subTwo)

    print("All subscribers are notified")

    pub.notify()

    pub.detach(subOne)

    print("Again subscribers are being notified")

    pub.notify()
Exemplo n.º 16
0
 def on_status(self, data):
     # When receiving a tweet: send it to pubsub
     #data = self.createJSON(data._json)
     publisher.write_to_pubsub(data._json)
     #print(self.createJSON(data._json).decode())
     return True