[extensions-web] manage: added command to check zip files integrity
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] manage: added command to check zip files integrity
- Date: Wed, 19 Dec 2018 16:39:09 +0000 (UTC)
commit c2bb81125cb37ee3818d37c3e224fe942b83b86c
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Wed Dec 19 20:38:43 2018 +0400
manage: added command to check zip files integrity
.../extensions/management/commands/check_files.py | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
diff --git a/sweettooth/extensions/management/commands/check_files.py
b/sweettooth/extensions/management/commands/check_files.py
new file mode 100644
index 0000000..9f329ec
--- /dev/null
+++ b/sweettooth/extensions/management/commands/check_files.py
@@ -0,0 +1,31 @@
+
+from django.core.management.base import BaseCommand
+from sweettooth.extensions.models import ExtensionVersion, STATUS_REJECTED
+from zipfile import BadZipfile
+
+class Command(BaseCommand):
+ help = "Checks consistency of extension's archives."
+
+ def handle(self, *args, **options):
+ for version in ExtensionVersion.objects.exclude(status=STATUS_REJECTED):
+ badversion = True
+ try:
+ with version.get_zipfile('r') as zip:
+ badfile = zip.testzip()
+
+ if badfile:
+ self.stderr.write("[%s: %d] Bad entry %s in zip file" % (version.extension.name,
version.version, badfile))
+ else:
+ badversion = False
+
+ except IOError, e:
+ self.stderr.write("[%s: %d] Unable to find zip file: %s" % (version.extension.name,
version.version, str(e)))
+ except BadZipfile, e:
+ self.stderr.write("[%s: %d] Bad zip file: %s" % (version.extension.name, version.version,
version.source.name))
+
+ if badversion:
+ self.stdout.write("[%s: %d] Rejecting" % (version.extension.name, version.version))
+
+ self.stdout.flush()
+
+ self.stdout.write('Done')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]