Exemplo n.º 1
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)
    Log.Debug("Validate Prefs called.")

    # cache the channel state
    update_dict = False
    restart = False

    # reset pin
    Dict["pin_correct_time"] = None

    config.initialize()
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != config.enable_channel:
        Log.Debug("Channel features %s, restarting plugin",
                  "enabled" if config.enable_channel else "disabled")
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = config.enable_channel
        Dict.Save()

    if restart:
        DispatchRestart()

    scheduler.setup_tasks()
    set_refresh_menu_state(None)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.register_logging_handler(DEPENDENCY_MODULE_NAMES,
                                    level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))

    return
Exemplo n.º 2
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)
    Log.Debug("Validate Prefs called.")
    config.initialize()
    scheduler.setup_tasks()
    set_refresh_menu_state(None)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.registerLoggingHander(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))

    return
Exemplo n.º 3
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)
    Log.Debug("Validate Prefs called.")
    config.initialize()
    scheduler.setup_tasks()
    set_refresh_menu_state(None)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.registerLoggingHander(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))

    return
Exemplo n.º 4
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)
    Log.Debug("Validate Prefs called.")

    # cache the channel state
    update_dict = False
    restart = False
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != Prefs["enable_channel"]:
        Log.Debug("Channel features %s, restarting plugin", "enabled" if Prefs["enable_channel"] else "disabled")
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = Prefs["enable_channel"]
        Dict.Save()

    if restart:
        DispatchRestart()

    config.initialize()
    scheduler.setup_tasks()
    set_refresh_menu_state(None)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))

    return
Exemplo n.º 5
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    # cache the channel state
    update_dict = False
    restart = False

    # reset pin
    Dict["pin_correct_time"] = None

    config.initialize()
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != config.enable_channel:
        Log.Debug("Channel features %s, restarting plugin",
                  "enabled" if config.enable_channel else "disabled")
        update_dict = True
        restart = True

    if "plugin_pin_mode" not in Dict:
        update_dict = True

    elif Dict["plugin_pin_mode"] != Prefs["plugin_pin_mode"]:
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = config.enable_channel
        Dict["plugin_pin_mode"] = Prefs["plugin_pin_mode"]
        Dict.Save()

    if restart:
        scheduler.stop()
        DispatchRestart()
        return

    scheduler.stop()
    scheduler.setup_tasks()
    set_refresh_menu_state(None)

    Log.Debug("Validate Prefs called.")

    # SZ config debug
    Log.Debug("--- SZ Config-Debug ---")
    for attr in [
            "app_support_path", "data_path", "data_items_path", "enable_agent",
            "enable_channel", "permissions_ok", "missing_permissions",
            "fs_encoding", "subtitle_destination_folder", "dbm_supported",
            "lang_list", "providers"
    ]:
        Log.Debug("config.%s: %s", attr, getattr(config, attr))

    for attr in ["plugin_log_path", "server_log_path"]:
        value = getattr(config, attr)
        access = os.access(value, os.R_OK)
        if Core.runtime.os == "Windows":
            try:
                f = open(value, "r")
                f.read(1)
                f.close()
            except:
                access = False

        Log.Debug("config.%s: %s (accessible: %s)", attr, value, access)

    for attr in [
            "subtitles.save.filesystem",
    ]:
        Log.Debug("Pref.%s: %s", attr, Prefs[attr])

    # fixme: check existance of and os access of logs
    Log.Debug("Platform: %s", Core.runtime.platform)
    Log.Debug("OS: %s", Core.runtime.os)
    Log.Debug("----- Environment -----")
    for key, value in os.environ.iteritems():
        if key.startswith("PLEX") or key.startswith("SZ_"):
            if "TOKEN" in key:
                outval = "xxxxxxxxxxxxxxxxxxx"

            else:
                outval = value
            Log.Debug("%s: %s", key, outval)
    Log.Debug("Locale: %s", locale.getdefaultlocale())
    Log.Debug("-----------------------")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.register_logging_handler(DEPENDENCY_MODULE_NAMES,
                                    level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))
    os.environ[
        'U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E'

    return
Exemplo n.º 6
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    # cache the channel state
    update_dict = False
    restart = False

    # reset pin
    Dict["pin_correct_time"] = None

    config.initialize()
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != config.enable_channel:
        Log.Debug("Interface features %s, restarting plugin", "enabled" if config.enable_channel else "disabled")
        update_dict = True
        restart = True

    if "plugin_pin_mode2" not in Dict:
        update_dict = True

    elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]:
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = config.enable_channel
        Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"]
        Dict.Save()

    if restart:
        scheduler.stop()
        DispatchRestart()
        return

    scheduler.setup_tasks()
    scheduler.clear_task_data("MissingSubtitles")
    set_refresh_menu_state(None)

    Log.Debug("Validate Prefs called.")

    # SZ config debug
    Log.Debug("--- SZ Config-Debug ---")
    for attr in [
            "version", "app_support_path", "data_path", "data_items_path", "enable_agent",
            "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding",
            "subtitle_destination_folder", "new_style_cache", "dbm_supported", "lang_list", "providers",
            "plex_transcoder", "refiner_settings", "unrar", "adv_cfg_path"]:

        value = getattr(config, attr)
        if isinstance(value, dict):
            d = replace_item(copy.deepcopy(value), "api_key", "xxxxxxxxxxxxxxxxxxxxxxxxx")
            Log.Debug("config.%s: %s", attr, d)
            continue

        Log.Debug("config.%s: %s", attr, value)

    for attr in ["plugin_log_path", "server_log_path"]:
        value = getattr(config, attr)

        if value:
            access = os.access(value, os.R_OK)
            if Core.runtime.os == "Windows":
                try:
                    f = open(value, "r")
                    f.read(1)
                    f.close()
                except:
                    access = False

        Log.Debug("config.%s: %s (accessible: %s)", attr, value, access)

    for attr in [
            "subtitles.save.filesystem", ]:
        Log.Debug("Pref.%s: %s", attr, Prefs[attr])

    # debug drone
    if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings:
        Log.Debug("----- Connections -----")
        try:
            from subliminal_patch.refiners.drone import SonarrClient, RadarrClient
            for key, cls in [("sonarr", SonarrClient), ("radarr", RadarrClient)]:
                if key in config.refiner_settings:
                    cname = key.capitalize()
                    try:
                        status = cls(**config.refiner_settings[key]).status()
                    except HTTPError, e:
                        if e.response.status_code == 401:
                            Log.Debug("%s: NOT WORKING - BAD API KEY", cname)
                        else:
                            Log.Debug("%s: NOT WORKING - %s", cname, traceback.format_exc())
                    except:
                        Log.Debug("%s: NOT WORKING - %s", cname, traceback.format_exc())
                    else:
                        if status and status["version"]:
                            Log.Debug("%s: OK - %s", cname, status["version"])
                        else:
                            Log.Debug("%s: NOT WORKING - %s", cname)
