def check_addon_alteration(self, addon, addon_path, temp_directory):
addon_url = "{}{}-{}.zip".format(self.download_addon_url, addon["name"], addon["version"])
if addon["version"] == "VERSION":
# TODO
return None, None
log.print_cms("default", "To download the addon : " + addon_url, "", 1)
altered = ""
try:
response = requests.get(addon_url)
response.raise_for_status()
if response.status_code == 200:
zip_file = zipfile.ZipFile(io.BytesIO(response.content), 'r')
zip_file.extractall(temp_directory)
zip_file.close()
project_dir_hash = dirhash(addon_path, 'sha1')
ref_dir = os.path.join(temp_directory, addon["name"])
ref_dir_hash = dirhash(ref_dir, 'sha1')
if project_dir_hash == ref_dir_hash:
altered = "NO"
log.print_cms("good", "Different from sources : " + altered, "", 1)
else:
altered = "YES"
log.print_cms("alert", "Different from sources : " + altered, "", 1)
ignored = ["tests"]
dcmp = dircmp(addon_path, ref_dir, ignored)
uCMS.diff_files(dcmp, addon["alterations"], addon_path)
addon["edited"] = altered
except requests.exceptions.HTTPError as e:
msg = "The download link is not standard. Search manually !"
log.print_cms("alert", msg, "", 1)
addon["notes"] = msg
return msg, e
return altered, None
评论列表
文章目录