Esempio n. 1
0
def execute():
    """
    Executable
    :return:
    """
    parser = _setup_arg_parser()
    provided_args = parser.parse_args(sys.argv[1:])
    data_dir = provided_args.datadir
    cook_name = provided_args.cookname
    output_file = "/home/pi/pitmaster_flex.sq3"
    use_lcd = provided_args.tft
    sensors = sensor.find_temp_sensors()
    data_obj = DBObject(filename=output_file)
    if use_lcd:
        display = LocalDisplay()
        display.set_display_msg("Welcome!")
    try:
        while True:
            for sen in sensors:
                temp_c = sensor.read_temp(sen["location"])
                temp_f = temps.from_c_to_f(temp=temp_c)
                info = {
                    "date": time.time(),
                    "temp_f": temp_f,
                    "temp_c": temp_c,
                    "probe_name": sen["name"],
                    "cook_name": cook_name
                }
                data_obj.save(info=info)
                if use_lcd:
                    display.check_events()
                    display.set_display_msg("{}: {}f".format(
                        sen["name"],
                        temp_f
                    ))
                time.sleep(3)
    except KeyboardInterrupt:
        print
        for i in data_obj.list_all_by_cook(cook_name=cook_name):
            print i
        raise SystemExit
Esempio n. 2
0
def execute():
    """
    Executable
    :return:
    """
    parser = _setup_arg_parser()
    provided_args = parser.parse_args(sys.argv[1:])
    data_dir = provided_args.datadir
    cook_name = provided_args.cookname
    output_file = "/home/pi/pitmaster_flex.sq3"
    use_lcd = provided_args.tft
    sensors = sensor.find_temp_sensors()
    data_obj = DBObject(filename=output_file)
    if use_lcd:
        display = LocalDisplay()
        display.set_display_msg("Welcome!")
    try:
        while True:
            for sen in sensors:
                temp_c = sensor.read_temp(sen["location"])
                temp_f = temps.from_c_to_f(temp=temp_c)
                info = {
                    "date": time.time(),
                    "temp_f": temp_f,
                    "temp_c": temp_c,
                    "probe_name": sen["name"],
                    "cook_name": cook_name
                }
                data_obj.save(info=info)
                if use_lcd:
                    display.check_events()
                    display.set_display_msg("{}: {}f".format(
                        sen["name"], temp_f))
                time.sleep(3)
    except KeyboardInterrupt:
        print
        for i in data_obj.list_all_by_cook(cook_name=cook_name):
            print i
        raise SystemExit
 def test_read_temp_raises_exception_when_sensor_not_found(self):
     with self.assertRaises(SensorNotFoundException):
         sensor.read_temp("/foo/bar")
 def test_read_temp_raises_exception_when_missing_sensor(self):
     with self.assertRaises(MissingPropertyException):
         sensor.read_temp()
 def test_read_temp_sensor(self):
     my_sen = tests.data_dir + "/mock_sensor_file"
     temp = sensor.read_temp(my_sen)
     self.assertEqual(20.0, temp)
 def test_read_temp_raises_exception_when_sensor_not_found(self):
     with self.assertRaises(SensorNotFoundException):
         sensor.read_temp("/foo/bar")
 def test_read_temp_raises_exception_when_missing_sensor(self):
     with self.assertRaises(MissingPropertyException):
         sensor.read_temp()
 def test_read_temp_sensor(self):
     my_sen = tests.data_dir + "/mock_sensor_file"
     temp = sensor.read_temp(my_sen)
     self.assertEqual(20.0, temp)