当前位置: 首页>>代码示例>>Python>>正文


Python Dejavu.create_session方法代码示例

本文整理汇总了Python中dejavu.Dejavu.create_session方法的典型用法代码示例。如果您正苦于以下问题:Python Dejavu.create_session方法的具体用法?Python Dejavu.create_session怎么用?Python Dejavu.create_session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dejavu.Dejavu的用法示例。


在下文中一共展示了Dejavu.create_session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: blinkLed

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import create_session [as 别名]
        response = subprocess.check_output(
            ["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)
开发者ID:pimpmypixel,项目名称:dejavu,代码行数:33,代码来源:start.py

示例2: HTTPServer

# 需要导入模块: from dejavu import Dejavu [as 别名]
# 或者: from dejavu.Dejavu import create_session [as 别名]
server = HTTPServer(('', PORT_NUMBER), myHandler)
thread = threading.Thread(target = server.serve_forever)
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)
开发者ID:pimpmypixel,项目名称:dejavu,代码行数:33,代码来源:serve.py


注:本文中的dejavu.Dejavu.create_session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。