Exemple #1
0
            ["ping", "-c", "3", hostname],
            stderr=subprocess.STDOUT,  # get all output
            universal_newlines=True,  # return string not bytes
        )
    except subprocess.CalledProcessError:
        response = None
    return response


try:
    blinkLed(10)
    if check_vpn() is not None:
        config = getConguration()
        djv = Dejavu(config)
        djv.create_session(config["fingerprint"]["id"], config["vpn_ip"], config["remote_ip"])
        djv.log_event("action", "boot")
        atexit.register(exit_handler, djv)
        if __name__ == "__main__":
            a = datetime.now()
            listen = 1
            pause = 0.5
            it = 1
            try:
                while True:
                    blinkLed(2)
                    song = djv.recognize(MicrophoneRecognizer, seconds=listen)
                    if song is not None:
                        djv.log_event("match", str(song["song_id"]))
                        print "Recognized %s\n" % (song)
                        blinkLed(5)
                    it += 1
Exemple #2
0
thread.daemon = True

try:
	thread.start()
except KeyboardInterrupt:
    server.shutdown()
    sys.exit(0)

try:
	if check_vpn() is not None:
		print "vpn connection"
		config = getConguration()
		djv = Dejavu(config)
		djv.create_session(config['fingerprint']['id'], config['vpn_ip'], config['remote_ip'])
		print 'Session '+str(config['session'])
		djv.log_event('action', 'boot')
		atexit.register(exit_handler, djv)
		print 'Start listening: http://'+str(config['vpn_ip'])+':'+str(PORT_NUMBER)+'/?on'
		print 'Stop listening: http://'+str(config['vpn_ip'])+':'+str(PORT_NUMBER)+'/?off'
		if __name__ == '__main__':
			a = datetime.now()
			listen = 1
			pause = .5
			it = 1
			try:
				while True:
					if(shouldrun):
						blinkLed(2)
						song = djv.recognize(MicrophoneRecognizer, seconds=listen)
						if song is not None:
							djv.log_event('match', str(song['song_id']))