fix(1c): resume report inventory from checkpoint names

This commit is contained in:
2026-08-15 14:54:02 +03:00
parent e20881f52d
commit d38d7c0810
+4 -2
View File
@@ -10,9 +10,11 @@ def call(url, method, payload):
def main(): def main():
p=argparse.ArgumentParser(); p.add_argument('--url',required=True); p.add_argument('--base-id',required=True); p.add_argument('--output',type=Path,required=True); a=p.parse_args() p=argparse.ArgumentParser(); p.add_argument('--url',required=True); p.add_argument('--base-id',required=True); p.add_argument('--output',type=Path,required=True); a=p.parse_args()
state=json.loads(a.output.read_text('utf-8')) if a.output.exists() else {'schema':'onec_report_inventory.v1','reports':{}} state=json.loads(a.output.read_text('utf-8')) if a.output.exists() else {'schema':'onec_report_inventory.v1','reports':{}}
names=list(state['reports'])
if not names:
listed=call(a.url,'metadata.objects.list',{'base_id':a.base_id,'kind':'Report','limit':500}) listed=call(a.url,'metadata.objects.list',{'base_id':a.base_id,'kind':'Report','limit':500})
for item in listed.get('objects',[]): names=[item.get('name') for item in listed.get('objects',[])]
name=item.get('name') for name in names:
if not name or state['reports'].get(name, {}).get('status') == 'ok': continue if not name or state['reports'].get(name, {}).get('status') == 'ok': continue
try: state['reports'][name]=call(a.url,'report.inspect',{'base_id':a.base_id,'report':name,'timeout_seconds':60}) try: state['reports'][name]=call(a.url,'report.inspect',{'base_id':a.base_id,'report':name,'timeout_seconds':60})
except Exception as exc: state['reports'][name]={'status':'transport_error','diagnostics':str(exc)} except Exception as exc: state['reports'][name]={'status':'transport_error','diagnostics':str(exc)}