def send( self, send_coords, get_coords, get_meta, act_point ): self.send_coords = send_coords self.get_coords = get_coords self.get_meta = get_meta run_in_progress = True self.pp = [] self.mp = [] ##loop over multiple start points that we may have been sent?? Should only be 1. ##Is neccesary to pass in a list, however, or python will not pass-by-reference? #for act_point in act_points: ##send the config to the MD process if send_coords == True : print("Client: Starting coords writer subthread") self.ocFeeder = feeder(self.crds_in_fifoname, act_point, self.client) if get_coords == True : print("Client: Starting coords listener subthread") self.ocListener = listener(self.crds_back_fifoname, self.pp) if get_meta == True : print("Client: Starting metadata listener subthread") self.omListener = listener(self.metadata_fifoname, self.mp)
def __init__(self, angle_num, imgs_if_tester=None): if imgs_if_tester is not None: self.is_test = True self.angles_imgs_lst = [] self.angles_imgs_counter = [] for i in range(angle_num): img_names = os.listdir(imgs_if_tester[i]) sorted_img_names = sorted(img_names, key=first_2_chars) img_array = [] for j in range(len(sorted_img_names)): img_array.append( cv2.cvtColor( cv2.imread(imgs_if_tester[i] + sorted_img_names[j]), cv2.COLOR_RGB2BGR)) print(sorted_img_names) self.angles_imgs_lst.append(img_array) self.angles_imgs_counter.append(-1) else: self.is_test = False if (IS_PI): self.socket = sender.sender() else: self.socket = listener.listener()
def collect(hashtag1,hashtag2): ckey = 'YyVlva7vgqsOde8ldC7hv8zv4' csecret = 'OJWEsSDIZv2oqGdwSfXq2ixj2vYccaGgCyXcA87bVLHAbmKRXM' atoken = '1260716269-kCBeHaWD63ZINkxTvd2kmqiNMiBSLt7tKDak93T' asecret = 'LczOksLgR9rYPl7BLIHTV38ptRfa1ZsmUbrRawvdbvvkr' auth = OAuthHandler(ckey,csecret) auth.set_access_token(atoken, asecret) twitterStream = Stream(auth,listener(hashtag1,hashtag2)) twitterStream.filter(track =[hashtag1,hashtag2])
def Run(self): EAR = listener.listener(Constants.sitelistpath, 30) while True: if EAR.listen(): print("> Running Scrape...") self.Delegate() print("> Scrape Concluded") else: EAR.WaitAndListen()
def stream_tweet(self, csocket): api = tweepy.API(self.auth) try: url = "http://api:5000/keyword" response = requests.get(url) keyword = response.json()['keyword'] except: keyword = "OMG" # Instantiate the tweet listener t_listener = listener(csocket) myStream = tweepy.Stream(auth=api.auth, listener=t_listener) myStream.filter(track=[keyword], languages=['en'], async=True) '''time.sleep(30)
def __init__(self, iniFile): self.iniFile = iniFile # Config.ini by default, user can specify. self.cfg = ConfigParser.ConfigParser() # Parse config.ini, save the options for later. self.cfg.read(self.iniFile) params = {} for pluginName in self.cfg.sections(): if pluginName == "main": continue for name, value in self.cfg.items(pluginName): params[name] = value lstnr = listener.listener(params) lstnr.start()
def main(self, n, node_id): self.node_id = node_id # Initialize and start the listener thread listener_thread = listener.listener() listener_thread.set_node_id(node_id) listener_thread.set_node_count(n) listener_thread.start() # Initialize and start the protocol handler thread aodv_thread = aodv.aodv() aodv_thread.set_node_id(node_id) aodv_thread.set_node_count(n) aodv_thread.start()
def ini(): #Editar ruta input de acuerdo a ubicacion de archivo txt de entrada ------- ruta_input = "C:\\Users\\juamp\Desktop\\finalLengV2\\finalLeng\\input3.txt" # ---------------------------------------------------------------------- lexer = graLexer(FileStream(ruta_input)) #print(lexer) tokens = CommonTokenStream(lexer) parser = graParser(tokens) tree = parser.translationunit() walker = ParseTreeWalker() walker.walk(listener(), tree)
def main(self, n, node_id): # Store the Node ID self.node_id = node_id # Initialize and start the listener thread listener_thread = listener.listener() listener_thread.set_node_id(node_id) listener_thread.set_node_count(n) listener_thread.start() # Initialize and start the protocol handler thread aodv_thread = aodv.aodv() aodv_thread.set_node_id(node_id) aodv_thread.set_node_count(n) aodv_thread.start()
def main(self, n, node_id): # Store the Node ID self.node_id = node_id # Initialize and start the listener thread print("creating a listener") listener_thread = listener.listener() listener_thread.set_node_id(node_id) listener_thread.set_node_count(n) listener_thread.start() # Initialize and start the protocol handler thread aodv_thread = aodv.aodv() aodv_thread.set_node_id(node_id) aodv_thread.set_node_count(n) aodv_thread.start()
class Controlling: listen = listener() bell = bellcam() #fcheck = facecheck() #ck = check() def __init__(self): self.listen = listener() self.bell = bellcam() # self.faced = facecheck() # self.ck() def run(self): bell_thread = Thread(target=Controlling.button_pressed, args=(self,)) listener_thread = Thread(target=Controlling.listen, args=(self,)) #bell_thread.setDaemon(True) #listener_thread.setDaemon(True) bell_thread.start() listener_thread.start() bell_thread.join() listener_thread.join() while True: pass def button_pressed(self): while True: print(bellcam.set_btn(self)) time.sleep(.1) if bellcam.set_btn(self) is True: #self.bell.take_photo() bellcam.take_photo(self) def listen(self): while True: #self.listen.get() listener.get(self) def face(self): while True: try: print("") #self.fcheck.checking() #facecheck.checking(self) except ImportError as e: print(e)
def main(self, n, node_id): self.node_id = node_id # Initialize and start the listener thread listener_thread = listener.listener() listener_thread.set_node_id(node_id) listener_thread.set_node_count(n) listener_thread.start() # Initialize and start the protocol handler thread aodv_thread = aodv.aodv() aodv_thread.set_node_id(node_id) aodv_thread.set_node_count(n) aodv_thread.start() # Initialize and start the vehicle simulation thread sensor_thread = sensor.sensor() sensor_thread.set_node_id(node_id) sensor_thread.daemon = True sensor_thread.start()
def __init__(self, angle_num, imgs_if_tester=None): if imgs_if_tester is not None: self.is_test = True self.angles_imgs_lst = [] self.angles_imgs_counter = [] for i in range(angle_num): img_names = os.listdir(imgs_if_tester[i]) sorted_img_names = sorted(img_names, key=first_2_chars) img_array = [] for j in range(len(sorted_img_names)): img_array.append( misc.imread(imgs_if_tester[i] + sorted_img_names[j])) print(sorted_img_names) self.angles_imgs_lst.append(img_array) self.angles_imgs_counter.append(-1) else: self.is_test = False gpio.setmode(gpio.BCM) self.init_vib() if (IS_PI): self.socket = sender.sender() else: self.socket = listener.listener()
def __conduct_listening(self): CREDENTIALS_FILE_PATH = "credentials.json" ID_CACHE_PATH = "transaction_id_cache.json" gb_pipe_manager = pipe_manager(CREDENTIALS_FILE_PATH, self.__settings_path) idm_instance = id_manager(ID_CACHE_PATH, self.__settings_path) # Listener operation # TODO: Implement listener and regulate data submissions listener_managers = [] connector = gb_pipe_manager.get_pipe() settings_json = self.__settings_file.read_json() for query in settings_json["queries"]: query_json = settings_json["queries"][query] if not query_json["meta"]: meta_dict = get_meta_for_query(query) listener_managers.append( listener_manager( listener(connector, query_json, query, idm_instance, meta_dict)))
#!/usr/bin/env python #--*-- coding: utf-8 --*-- # Liszt 2014-3-12 import listener import sys if __name__ == '__main__': listener.listener(sys.argv[1])
return T if __name__=="__main__": # set signal handling signal.signal(signal.SIGINT,sigint_handle) watchio.info("Main watch application started.") # set communication parameters conf = configparser.ConfigParser() conf.read('config.txt') port = int(conf.get('communication', 'port')) host = conf.get('communication','host') L = listener.listener(host, port) L.start() T = getDefaultTournament() watchcli.handleTournament(T,L) watchio.info("Main watch application stopped.")
def __init__(self): self.listen = listener() self.bell = bellcam()
def __init__(self): self.listen = listener() #self.face = facecheck() #self.bell = bellcam() print("init")
#import dependencies import tweepy from tweepy import Stream from tweepy import OAuthHandler from listener import listener import TextProcessor as tp from flask import Flask #main if __name__ == '__main__': #access keys consumer_key = "XXXXXXXXXXXXXXXXXXXXX" consumer_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" access_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" access_token_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" #pass twitter credentials to tweepy auth = OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) twitterStream = Stream(auth, listener(), tweet_mode='extended') twitterStream.filter(languages=["en"], track=["trump"])
def send_data(c_socket, keyword): auth = OAuthHandler(ckey, csecret) auth.set_access_token(atoken, asecret) twitter_stream = Stream(auth, listener(c_socket)) twitter_stream.filter(track=[keyword], languages=['en'])
def __init__(self): self.listen = listener() self.face = facecheck() print("ROSS")
def follow_ar_tag(self, get_trajectory2_func, tag, controller_name, rate=200, timeout=None, log=False): """ takes in an AR tag number and follows it with the baxter's arm. You should look at execute_path() for inspiration on how to write this. Parameters ---------- tag : int which AR tag to use rate : int This specifies how many ms between loops. It is important to use a rate and not a regular while loop because you want the loop to refresh at a constant rate, otherwise you would have to tune your PD parameters if the loop runs slower / faster timeout : int If you want the controller to terminate after a certain number of seconds, specify a timeout in seconds. log : bool whether or not to display a plot of the controller performance Returns ------- bool whether the controller completes the path or not """ if log: times = list() actual_positions = list() actual_velocities = list() target_positions = list() target_velocities = list() t=0 count = 0 while timeout is None or count < 5: print("!!!!!!!!!!!!!!In first while loop!!!!!!!!!!!!!!") cur_pos_quat = self._kin.forward_position_kinematics() angle_pos = get_joint_positions(self._limb) cur_pos = np.array([cur_pos_quat[0],cur_pos_quat[1],cur_pos_quat[2]]) tag_pos = self.lookup_tag2(tag)[0] print("Time:", t) print("########first tag_pos in controller#########") print(tag_pos) #for some reason, the x y coordinates of the ar tag position are all negative and sometimes inverted. #Thus, we added the following block to make sure the ar tag position is passed in correctly. if abs(tag_pos[0]) > abs(tag_pos[1]): m_tag_pos = np.array([abs(tag_pos[0]), abs(tag_pos[1]), abs(tag_pos[2])]) else: m_tag_pos = np.array([abs(tag_pos[1]), abs(tag_pos[0]), abs(tag_pos[2])]) #m_tag_pos = np.array([abs(tag_pos[1]), abs(tag_pos[0]), abs(tag_pos[2])]) print("########second tag_pos in controller#########") print(m_tag_pos) path = get_trajectory2_func("line", m_tag_pos, 300, controller_name, cur_pos) # For interpolation max_index = len(path.joint_trajectory.points)-1 current_index = 0 # For timing start_t = rospy.Time.now() r = rospy.Rate(rate) count = count + 1 while not rospy.is_shutdown(): # print("!!!!!!!!!!!!!!In second while loop!!!!!!!!!!!!!!") # Find the time from start t = (rospy.Time.now() - start_t).to_sec() # If the controller has timed out, stop moving and return false # if timeout is not None and t >= timeout: # # Set velocities to zero # self.stop_moving() # return False current_position = get_joint_positions(self._limb) current_velocity = get_joint_velocities(self._limb) # Get the desired position, velocity, and effort ( target_position, target_velocity, target_acceleration, current_index ) = self.interpolate_path(path, t, current_index) if log: times.append(t+(count-1)*6) actual_positions.append(current_position) actual_velocities.append(current_velocity) target_positions.append(target_position) target_velocities.append(target_velocity) # Run controller self.step_control(target_position, target_velocity, target_acceleration) # Sleep for a bit (to let robot move) r.sleep() if current_index >= max_index: print("#######in break ############") self.stop_moving() break self.stop_moving() # For plotting if log: self.plot_results( times, actual_positions, actual_velocities, target_positions, target_velocities ) return True while not rospy.is_shutdown(): # Find the time from start t = (rospy.Time.now() - start_t).to_sec() # If the controller has timed out, stop moving and return false if timeout is not None and t >= timeout: # Set velocities to zero self.stop_moving() return False # tag_pos = lookup_tag2(tag) # lookup_tag is not defined sub = listener() """ We can't import from main, so I copied lookup_tag to utils and imported from there not sure if that's causing any problems. Still """ num_way = 200 controller_name = 'jointspace' cur_pos_quat = self._kin.forward_position_kinematics() start_pos = np.array([cur_pos_quat[0], cur_pos_quat[1], cur_pos_quat[2]]) path = LinearPath(10, self._kin, self._limb, start_pos, tag_pos) ( target_position, target_velocity, target_acceleration, current_index ) = self.interpolate_path(path, .2, current_index) # For plotting if log: times.append(t) actual_positions.append(current_position) actual_velocities.append(current_velocity) target_positions.append(target_position) target_velocities.append(target_velocity) # Run controller print("####step_control time!!!!!#####") self.step_control(target_position, target_velocity, target_acceleration) # Sleep for a bit (to let robot move) r.sleep() if log: self.plot_results( times, actual_positions, actual_velocities, target_positions, target_velocities ) return True