Esempio n. 1
0
 def _stop_timer(self, r_id):
     log("ReminderTimersService: Stopping timer for " + r_id)
     try:
         self._timers.pop(r_id).stop()
     except Exception:
         logw("ReminderTimersService: Error stopping timer. Probably " +
              r_id + " does not exist")
Esempio n. 2
0
    def interact(self, message):
        log("ReminderManagementParallelService: Got message")
        try:
            json = dejson(message)
            log("ReminderManagementParallelService: Unmarshalled message")
            action = json['action']
            if action == 'ADD':
                log("ReminderManagementParallelService: Adding reminder...")
                hour = int(json['hour'])
                minute = int(json['minute'])
                weekday = int(json['weekday'])
                concept = int(json['concept'])
                log("ReminderManagementParallelService: Added " +
                    str(concept) + " reminder @" + str(hour) + ":" +
                    str(minute) + " on days " + str(weekday))
                r_id = self._reminders.add_reminder(hour, minute, weekday,
                                                    concept)
                self._publisher.publish(r_id)
                #ReminderSenderParallelService().interact("")
            else:
                r_id = json['id']
                log("ReminderManagementParallelService: Removing reminder " +
                    r_id)
                self._reminders.remove_reminder(r_id)

        except Exception:
            logw("ReminderManagementParallelService: Unreadable message: " +
                 message)
Esempio n. 3
0
 def deregister_remove_callback(self, identifier: str) -> bool:
     log("ReminderData: Deregistering remove callback")
     if identifier in self._remove_callbacks:
         self._remove_callbacks.pop(identifier)
         return True
     else:
         logw("ReminderData: Callback not found")
         return False
Esempio n. 4
0
 def get_seconds_to(self, r_id: str) -> float:
     log("ReminderData: Getting seconds to " + r_id)
     rmndr = self.get_reminder(r_id)
     if rmndr is not None:
         ms = self._get_ms_time(rmndr[0], rmndr[1])
         return ms / 1000
     else:
         logw("ReminderData: Reminder not found")
         return -1
Esempio n. 5
0
 def interact(self, message):
     log("TVBroadcastRemindersParallelService: Got message " + message)
     broadcast = self._kodi.get_next_time(message)
     if broadcast is not None:
         self._reminders.add_reminder(broadcast.hour, broadcast.minute,
                                      broadcast.isoweekday(),
                                      self.TV_CONCEPT)
     else:
         logw("TVBroadcastRemindersParallelService: " + message +
              " not found")
Esempio n. 6
0
 def play_channel(self, channel_name: str) -> bool:
     log("KodiRpc: Request to play " + channel_name)
     channel_id = self._get_channel_id_by_name(channel_name.upper())
     if channel_id is None:
         logw("KodiRpc: Channel not found")
         return False
     else:
         self._playing = True
         self._paused = False
         return self._play_channel("playch", channel_id)
Esempio n. 7
0
 def repeat_reminder(self, r_id: str) -> bool:
     log("ReminderData: Repeating reminder " + r_id)
     if r_id in self._db_reminders:
         if self._db_reminders[r_id][
                 2] in self._NON_REPEATING_REMINDER_CONCEPTS:
             log("ReminderData: Non-repeating reminder, ignoring...")
             return True
         for f in self._add_callbacks.values():
             f(r_id)
         return True
     else:
         logw("ReminderData: Reminder not found")
         return False
Esempio n. 8
0
 def remove_reminder(self, r_id: str) -> bool:
     log("ReminderData: Removing reminder " + r_id)
     if r_id in self._db_reminders:
         reminder = self._db_reminders[r_id]
         self._db_reminders.pop(r_id)
         self._reminders.remove(reminder)
         log("ReminderData: Removed " + r_id)
         log("ReminderData: Executing remove callbacks")
         for f in self._remove_callbacks.values():
             f(r_id)
         return True
     else:
         logw("ReminderData: Reminder not found")
         return False
Esempio n. 9
0
 def stop(self) -> bool:
     log("KodiRpc: Request to stop")
     if not self._playing:
         logw("KodiRpc: Not playing anything")
         return False
     else:
         rpc_call = self._build_json("Input.ExecuteAction", "stp",
                                     {'action': 'stop'})
         response = requests.post(url=self.URL, data=rpc_call).json()
         if response.get('result') == 'OK':
             self._playing = False
             return True
         else:
             return False
Esempio n. 10
0
 def _get_channel_broadcasts(self, name: str) -> list:
     log("KodiRpc: Getting broadcasts of " + name)
     channel_id = self._get_channel_id_by_name(name)
     if channel_id is not None:
         rpc_call = self._build_json("PVR.GetBroadcasts", "gbrd", {
             'channelid': channel_id,
             'properties': ['starttime']
         })
         response = requests.post(url=self.URL, data=rpc_call).json()
         if response is None:
             logw("KodiRpc: Kodi has no broadcasts for this channel")
             return []
         else:
             return response['result'].get('broadcasts')
     else:
         logw("KodiRpc: Channel does not exist")
         return []
Esempio n. 11
0
 def get_reminder(self, r_id: str) -> Union[tuple, NoReturn]:
     log("ReminderData: Getting reminder " + r_id)
     if r_id in self._db_reminders:
         return self._db_reminders[r_id]
     else:
         logw("ReminderData: Reminder not found")