def handle_new_connection(self, sock, conn_id): self.connection_ids[conn_id] = sock self.connection_ids_reverse[sock] = conn_id if self.callback_new_connection is not None: self.callback_new_connection(client_id=conn_id) l = listener.Listener(sock, self.buffer, self.handle_client_message) l.start() self.listeners.append(l)
def __init__(self): import log import listener self.myListener = listener.Listener() self.myLog = log.Log('decider.log') self.myLog.add('Decider initialized') self.deciders = [] # array to hold various deciders self.setupDeciders()
def __init__(self, addr, verbose=True, spew=False): self.serverip, self.serverport = addr self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.socket.settimeout(self._timeout) self.incoming = Queue.Queue() self.listener = listener.Listener(self.socket) self.listener.register(None, self.incoming.put) if verbose: self.listener.register(None, tools.print_message) self.listener.start() self.spew = spew
def __main(): checkin = listener.Listener('', 5007) checkin.verbose = False print('Starting Checkin Server') checkin.start() webhandler.GET_BEACONS = checkin.get_beacons webinterface = webserver.GServer('', 5009, webhandler.do_get, webhandler.do_post) print("Starting Web Interface") webinterface.startserverasync() print("All Services started. Going to display mode") while True: time.sleep(10) print(checkin.get_beacons())
def main() -> None: """ Main Function calling all other functions """ #Define key words keyword_list = [ '#DataScience', '#MachineLearning', '#artificialintelligence', '#AI', '#ai', '#machinelearning', '#deeplearning', 'DeepLearning', '#ML', '#ArtificialIntelligence', '#machinelearning', 'DigitalTransformation' ] # track list #Initiate Time start_time = time.time() # grabs the system time print("Launch! \n") #Listen to twitter twitterStream = Stream( Authentification(), listener.Listener( start_time, time_limit=3600)) # initialize Stream object with a time out limit twitterStream.filter( track=keyword_list, languages=['en']) # call the filter method to run the Stream Object print('Exctraction from twitter succesful')
def __init__(self): try: self.listener = listener.Listener(LISTENING_QUEUE) except Exception, e: logging.error(str(e))
#!/usr/bin/env python import listener IP = "192.168.44.1" PORT = 1337 listnr = listener.Listener(IP, PORT) listnr.run()
#!/usr/bin/env python import socket, listener def get_ip(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ip = "" try: s.connect(("10.255.255.255", 1)) ip = s.getsockname()[0] except: ip = "127.0.0.1" finally: s.close() return ip tcp_socket_listener = listener.Listener(get_ip(), 49099) tcp_socket_listener.run()
import listener playthelistener = listener.Listener() playthelistener.run()
str_credentials = tenant + "/" + user + ":" + password return 'Basic ' + base64.b64encode(str_credentials.encode()).decode() # subscriber has form of dictionary with 3 keys {tenant, user, password} def get_subscriber_for(tenant_id): req = Request(C8Y_BASEURL + '/application/currentApplication/subscriptions') req.add_header( 'Accept', 'application/vnd.com.nsn.cumulocity.applicationUserCollection+json') req.add_header( 'Authorization', base64_credentials(C8Y_BOOTSTRAP_TENANT, C8Y_BOOTSTRAP_USER, C8Y_BOOTSTRAP_PASSWORD)) response = urlopen(req) subscribers = json.loads(response.read().decode())["users"] return [s for s in subscribers if s["tenant"] == tenant_id][0] try: logger.info('Starting listener') Listener = listener.Listener() Listener.start() except KeyboardInterrupt: logger.warning( 'KeyboardInterrupt was called, stopping listener and raising SystemExit' ) Listener.stop() raise SystemExit
iqthread = start_iqconnect(pwd['iqfeed']['productID'], pwd['iqfeed']['iq_user'], pwd['iqfeed']['iq_pass']) mylog = mylogger.Logger(pwd['telegram']['botToken'], pwd['telegram']['chatID'], config['system']['log_path']) db_queue = queue.Queue() iq_queue = queue.Queue() db = postgres.DatabaseConnection(db_queue, mylog) db.connect() listen = listener.Listener(iq_queue, db_queue, mylog, symbols) listen.start_listening() conn = connection.BarsConnection(iq_queue, mylog) conn.connect() sleep(2) conn.subscribe_to_symbols(symbols, config) print('Application initialized - main() looping...') # Loop until user --> CTRL-C run = True while run: sleep(5)
result_callback) def compute_detected(data, frequencies, toto): plot2D(range(len(data)), data) out = [] anabeg = 100 anaend = 10000 for freq in range(anabeg, anaend, 10): value = rec.goetzl(data, freq) print(freq) print(value) out.append(value) plot2D(range(anabeg, anaend, 10), out) #util.listen_and_raw_record() #listen_and_speak() #data = util.generate_frequency([400]) #util.play_sound(data) #bi_fr #compute_frequencies([1000]) ############################################################################## # LET'S BEGIN NOW !! # ############################################################################## current_listener = listener.Listener(rec.goetzl, 1000) util.listen_continuously(current_listener, 48000, 10000)
import listener li = listener.Listener("192.168.43.36", 4545) li.bind_and_listen() li.send_command()
def __init__(self, file_name, destination): self.file_name = file_name self.destination = destination self.metafile_dict = {} self.info_dict = OrderedDict( ) # OrderedDict is mandatory to get correct value of info_dict_hash self.request_parameters = {} self.tracker_response_dict = {} self.peer_ips = [] self.peer_table = { } # Dictionary with key being peer's ip address and value being 'peer' object self.conn_table = { } # Dictionary with key being 'client_address' and value being 'connection' socket object self.ip = get_my_ip() self.port = MY_PORT # Hard coded for the sake of testing self.output_files = [] self.response = None self.response_string = '' self.metafile = open(file_name, 'r', encoding="ISO-8859-1") if self.metafile.read(1) == 'd': print("Parsing metafile") self.metafile_dict = parser.get_dict(self.metafile) print("Parsing metafile complete") self.metafile.close() self.info_dict = self.metafile_dict['info'] self.info_dict_hash = hashlib.sha1( parser.bencode_dict(self.info_dict).encode('utf-8')).digest() self.peer_id = "piTorrentTestPeer001" if len(self.peer_id) > 20: self.peer_id = self.peer_id[:20] else: while len(self.peer_id) != 20: self.peer_id += '0' self.send_tracker_request() if 'peers' in self.tracker_response_dict: self.get_peers() else: print("Tracker returned no peers") return if self.peer_ips: for i in self.peer_ips: self.peer_table[i[0]] = peer.Peer(i[0], i[1], self.info_dict_hash, self.peer_id) print('Peers dict is', self.peer_table) else: print("No peers found to start handshake") return self.create_empty_files() self.listener_object = listener.Listener(self.ip, self.port, self.info_dict_hash, self.peer_table, self.conn_table) listen_thread = threading.Thread( target=self.listener_object.listen_for_peers) listen_thread.daemon = False # [TODO] Getting some weird error when made True listen_thread.start() for address, peer_object in self.peer_table.items(): peer_object.handshake()
def init_listener(): print("Listener is starting...") import listener sm.listener = listener.Listener() print("Listener is ready!")
def create_new_listener(self): new_listener = listener.Listener(self._default_subnet) new_listener.start_mouse_listener()
import listener my_listener = listener.Listener("192.168.1.77", 4444) my_listener.run()
import listener lst = listener.Listener()
def calculateCorrelationData(self, newTeachPath): # calculates the Pearson correlation for each frequency bin import os from scipy.stats import pearsonr import listener tempListener = listener.Listener() groundTruth = [] numSamples = 0 correlData = [] # correlation data matrix finalData = [] # get list of files in recordings directory filelist = os.listdir(newTeachPath) # take a filename and see if it is a .fft file for file in filelist: fftfile = newTeachPath + file # check if 'file' is a file (it could be a directory) if os.path.isfile(fftfile) and file[-4:] == '.fft': # set the groundTruth if the file is for a plane or not if file[0] == 'p': # it's a plane groundTruth.append(float(1)) else: groundTruth.append(float(0)) # get the FFT data from file and add it to the list correlData.append(tempListener.getFFTData(fftfile)) numSamples += 1 if len(correlData[numSamples - 1]) != tempListener.fftNumUsefulBins: print('Error: FFT in file (' + fftfile + ') not equal to expected value') print('Expected: ' + str(tempListener.fftNumUsefulBins) + '\tActual: ' + str(len(correlData[numSamples - 1]))) # print(groundTruth) file = open('rawCorrelData.csv', 'w') # open the file in write mode for b in range(len(groundTruth)): file.write(str(groundTruth[b]) + ', ') file.write('\n') for freq in range(int(tempListener.fftNumUsefulBins)): freqSet = [] for sample in range(numSamples): freqSet.append(correlData[sample][freq]) file.write(str(correlData[sample][freq]) + ', ') file.write('\n') # find the correlation co-efficient for this frequency # use scipy's pearsonr(x,y) to calculate the correlation result = pearsonr(freqSet, groundTruth) finalData.append(result[0]) # TODO: sanity check the correlation data against existing FFT files? file.close() # be nice and close out the file # save the correlation data to a file for future use self.saveCorrelationData(self.correlationFile, finalData)
#!/usr/bin/env python import listener my_listener = listener.Listener("10.0.9.4", 4546) my_listener.run()
def run(self): l = listener.Listener(self.client_socket, self.buffer, self.handle_message) l.start()