"""Real exported bytes, localhost-only controls, actual platform trial engine. Temporarily runs the dev backend against a disposable localhost supplier and fixture station. Restores its original scanner config, cleans the exact batch. """ import argparse import copy import datetime as dt import hashlib import json from pathlib import Path import time import urllib.request import uuid from verify_cmvr_native import Client, TargetReadOnlyDb, require, response_identifier from verify_scanner_workflow import Supplier, LocalResources, DevBackend from verify_real_framework_url import graph from cleanup_verification import cleanup ROOT=Path(__file__).resolve().parents[1] REPORT=ROOT/'.local/framework-url-offline-20261027.json' NOTE='本机隔离框架URL回归;使用真实导出的P3字节,所有控制只到本机模拟服务,无真实设备操作' def loop_graph(first_task,second_task,prefix): flow=graph(first_task,prefix) start,end=flow['nodes'][0],flow['nodes'][-1] children=flow['nodes'][1:-1] current=dict(id='current',type='currentLoop',properties=dict(name='获取当前循环对象',action='GET_CURRENT_OBJECT',nodeParams=[],outputParams=[dict(name='object',type='string')])) source=next(n for n in children if n['id']=='source') source['properties']['nodeParams'][0]=dict(name='taskId',type='quote',quoteType='output',quote=['current','output','object']) children=[current]+children loop=dict(id='loop',type='loop',children=[n['id'] for n in children],properties=dict(name='逐轮引用导出结果',action='START_LOOP',nodeParams=[dict(name='loopNum',type='input',input=[first_task,second_task])])) flow['nodes']=[start,loop,*children,end] pairs=[('start','loop'),('loop','end')]+[(children[i]['id'],children[i+1]['id']) for i in range(len(children)-1)] flow['edges']=[dict(id='edge-'+str(i),sourceNodeId=a,targetNodeId=b) for i,(a,b) in enumerate(pairs)] return flow def main(): parser=argparse.ArgumentParser(description=__doc__) parser.add_argument('--manage-dev',action='store_true',required=True) parser.add_argument('--component-audit',action='store_true') args=parser.parse_args() client=Client().login();db=TargetReadOnlyDb(client) require(not db.select("SELECT id FROM te_task_inst WHERE status IN ('1','3')"),'存在运行中工作流') require(not db.select("SELECT id FROM lab_execution WHERE status IN ('QUEUED','RUNNING','PAUSED') AND deleted=0"),'存在运行中业务执行') require(not db.select('SELECT owner_key FROM lab_resource_occupation WHERE deleted=0'),'存在设备占用') require(db.select('SELECT COUNT(*) n FROM lab_scanner_command WHERE active_endpoint IS NOT NULL')[0]['n']==0,'存在未确认命令') original_config=client.native('GET','/scanner/configuration')['data'] original_status=client.native('GET','/scanner/status')['data'] require(all(original_status.get(k) is False for k in ('scanning','busy','stateUncertain','restartRequired')),'真实设备不空闲') private_hash=hashlib.sha256((ROOT/'.local/scanner-private.yaml').read_bytes()).hexdigest() chosen=None for row in db.select("SELECT command_key,result_json FROM lab_scanner_command WHERE operation='EXPORT' AND state='SUCCEEDED' ORDER BY updated_at DESC LIMIT 40"): value=json.loads(row['result_json']) files=[f for f in value.get('result',{}).get('files',[]) if f.get('name','').lower().endswith('.p3')] if files: chosen=(row,value,files[0]);break require(chosen,'需要已有真实P3数据') source_command,source_result,source=chosen source_url=client.base_url+'/admin-api/cmvr/scanner/files/'+source['fileId'] def read_real_file(c): req=urllib.request.Request(source_url,headers={'tenant-id':'1','Authorization':'Bearer '+c._token}) with urllib.request.urlopen(req,timeout=20) as r: return r.read(16*1024*1024+1) payload=read_real_file(client) require(0