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


Python CloudLog类代码示例

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


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

示例1: _runLoop

  def _runLoop(self, params):
    while self._run:
      current_time = int(datetime.now().strftime('%s')) * 1000
      # Read the outside temperature
      try:
        if ((current_time - self.outside["last_updated"]) > (self._outside_config["interval"] * 1000)) and self._outside_config["enabled"]:
          conn = httplib.HTTPConnection("api.wunderground.com")
          url = "/api/[KEY]/conditions/q/" + self._outside_config["location"] + ".json"
          conn.request("GET", url.replace("[KEY]", Keys.WEATHERBUG))
          r1 = conn.getresponse()
          w = json.loads(r1.read())
          conn.close()
          self.outside["temperature"] = int(w.get("current_observation").get("temp_f"))
          self.outside["last_updated"] = current_time
          #CloudLog.track("TEMPERATURE_OUTSIDE", str(self.outside["temperature"]))
      except Exception, e:
        CloudLog.error(self._component, "Error reading outside temperature", e)

      # Read the inside temperature
      try:
        if ((current_time - self.inside["last_updated"]) > (self._inside_config["interval"] * 1000)) and self._inside_config["enabled"]:
          lines = self._readTemperatureSensor()
          while lines[0].strip()[-3:] != 'YES':
            time.sleep(0.2)
            lines = self._readTemperatureSensor()
          equals_pos = lines[1].find('t=')
          if equals_pos != -1:
            temp_string = lines[1][equals_pos+2:]
            temp_c = float(temp_string) / 1000.0
            temp_f = temp_c * 9.0 / 5.0 + 32.0
          self.inside["temperature"] = temp_f
          self.inside["last_updated"] = current_time
          #CloudLog.track("TEMPERATURE_INSIDE", str(self.inside["temperature"]))
      except Exception, e:
        CloudLog.error(self._component, "Error reading inside temperature", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:35,代码来源:Temperature.py

示例2: _runLoop

 def _runLoop(self, params):
   CloudLog.log(self._component, "Running.")
   if self.unread is None:
     self.unread = 0
   while self.running:
     try:
       if self._controller.state == "HOME":
         output = Popen(['lynx', '-source', 'https://www.google.com/voice/request/unread'], stdout=PIPE)
         response = output.stdout.read()
         response = json.loads(response)
         previous_count = self.unread
         self.unread = int(response["unreadCounts"]["all"])
         if self.unread > previous_count:
           cmd = self._settings["cmd_new"]
           self._controller.executeCommandByName(cmd)
         elif self.unread == 0 and previous_count > 0:
           cmd = self._settings["cmd_zero"]
           self._controller.executeCommandByName(cmd)
         interval = self._settings["interval"]
       else:
         interval = self._settings["interval"] * 2
     except Exception, e:
       cmd = self._settings["cmd_error"]
       self._controller.executeCommandByName(cmd)
       if interval < self._settings["interval"] * 10:
         interval += self._interval
     time.sleep(interval)
开发者ID:massimopalmieri,项目名称:PiHomeControl,代码行数:27,代码来源:GVoice.py

示例3: __init__

 def __init__(self, ip_address, port):
   CloudLog.log(self._component, "Initializing.")
   self._ip_address = ip_address
   self._port = port
   with open("config.json", "r") as text_file:
     results = text_file.read()
   self._commands = json.loads(results)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:7,代码来源:Keypad.py

示例4: _send

 def _send(self, device, command):
   result = {"completed": False, "request": {}}
   try:
     if device == "LR":
       port = "1"
       protocol = "FR"
     elif device == "BR":
       port = "2"
       protocol = "LG"
     else:
       port = "3"
       protocol = "FR"
     cmd = "sendir,1:" + port + "," + self._commands[protocol][command]
     result["request"]["command"] = cmd
     if self._ready:
       try:
         s = socket.socket()
         s.settimeout(5)
         s.connect((self._ip_address, self._port))
         s.send(cmd + "\r")
         response = s.recv(1024)
         s.close()
         result["completed"] = True
         result["response"] = str(response)
       except Exception, e:
         CloudLog.error(self._component, "Error when sending command", e)
     else:
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:27,代码来源:AirCon.py

示例5: _startAnnounce

 def _startAnnounce(self):
   if self._threadAnnounce is None:
     try:
       CloudLog.log(self._component + ":StartAnnounce", "Starting UDP Announcer")
       self._threadAnnounce = thread.start_new_thread(self._runAnnounceLoop, (None,))
     except Exception, e:
       CloudLog.error(self._component, "Unable to start announce loop", e)
开发者ID:massimopalmieri,项目名称:PiHomeControl,代码行数:7,代码来源:UDPHandler.py

示例6: _startListen

 def _startListen(self):
   if self._threadListen is None:
     try:
       CloudLog.log(self._component + ":StartListen", "Starting UDP Listener")
       self._thread = thread.start_new_thread(self._runListenLoop, (None,))
     except Exception, e:
       CloudLog.error(self._component, "Unable to start listen loop", e)
开发者ID:massimopalmieri,项目名称:PiHomeControl,代码行数:7,代码来源:UDPHandler.py

示例7: _start

 def _start(self):
   if self.running is False:
     self.running = True
     try:
       self._thread = thread.start_new_thread(self._runLoop, (None,))
     except Exception, e:
       CloudLog.error(self._component, "Unable to start run loop", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:7,代码来源:Cloud.py

示例8: start

 def start(self):
   if self._run is False:
     self._run = True
     try:
       thread.start_new_thread(self._runLoop, (None,))
     except Exception, e:
       CloudLog.error(self._component, "Unable to start temperature loop.", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:7,代码来源:Temperature.py

示例9: play

def play(file_name):
  try:
    if file_name is not None:
      cmd = "mplayer -ao alsa -really-quiet -noconsolecontrols "
      call(cmd+file_name, shell=True)
      CloudLog.debug("SoundSystem", file_name)
  except Exception, e:
    CloudLog.error("SoundSystem.Play", "Error playing sound", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:8,代码来源:SoundSystem.py

示例10: _push

 def _push(self):
   try:
     status = self._controller.status()
     status["user_key"] = Keys.APPENGINE_USER
     content = json.dumps(status)
     self._query("POST", "/set/status", content)
   except Exception, e:
     CloudLog.error(self._component, "Error pushing system status.", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:8,代码来源:Cloud.py

示例11: _readTemperatureSensor

 def _readTemperatureSensor(self):
   try:
     f = open(self._inside_config["sensor_path"], 'r')
     lines = f.readlines()
     f.close()
     return lines
   except Exception, e:
     CloudLog.error(self._component, "Unable to read indoor temperature sensor", e)
     return ""
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:9,代码来源:Temperature.py

示例12: __init__

 def __init__(self, controller):
   CloudLog.log(self._component, "Initializing.")
   self._controller = controller
   try:
     import RPIO
     self._start()
   except Exception, e:
     self.state = "NO_RPIO"
     CloudLog.error(self._component, "RPIO is unavailable.", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:9,代码来源:Door.py

示例13: __init__

    def __init__(self, connection_settings=None):
        CloudLog.log(self._component, "Initializing.")
        if connection_settings is None:
            connection_settings = self._find()

        if connection_settings is not None:
            self._ip_address = connection_settings["ip"]
            self._port = connection_settings["port"]
            self._uuid = connection_settings["uuid"]
开发者ID:pwiiikkk,项目名称:PiHomeControl,代码行数:9,代码来源:Harmony.py

示例14: set_temp

 def set_temp(self, device, temperature):
   try:
     temperature = int(temperature)
     if temperature >= 60 and temperature <= 75:
       self._send(device, str(temperature))
       self._status[device] = temperature
     else:
       CloudLog.error(self._component, "Cannot change temp.")
   except:
     CloudLog.error(self._component, "Temp out of range")
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:10,代码来源:AirCon.py

示例15: status

 def status(self):
   result = {"completed": False, "request": {}}
   result["request"]["command"] = "/status"
   if self._ready:
     try:
       response = self._phue.get_api()
       result["completed"] = True
       result["response"] = response
     except Exception, e:
       CloudLog.error(self._component, "Error calling phue", e)
开发者ID:Dean-Jansen,项目名称:PiHomeControl,代码行数:10,代码来源:Hue.py


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