in gnm_deliverables/management/commands/validate_archive.py [0:0]
def handle(self, *args, **options):
pprint(options)
output_file_path = options["output"]
if not options["server"]:
print("You must specify --server on the commandline")
sys.exit(1)
if not options["secret"]:
print("You must specify --secret on the commandline")
sys.exit(1)
total_count = DeliverableAsset.objects.all().count()
archived_count = self.queryset.count()
try:
authenticated_request(os.path.join(options["server"],"api/entry","not-exist"), options["secret"])
except NotFoundResponse:
pass
with open(output_file_path, "w") as f:
writer = csv.writer(f, dialect=csv.excel)
writer.writerow(["Asset ID","Bundle ID", "Filename","Bundle name","Archive Id","Found"])
logger.info("Out of {} items registered, {} are in the archive".format(total_count, archived_count))
for asset in self.queryset:
if asset.archive_item_id is None:
logger.warning("Item {} has no archive id - should not have been included in search??".format(asset.filename))
try:
url = os.path.join(options["server"],"api/entry",asset.archive_item_id)
logger.debug("url is {0}".format(url))
authenticated_request(url, options["secret"])
logger.info("Found archived entry for {}".format(asset.filename))
except NotFoundResponse:
logger.info("No archived entry found for {}".format(asset.filename))
writer.writerow([asset.id, asset.deliverable_id, asset.filename, asset.deliverable.name, asset.archive_item_id, False])