diff --git a/plugins/1c/tools/inventory_reports.py b/plugins/1c/tools/inventory_reports.py index 9d4cacb..bd3b475 100644 --- a/plugins/1c/tools/inventory_reports.py +++ b/plugins/1c/tools/inventory_reports.py @@ -10,9 +10,11 @@ def call(url, method, payload): 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() state=json.loads(a.output.read_text('utf-8')) if a.output.exists() else {'schema':'onec_report_inventory.v1','reports':{}} - listed=call(a.url,'metadata.objects.list',{'base_id':a.base_id,'kind':'Report','limit':500}) - for item in listed.get('objects',[]): - name=item.get('name') + names=list(state['reports']) + if not names: + listed=call(a.url,'metadata.objects.list',{'base_id':a.base_id,'kind':'Report','limit':500}) + names=[item.get('name') for item in listed.get('objects',[])] + for name in names: 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}) except Exception as exc: state['reports'][name]={'status':'transport_error','diagnostics':str(exc)}