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


Python temperature.Temperature类代码示例

本文整理汇总了Python中temperature.Temperature的典型用法代码示例。如果您正苦于以下问题:Python Temperature类的具体用法?Python Temperature怎么用?Python Temperature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: read

    def read(self, path=None):
        #f6 01 4b 46 7f ff 0a 10 eb : crc=eb YES
        #f6 01 4b 46 7f ff 0a 10 eb t=31375

        path = self.path if not path else path
        temperature = Temperature()

        try:
            sensor = open(path, "r")
            data = sensor.readlines()
            sensor.close()

            if data[0].strip()[-3:] == "YES":
                equals_pos = data[1].find("t=")
                if equals_pos != -1:
                    temperature.set_data(data[1][equals_pos+2:])
                else:
                    raise IndexError
            else:
                raise IndexError
        except IndexError:
            print 'sensor read error'
            #temperature.set_error(index)
        except IOError:
            print 'sensor not connected'
            #temperature.set_error(io)
        except:
            print 'error'
            #temperature.set_error(other)

        return temperature
开发者ID:rimek,项目名称:pi-tools,代码行数:31,代码来源:sensor.py

示例2: test_1

 def test_1(self):
     t = Temperature("64f")
     self.assertEquals(t.value, 64)
     self.assertEquals(t._Temperature__scale, "F")
     t.value = "100k"
     self.assertEquals(t.value, 100)
     self.assertEquals(t._Temperature__scale, "K")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:7,代码来源:test_temperature.py

示例3: test_6

 def test_6(self):
     Temperature.set_default_scale("f")
     t = Temperature("100")
     self.assertEquals(str(t), "100F")
     Temperature.set_default_scale("k")
     t = Temperature("-50")
     self.assertEquals(str(t), "-50K")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:7,代码来源:test_temperature.py

示例4: test_4

 def test_4(self):  # Fahrenheit + Celsius
     t1 = Temperature("32F")
     t2 = Temperature("0C")
     t1.dscale = "K"
     t2.dscale = "K"
     t3 = t1 - t2
     self.assertEquals(t3.value, 0)
     self.assertEquals(t3.scale, "K")
     self.assertEquals(t3.dscale, "K")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:9,代码来源:test_temperature.py

示例5: processtemp

def processtemp(amount, inputunit, outputunit):
  degrees = Temperature(temperature=amount, system=inputunit)

  if outputunit == 'celsius':
    printtemperature(temp=degrees.celsius(), unit=outputunit)
  elif outputunit == 'fahrenheit':
    printtemperature(temp=degrees.fahrenheit(), unit=outputunit)
  elif outputunit == 'kalvin':
    printtemperature(temp=degrees.kalvin(), unit=outputunit)
  elif outputunit == 'rankine':
    printtemperature(temp=degrees.rankine(), unit=outputunit)
开发者ID:frunix,项目名称:converter,代码行数:11,代码来源:functions.py

示例6: temperature

        def temperature():
            # TODO request shouldn't be forwarded to application code
            temp = Temperature(request)

            if request.args.get("accuracy"):
                temp.set_accuracy(int(request.args.get("accuracy")))

            # TODO db_session is temporary here
            if request.method == 'GET':
                return temp.process_get(self.db_session)
            elif request.method == 'POST':
                return temp.process_post(self.db_session)
开发者ID:goldmann,项目名称:collector,代码行数:12,代码来源:collector.py

示例7: task1

def task1():
    count = 0
    r = redis.Redis(host='localhost', port=6379, db=0)
    while True:            
        t = Temperature()
        _t = t.get_value()

        r.set('temperature', _t)
        count += 1

        print 'count: ', count
        print 'temperature: ', _t 
        gevent.sleep(0)
开发者ID:robinsonsantos,项目名称:python-redis,代码行数:13,代码来源:server.py

示例8: __init__

 def __init__(self, buss_id, address):
     self.gyro = Gyroscope(buss_id, address)
     self.gyro_full_scale = 245
     self.acc = Accelerometer(buss_id, address)
     self.acc_full_scale = 2
     self.fifo = Fifo(buss_id, address)
     self.temp = Temperature(buss_id, address)
开发者ID:hajtohaj,项目名称:BBB_Balancer,代码行数:7,代码来源:minimu.py

示例9: get_weather

def get_weather(request):
	town = request.matchdict.get('town', 'Paris')
	temp_per = Temperature.get_by(city=town)
	temp = 0
	if temp_per:
		temp = temp_per.temperature
	else:
		d = weather.get_weather(town)
		temp = d[u'data'][u'current_condition'][0][u'temp_C']
		temp_per = Temperature(city=town, temperature=temp)
		temp_per.save()
	return Response("""
<div style="text-align: center">
	<div style="font-size: 72px">{}</div>
	<div style="font-size: 144px">{}°C</div>
	<div style="font-size: 24px">Current temperature</div>
</div>"""\
	.format(town, temp))
开发者ID:howaryoo,项目名称:pyramid-twisted,代码行数:18,代码来源:weather_pyramid_server.py

示例10: setUp

 def setUp(self):
     self.__oldDefaultScale = Temperature.DEFAULT_SCALE
     Temperature.set_default_scale("C")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:3,代码来源:test_temperature.py

示例11: test_value_error3

 def test_value_error3(self):  # not in ["c", "C", "f", "F", "k", "K"]
     with self.assertRaises(ValueError):
         Temperature.set_default_scale("a")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:3,代码来源:test_temperature.py

示例12: test_value_error2

 def test_value_error2(self):  # not a single char str
     with self.assertRaises(ValueError):
         Temperature.set_default_scale("")
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:3,代码来源:test_temperature.py

示例13: test_k2k

 def test_k2k(self):
     self.assertEquals(Temperature.k2k(100), 100)
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:2,代码来源:test_temperature.py

示例14: test_type_error3

 def test_type_error3(self):  # not a str
     with self.assertRaises(TypeError):
         Temperature.set_default_scale(6)
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:3,代码来源:test_temperature.py

示例15: test_2

 def test_2(self):
     t = Temperature("32F")
     t.dscale = "c"
     t -= 32.
     self.assertEquals(t.value, 0)
开发者ID:KevinLiu1314,项目名称:Temperature,代码行数:5,代码来源:test_temperature.py


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