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


Python Streamer.Streamer方法代码示例

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


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

示例1: main

# 需要导入模块: from ISStreamer import Streamer [as 别名]
# 或者: from ISStreamer.Streamer import Streamer [as 别名]
def main():
	# Wait for ntpd to run for sync of the clock
	found_ntpd = False
	cnt = 0
	while found_ntpd == False:
		for proc in psutil.process_iter():
			if proc.name() == "ntpd":
				found_ntpd = True 
		cnt += 1
		if cnt == 60: # assume that ntpd has already run if not found in 60 seconds
			found_ntpd=True
		time.sleep(1)

	time.sleep(60*MINUTES_DELAY)
	streamer = Streamer(bucket_name=BUCKET_NAME, bucket_key=BUCKET_KEY, access_key=ACCESS_KEY)
	streamer.log(PROCESS_NAME,"Exited")
	streamer.flush() 
开发者ID:initialstate,项目名称:pi-process-dashboard,代码行数:19,代码来源:monitor_reboot.py

示例2: main

# 需要导入模块: from ISStreamer import Streamer [as 别名]
# 或者: from ISStreamer.Streamer import Streamer [as 别名]
def main():
    streamer = Streamer(bucket_name=BUCKET_NAME, bucket_key=BUCKET_KEY, access_key=ACCESS_KEY)
    # Start temperature stream thread
    try:
       thread.start_new_thread(stream_temp, (streamer, ))
    except:
       print "Error: unable to start temperature streamer thread"

    # Door sensor
    door_status = 1
    while True:
        ## if the switch is open
        if (io.input(door_pin) == True and door_status != 0):
            streamer.log(":door: Door", "Open") 
            print "Door Open"
            streamer.flush() 
            door_status = 0 
        ## if the switch is closed 
        if (io.input(door_pin) == False and door_status != 1):
            streamer.log(":door: Door", "Close") 
            print "Door Closed"
            streamer.flush() 
            door_status = 1 
        time.sleep(2) 
开发者ID:initialstate,项目名称:piot-101,代码行数:26,代码来源:sensors.py

示例3: main

# 需要导入模块: from ISStreamer import Streamer [as 别名]
# 或者: from ISStreamer.Streamer import Streamer [as 别名]
def main():
	if len(sys.argv) != 2:
		print "Usage: " + sys.argv[0] + " <pid>"
		exit()
	pid = sys.argv[1]

	streamer = Streamer(bucket_name=BUCKET_NAME, bucket_key=BUCKET_KEY, access_key=ACCESS_KEY)
	if psutil.pid_exists(int(pid)) == False:
		print "Error: That process doesn't exist! Exiting ..."
		exit()
	else:
		streamer.log(PROCESS_NAME,"Running")
		streamer.flush()

	while True:
		if psutil.pid_exists(int(pid)) == False:
			streamer.log(PROCESS_NAME,"Exited")
			streamer.flush()
			exit()
		else:
			streamer.log(PROCESS_NAME,"Running")
			process = Popen(['hostname', '-I'], stdout=PIPE)
			output, _error = process.communicate()
			streamer.log(PROCESS_NAME + " IP Address", output.rstrip())
			streamer.flush()
		time.sleep(60*MINUTES_BETWEEN_READS) 
开发者ID:initialstate,项目名称:pi-process-dashboard,代码行数:28,代码来源:monitor_process.py

示例4: main

# 需要导入模块: from ISStreamer import Streamer [as 别名]
# 或者: from ISStreamer.Streamer import Streamer [as 别名]
def main(argv):
	bucket = ''
	access_key = ''
	try:
		opts, args = getopt.getopt(argv,"hb:k:",["bucket_name=", "access_key="])
	except getopt.GetoptError:
		print('example_command_line.py -b <bucket_name> -k <access_key>')

	for opt, arg in opts:
		if opt == '-h':
			print('example_command_line.py -b <bucket_name> -k <access_key>')
		elif opt in ("-b", "--bucket_name"):
			bucket = arg
		elif opt in ("-k", "--access_key"):
			access_key = arg


	streamer = Streamer(bucket_name=bucket, access_key=access_key)

	try:
		while 1:
			log = ''
			try:
				if (sys.version_info < (2,7,0)):
				    sys.stderr.write("You need at least python 2.7.0 to use the ISStreamer")
				    exit(1)
				elif (sys.version_info >= (3,0)):
				    log = input()
				else:
				    log = raw_input()
			except EOFError:
				break
			parts = log.split(',')

			if len(parts) == 2:
				streamer.log(parts[0].strip(), parts[1].strip())
			else:
				print("format should be \"key, value\"")

	except KeyboardInterrupt:
		streamer.close() 
开发者ID:initialstate,项目名称:python_appender,代码行数:43,代码来源:example_command_line.py


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