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_c_to_f_when_c_str_invalid_prop_exception_raised(self):
     c_temp = "hello"
     with self.assertRaises(InvalidPropertyException) as c:
         temps.from_c_to_f(c_temp)
     self.assertIn("temp must be a valid number", c.exception.message)
 def test_c_to_f_when_c_none_raises_missing_property(self):
     c_temp = None
     with self.assertRaises(MissingPropertyException) as c:
         temps.from_c_to_f(c_temp)
     self.assertEqual("temp can not be None!", c.exception.message)
 def test_c_to_f_when_c_positive(self):
     c_temp = 107.6
     expected = 225.68
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)
 def test_c_to_f_when_c_negative(self):
     c_temp = -11.2
     expected = 11.84
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)
 def test_c_to_f_when_c_0(self):
     c_temp = 0
     expected = 32
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)
 def test_c_to_f_when_c_str_invalid_prop_exception_raised(self):
     c_temp = "hello"
     with self.assertRaises(InvalidPropertyException) as c:
         temps.from_c_to_f(c_temp)
     self.assertIn("temp must be a valid number", c.exception.message)
 def test_c_to_f_when_c_none_raises_missing_property(self):
     c_temp = None
     with self.assertRaises(MissingPropertyException) as c:
         temps.from_c_to_f(c_temp)
     self.assertEqual("temp can not be None!", c.exception.message)
 def test_c_to_f_when_c_positive(self):
     c_temp = 107.6
     expected = 225.68
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)
 def test_c_to_f_when_c_negative(self):
     c_temp = -11.2
     expected = 11.84
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)
 def test_c_to_f_when_c_0(self):
     c_temp = 0
     expected = 32
     actual = temps.from_c_to_f(c_temp)
     self.assertEqual(expected, actual)