def onControl(self, control): if control == self.close_button: self.stop() elif control == self.settings_button: utils.open_settings() else: button = self.getControl(control) response = button.send_cmd(control) if not response: msg = u"{0}: {1}".format(utils.get_string(32103), response.message) utils.notify(msg) if isinstance(control, xbmcgui.ControlRadioButton): control.setSelected(not control.isSelected())
import xbmc import xbmcaddon import xbmcgui from resources.lib import foscam from resources.lib import utils from resources.lib import gui user = utils.get_setting('username') password = utils.get_setting('password') host = utils.get_setting('host') port = utils.get_int_setting('port') if not host: utils.error_dialog(utils.get_string(32101)) sys.exit(1) if utils.invalid_user_char(user, show_dialog=True): sys.exit(1) if utils.invalid_password_char(password, show_dialog=True): sys.exit(1) camera = foscam.Camera(host, port, user, password) success, msg = camera.test() if not success: utils.error_dialog(msg) sys.exit(1)
def error_dialog(msg): xbmcgui.Dialog().ok(utils.get_string(32000), msg, " ", utils.get_string(32102)) utils.open_settings() sys.exit(1)
def send_command(self, command): response = command.send() if not response: msg = u"{0}: {1}".format(utils.get_string(32104), response.message) utils.notify(msg)