def start(error_counter, addon_path, config = None): colorPrint("Checking %s" % os.path.basename( os.path.normpath(addon_path)), "34") error_counter, addon_xml = _check_addon_xml(error_counter, addon_path) if addon_xml != None: if len(addon_xml.findall("*//broken")) == 0: file_index = _create_file_index(addon_path) error_counter = _check_for_invalid_xml_files(error_counter, file_index) error_counter = _check_for_invalid_json_files( error_counter, file_index) error_counter = _check_artwork(error_counter, addon_path, addon_xml, file_index) if _check_config(config, "check_license_file_exists"): # check if license file is existing error_counter = _addon_file_exists(error_counter, addon_path, "LICENSE\.txt|LICENSE\.md|LICENSE") if _check_config(config, "check_legacy_strings_xml"): error_counter = _check_for_legacy_strings_xml(error_counter, addon_path) if _check_config(config, "check_legacy_language_path"): error_counter = _check_for_legacy_language_path(error_counter, addon_path) error_counter = _find_blacklisted_strings(error_counter, addon_path) error_counter = _check_file_whitelist(error_counter, file_index, addon_path) else: print("Addon marked as broken - skipping") return error_counter
def start(error_counter, addon_path, config=None): colorPrint("Checking %s" % os.path.basename(os.path.normpath(addon_path)), "34") global REL_PATH # Extract common path from addon paths # All paths will be printed relative to this path REL_PATH = os.path.split(addon_path[:-1])[0] error_counter, addon_xml = _check_addon_xml(error_counter, addon_path) if addon_xml != None: if len(addon_xml.findall("*//broken")) == 0: file_index = _create_file_index(addon_path) error_counter = _check_for_invalid_xml_files( error_counter, file_index) error_counter = _check_for_invalid_json_files( error_counter, file_index) error_counter = _check_artwork(error_counter, addon_path, addon_xml, file_index) if check_config(config, "check_license_file_exists"): # check if license file is existing error_counter = _addon_file_exists( error_counter, addon_path, "LICENSE\.txt|LICENSE\.md|LICENSE") if check_config(config, "check_legacy_strings_xml"): error_counter = _check_for_legacy_strings_xml( error_counter, addon_path) if check_config(config, "check_legacy_language_path"): error_counter = _check_for_legacy_language_path( error_counter, addon_path) # Kodi 18 Leia + deprecations if check_config(config, "check_kodi_leia_deprecations"): error_counter = _find_blacklisted_strings( error_counter, addon_path, [ "System.HasModalDialog", "StringCompare", "SubString", "IntegerGreaterThan", "ListItem.ChannelNumber", "ListItem.SubChannelNumber", "MusicPlayer.ChannelNumber", "MusicPlayer.SubChannelNumber", "VideoPlayer.ChannelNumber", "VideoPlayer.SubChannelNumber" ], [], [".py", ".xml"]) # General blacklist error_counter = _find_blacklisted_strings(error_counter, addon_path, [], [], []) error_counter = _check_file_whitelist(error_counter, file_index, addon_path) else: print("Addon marked as broken - skipping") return error_counter
def check_repo(): error_counter = {"warnings": 0, "problems": 0} repo_path = os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) print("Repo path " + repo_path) toplevel_folders = sorted(next(os.walk(repo_path))[1]) print("Toplevel folders " + str(toplevel_folders)) config = _read_config_for_version(repo_path) for addon_folder in toplevel_folders: if addon_folder[0] != '.': addon_path = os.path.join(repo_path, addon_folder) error_counter = check_addon.start(error_counter, addon_path, config) if error_counter["problems"] > 0: colorPrint( "We found %s problems and %s warnings, please check the logfile." % (error_counter["problems"], error_counter["warnings"]), "31") sys.exit(1) elif error_counter["warnings"] > 0: # If we only found warnings, don't mark the build as broken colorPrint( "We found %s problems and %s warnings, please check the logfile." % (error_counter["problems"], error_counter["warnings"]), "35") print("Finished!")
def _check_addon_xml(error_counter, addon_path): addon_xml_path = os.path.join(addon_path, "addon.xml") addon_xml = None try: error_counter = _addon_file_exists(error_counter, addon_path, "addon\.xml") addon_xml = xml.etree.ElementTree.parse(addon_xml_path) addon = addon_xml.getroot() colorPrint("created by %s" % addon.attrib.get("provider-name"), "34") error_counter = _addon_xml_matches_folder(error_counter, addon_path, addon_xml) except xml.etree.ElementTree.ParseError: error_counter = _logProblem(error_counter, "Addon xml not valid, check xml. %s" % addon_xml_path) return error_counter, addon_xml
def check_repo(): error_counter = {"warnings": 0, "problems": 0} repo_path = os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) print("Repo path " + repo_path) parameters = sys.argv[1:] if len(parameters) == 0: toplevel_folders = sorted(next(os.walk(repo_path))[1]) else: toplevel_folders = sorted(parameters) print("Toplevel folders " + str(toplevel_folders)) config = _read_config_for_version(repo_path) for addon_folder in toplevel_folders: if addon_folder[0] != '.': addon_path = os.path.join(repo_path, addon_folder) error_counter = check_addon.start(error_counter, addon_path, config) if check_addon.check_config(config, "comment_on_pull"): if check_addon.comments_problem or check_addon.comments_warning: GithubAPI().comment_on_pull(check_addon.comments_problem, check_addon.comments_warning) GithubAPI().set_label(["Checks failed"]) else: GithubAPI().remove_label(["Checks failed"]) GithubAPI().set_label(["Checks passed"]) if error_counter["problems"] > 0: colorPrint( "We found %s problems and %s warnings, please check the logfile." % (error_counter["problems"], error_counter["warnings"]), "31") sys.exit(1) elif error_counter["warnings"] > 0: # If we only found warnings, don't mark the build as broken colorPrint( "We found %s problems and %s warnings, please check the logfile." % (error_counter["problems"], error_counter["warnings"]), "35") print("Finished!")
def _logWarning(error_counter, warning_string): colorPrint("WARNING: %s" % warning_string, "35") comments_warning.append(warning_string) error_counter["warnings"] = error_counter["warnings"] + 1 return error_counter
def _logProblem(error_counter, problem_string): colorPrint("PROBLEM: %s" % problem_string, "31") comments_problem.append(problem_string) error_counter["problems"] = error_counter["problems"] + 1 return error_counter
def _logWarning(error_counter, warning_string): colorPrint("WARNING: %s" % warning_string, "35") error_counter["warnings"] = error_counter["warnings"] + 1 return error_counter
def _logProblem(error_counter, problem_string): colorPrint("PROBLEM: %s" % problem_string, "31") error_counter["problems"] = error_counter["problems"] + 1 return error_counter