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


Python Monitor.close方法代码示例

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


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

示例1: Main

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import close [as 别名]
class Main(object):
    def __init__(self):
        self.monitor = None

        try:
            # instanciates the config
            self.config = Config()

            # exists baboon when receiving a sigint signal
            signal.signal(signal.SIGINT, self.sigint_handler)

            # Initialize the scm class to use
            scm_classes = Diffman.__subclasses__()
            for cls in scm_classes:
                tmp_inst = cls()
                if tmp_inst.scm_name == self.config.scm:
                    self.diffman = tmp_inst

            # TODO verify self.diffman

            self.mediator = Mediator(self.diffman)

            self.transport = Transport(self.mediator)
            self.transport.open()

            self.monitor = Monitor(self.transport, self.diffman)
            self.monitor.watch()

            # TODO this won't work on windows...
            signal.pause()

        except BaboonException, err:
            sys.stderr.write("%s\n" % err)
            # Try to close the transport properly. If the transport is
            # not correctly started, the close() method has no effect.
            self.transport.close()

            # Same thing for the monitor
            if self.monitor:
                self.monitor.close()

            # Exits with a fail return code
            sys.exit(1)
开发者ID:raphdg,项目名称:baboon,代码行数:45,代码来源:main.py

示例2: Interface

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import close [as 别名]

#.........这里部分代码省略.........

	@Slot(result=bool)
	def isRetrievingTemperature(self):
		return self.temp_thread.isRunning();

	@Slot(result=str)
	def get_command_list(self):
		return json.dumps(self.command_list, sort_keys=True);

	@Slot(result=str)
	def get_scheduled_commands(self):
		adapted = {};
		i = 0;

		for command, date in self.scheduled_commands:
			adapted[str(i)] = [command, str(date.year), str(date.month), str(date.day), str(date.hour), str(date.minute)];
			i += 1;

		return json.dumps(adapted, sort_keys=True);

	@Slot(str, result=str)
	def process_command(self, command):
		#Write the serial string associated with command to the serial port
		try: 
			self.serial_port.write(self.command_list[command][0] + "\n");
			return "Success";
		except:
			print("Error writing command to port.");
			return "Error writing to port";

	def write_commands_list(self):
		com_file = open("commandWindows.yml", "w");
		com_file.write(yaml.dump(self.command_list));
		com_file.close();

	def write_scheduled_list(self):
		com_file = open("scheduledCommands.yml", "w");
		com_file.write(yaml.dump(self.scheduled_commands));
		com_file.close();

	@Slot(str, str, str, result=int)
	def add_command(self, command, serial_string, reply_string):
		command = command.title();

		if command in self.command_list:
			return 1;

		self.command_list[command] = [serial_string, reply_string];

		try:
			self.write_commands_list();
			return 0;
		except:
			return -1;

	@Slot(str, str, str, str, str, str, result=str)
	def schedule_command(self, command, year, month, day, hour, minute):
		try:
			year = int(year);
			month = int(month);
			day = int(day);
			hour = int(hour);
			minute = int(minute);
		except:
			return "Invalid date";
开发者ID:Jacobsjj2,项目名称:automation_server,代码行数:69,代码来源:AutoServer.py


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