我有一个有效执行以下操作的脚本:
top_script.py:
<script type="text/javascript">
// Write the PIREP data out into JSON
// The big reason being we don't need to have PHP writing JS - yuck
<?php
$report = PIREPData::findPIREPS(array('p.pilotid' => $userinfo->pilotid), 10);
for($i=0; $i<10; $i++)
{
$pirep[$i] = PIREPData::getReportDetails($report[$i]->pirepid);
//var_dump($pirep[$i]);
?>
const flight = JSON.parse('<?php echo json_encode($pirep[$i]); ?>');
console.log(flight[$i]);
<?php
}
?>
const map = createMap({
render_elem: 'routemap',
provider: '<?php echo Config::Get("MAP_TYPE"); ?>',
});
<?php
for($i=0; $i<10; $i++)
{
?>
const depCoords = L.latLng(flight[$i].deplat, flight[$i].deplng);
selDepMarker = L.marker(depCoords, {
icon: MapFeatures.icons.departure,
}).bindPopup(flight[$i].depname).addTo(map);
const arrCoords = L.latLng(flight[$i].arrlat, flight[$i].arrlng);
selArrMarker = L.marker(arrCoords, {
icon: MapFeatures.icons.arrival,
}).bindPopup(flight[$i].arrname).addTo(map);
let points = [];
points.push(depCoords);
<?php
}
?>
// rendering for if there's smartcars data
if(flight.rawdata instanceof Object
&& flight.rawdata.points !== undefined
&& Array.isArray(flight.rawdata.points)
) {
$.each(flight.rawdata.points, function(i, nav) {
if(nav.lat === undefined || nav.lng === undefined) {
return;
}
points.push(L.latLng(nav.lat, nav.lng));
});
} else {
$.each(flight.route_details, function(i, nav) {
const loc = L.latLng(nav.lat, nav.lng);
const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix;
points.push(loc);
const marker = L.marker(loc, {
icon: icon,
title: nav.title,
})
.bindPopup(tmpl("navpoint_bubble", { nav: nav }))
.addTo(map);
});
}
points.push(arrCoords);
const selPointsLayer = L.geodesic([points], {
weight: 2,
opacity: 0.5,
color: 'red',
steps: 10
}).addTo(map);
map.fitBounds(selPointsLayer.getBounds());
</script>
bash_script.sh
os.system("bash_script.sh")
child_script.py
python3 child_script.py
在VSCode中,我喜欢集成调试器,但是当从IDE启动时遵循他们的建议[1]时,我会得到“ ECONNREFUSED 127.0.0.1:5678”。
当我从VSCode的集成终端执行以下命令时,它运行时没有错误,但并没有在child_script.py中的断点处停止。
# Actual work goes here
我如何首先(从IDE或命令行)执行顶级脚本,并让附加在child_script.py中的断点在VSCode中呈现?
答案 0 :(得分:0)
问题在于,使用os.system()
调试器不知道您启动了您关心的另一个Python解释器。您需要做的是附加到第二个过程。详细信息会根据您的设置方式而有所不同,但是您可以将https://code.visualstudio.com/docs/python/debugging#_local-script-debugging作为起点。
答案 1 :(得分:0)
这很简单。您可以将配置添加到您的 launch.json 文件中,如下所示:
{
"name": "MySubProcess",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}
}
现在(通过提示符或其他方式)分别启动python进程。这将生成一个python子进程。您可以在Windows任务管理器中(或在MacOS活动监视器中,或在Linux中以类似方式)看到这一点。
在VSCode中,单击 Debug ,(在上面的示例中选择子流程配置:“ MySubProcess”),然后选择刚刚启动的流程。然后,调试器将在子流程代码中的断点处停止。