Exemplo n.º 7
0
def ValidatePrefs():
    Log.Debug("Validate Prefs called.")
    config.initialize()
    scheduler.setup_tasks()
    return
Exemplo n.º 8
0
def ValidatePrefs():
    Log.Debug("Validate Prefs called.")
    config.initialize()
    scheduler.setup_tasks()
    return
Exemplo n.º 9
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    # cache the channel state
    update_dict = False
    restart = False

    # reset pin
    Dict["pin_correct_time"] = None

    config.initialize()
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != config.enable_channel:
        Log.Debug("Interface features %s, restarting plugin",
                  "enabled" if config.enable_channel else "disabled")
        update_dict = True
        restart = True

    if "plugin_pin_mode2" not in Dict:
        update_dict = True

    elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]:
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = config.enable_channel
        Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"]
        Dict.Save()

    if restart:
        scheduler.stop()
        DispatchRestart()
        return

    scheduler.setup_tasks()
    scheduler.clear_task_data("MissingSubtitles")
    set_refresh_menu_state(None)

    Log.Debug("Validate Prefs called.")

    # SZ config debug
    Log.Debug("--- SZ Config-Debug ---")
    for attr in [
            "version", "app_support_path", "data_path", "data_items_path",
            "enable_agent", "enable_channel", "permissions_ok",
            "missing_permissions", "fs_encoding",
            "subtitle_destination_folder", "include", "include_exclude_paths",
            "include_exclude_sz_files", "new_style_cache", "dbm_supported",
            "lang_list", "providers", "normal_subs", "forced_only",
            "forced_also", "plex_transcoder", "refiner_settings", "unrar",
            "adv_cfg_path", "use_custom_dns", "has_anticaptcha",
            "anticaptcha_cls", "mediainfo_bin"
    ]:

        value = getattr(config, attr)
        if isinstance(value, dict):
            d = replace_item(copy.deepcopy(value), "api_key",
                             "xxxxxxxxxxxxxxxxxxxxxxxxx")
            Log.Debug("config.%s: %s", attr, d)
            continue

        if attr in ("api_key", ):
            value = "xxxxxxxxxxxxxxxxxxxxxxxxx"

        Log.Debug("config.%s: %s", attr, value)

    for attr in ["plugin_log_path", "server_log_path"]:
        value = getattr(config, attr)

        if value:
            access = os.access(value, os.R_OK)
            if Core.runtime.os == "Windows":
                try:
                    f = open(value, "r")
                    f.read(1)
                    f.close()
                except:
                    access = False

        Log.Debug("config.%s: %s (accessible: %s)", attr, value, access)

    for attr in [
            "subtitles.save.filesystem",
    ]:
        Log.Debug("Pref.%s: %s", attr, Prefs[attr])

    if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings:
        Thread.Create(check_connections)

    # fixme: check existance of and os access of logs
    Log.Debug("----- Environment -----")
    Log.Debug("Platform: %s", Core.runtime.platform)
    Log.Debug("OS: %s", Core.runtime.os)
    Log.Debug("Python: %s", platform.python_version())
    for key, value in os.environ.iteritems():
        if key.startswith("PLEX") or key.startswith("SZ_"):
            if "TOKEN" in key:
                outval = "xxxxxxxxxxxxxxxxxxx"

            else:
                outval = value
            Log.Debug("%s: %s", key, outval)
    Log.Debug("Locale: %s", locale.getdefaultlocale())
    Log.Debug("-----------------------")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.register_logging_handler(DEPENDENCY_MODULE_NAMES,
                                    level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))
    os.environ[
        'U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E'

    return
Exemplo n.º 10
0
def ValidatePrefs():
    Core.log.setLevel(logging.DEBUG)

    if Prefs["log_console"]:
        Core.log.addHandler(logger.console_handler)
        Log.Debug("Logging to console from now on")
    else:
        Core.log.removeHandler(logger.console_handler)
        Log.Debug("Stop logging to console")

    # cache the channel state
    update_dict = False
    restart = False

    # reset pin
    Dict["pin_correct_time"] = None

    config.initialize()
    if "channel_enabled" not in Dict:
        update_dict = True

    elif Dict["channel_enabled"] != config.enable_channel:
        Log.Debug("Interface features %s, restarting plugin", "enabled" if config.enable_channel else "disabled")
        update_dict = True
        restart = True

    if "plugin_pin_mode2" not in Dict:
        update_dict = True

    elif Dict["plugin_pin_mode2"] != Prefs["plugin_pin_mode2"]:
        update_dict = True
        restart = True

    if update_dict:
        Dict["channel_enabled"] = config.enable_channel
        Dict["plugin_pin_mode2"] = Prefs["plugin_pin_mode2"]
        Dict.Save()

    if restart:
        scheduler.stop()
        DispatchRestart()
        return

    scheduler.setup_tasks()
    scheduler.clear_task_data("MissingSubtitles")
    set_refresh_menu_state(None)

    Log.Debug("Validate Prefs called.")

    # SZ config debug
    Log.Debug("--- SZ Config-Debug ---")
    for attr in [
            "version", "app_support_path", "data_path", "data_items_path", "enable_agent",
            "enable_channel", "permissions_ok", "missing_permissions", "fs_encoding",
            "subtitle_destination_folder", "include", "include_exclude_paths", "include_exclude_sz_files",
            "new_style_cache", "dbm_supported", "lang_list", "providers", "normal_subs", "forced_only", "forced_also",
            "plex_transcoder", "refiner_settings", "unrar", "adv_cfg_path", "use_custom_dns",
            "has_anticaptcha", "anticaptcha_cls"]:

        value = getattr(config, attr)
        if isinstance(value, dict):
            d = replace_item(copy.deepcopy(value), "api_key", "xxxxxxxxxxxxxxxxxxxxxxxxx")
            Log.Debug("config.%s: %s", attr, d)
            continue

        if attr in ("api_key",):
            value = "xxxxxxxxxxxxxxxxxxxxxxxxx"

        Log.Debug("config.%s: %s", attr, value)

    for attr in ["plugin_log_path", "server_log_path"]:
        value = getattr(config, attr)

        if value:
            access = os.access(value, os.R_OK)
            if Core.runtime.os == "Windows":
                try:
                    f = open(value, "r")
                    f.read(1)
                    f.close()
                except:
                    access = False

        Log.Debug("config.%s: %s (accessible: %s)", attr, value, access)

    for attr in [
            "subtitles.save.filesystem", ]:
        Log.Debug("Pref.%s: %s", attr, Prefs[attr])

    if "sonarr" in config.refiner_settings or "radarr" in config.refiner_settings:
        Thread.Create(check_connections)

    # fixme: check existance of and os access of logs
    Log.Debug("----- Environment -----")
    Log.Debug("Platform: %s", Core.runtime.platform)
    Log.Debug("OS: %s", Core.runtime.os)
    Log.Debug("Python: %s", platform.python_version())
    for key, value in os.environ.iteritems():
        if key.startswith("PLEX") or key.startswith("SZ_"):
            if "TOKEN" in key:
                outval = "xxxxxxxxxxxxxxxxxxx"

            else:
                outval = value
            Log.Debug("%s: %s", key, outval)
    Log.Debug("Locale: %s", locale.getdefaultlocale())
    Log.Debug("-----------------------")

    Log.Debug("Setting log-level to %s", Prefs["log_level"])
    logger.register_logging_handler(DEPENDENCY_MODULE_NAMES, level=Prefs["log_level"])
    Core.log.setLevel(logging.getLevelName(Prefs["log_level"]))
    os.environ['U1pfT01EQl9LRVk'] = '789CF30DAC2C8B0AF433F5C9AD34290A712DF30D7135F12D0FB3E502006FDE081E'

    return