def handle_login(): try: """ get username and password and do login with them """ """ also get whether to hide successful login notification """ username = ownAddon.getSetting('username') password = ownAddon.getSetting('password') login_message_style = ownAddon.getSetting('login_message_style') login_welcome_msg = ownAddon.getSetting('login_welcome_msg') login_failed_msg = ownAddon.getSetting('login_failed_msg') login_required_msg = ownAddon.getSetting('login_required_msg') if username == '' or password == '': koding.Add_Dir(name=_(login_required_msg), url=_(login_required_msg), mode="message", folder=False, icon=xbmcaddon.Addon().getAddonInfo("icon"), fanart=xbmcaddon.Addon().getAddonInfo("fanart"), content_type="") return None true_path = koding.Physical_Path( ('special://home/addons/%s/' % (addon_id))) expiration = ownAddon.getSetting('WEBLOGIN_EXPIRES_AT') if time.time() > expiration or expiration == '': logged_in = weblogin.verify_login(true_path, username, password) if logged_in == True: login_message = login_welcome_msg expires_at = time.time() + 60 * 60 * int(session_length) expiration = expires_at ownAddon.setSetting("WEBLOGIN_EXPIRES_AT", str(expires_at)) display_menu = True else: login_message = login_failed_msg display_menu = False if '%s' in login_message: login_message = login_message % (username) if 'notification' in login_message_style: xbmcgui.Dialog().notification( 'Login Update', login_message, xbmcaddon.Addon().getAddonInfo("icon"), 4000) elif 'popup' in login_message_style: xbmcgui.Dialog().ok('Login Update', login_message) else: display_menu = True except: failure = traceback.format_exc() xbmcgui.Dialog().textviewer( 'Handle Login Exception - Report this to the developer', str(failure)) display_menu = False return display_menu
def handle_login(): try: """ get username and password and do login with them """ """ also get whether to hide successful login notification """ username = ownAddon.getSetting('username') password = ownAddon.getSetting('password') login_message_style = ownAddon.getSetting('login_message_style') login_welcome_msg = ownAddon.getSetting('login_welcome_msg') login_failed_msg = ownAddon.getSetting('login_failed_msg') login_required_msg = ownAddon.getSetting('login_required_msg') if username == '' or password == '': koding.Add_Dir( name=_(login_required_msg), url=_(login_required_msg), mode="message", folder=False, icon=xbmcaddon.Addon().getAddonInfo("icon"), fanart=xbmcaddon.Addon().getAddonInfo("fanart"), content_type="") return None true_path = koding.Physical_Path(('special://home/addons/%s/' % (addon_id))) expiration = ownAddon.getSetting('WEBLOGIN_EXPIRES_AT') if time.time() > expiration or expiration == '': logged_in = weblogin.verify_login(true_path,username,password) if logged_in == True: login_message = login_welcome_msg expires_at = time.time() + 60 * 60 * int(session_length) expiration = expires_at ownAddon.setSetting("WEBLOGIN_EXPIRES_AT", str(expires_at)) display_menu = True else: login_message = login_failed_msg display_menu = False if '%s' in login_message: login_message = login_message % (username) if 'notification' in login_message_style: xbmcgui.Dialog().notification('Login Update', login_message,xbmcaddon.Addon().getAddonInfo("icon"), 4000) elif 'popup' in login_message_style: xbmcgui.Dialog().ok('Login Update', login_message) else: display_menu = True except: failure = traceback.format_exc() xbmcgui.Dialog().textviewer('Handle Login Exception - Report this to the developer',str(failure)) display_menu = False return display_menu