2
#/******************************************************************************
3
# * Copyright (c) 2020 Werner Mayer <wmayer[at]users.sourceforge.net> *
5
# * This file is part of the FreeCAD CAx development system. *
7
# * This library is free software; you can redistribute it and/or *
8
# * modify it under the terms of the GNU Library General Public *
9
# * License as published by the Free Software Foundation; either *
10
# * version 2 of the License, or (at your option) any later version. *
12
# * This library is distributed in the hope that it will be useful, *
13
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
# * GNU Library General Public License for more details. *
17
# * You should have received a copy of the GNU Library General Public *
18
# * License along with this library; see the file COPYING.LIB. If not, *
19
# * write to the Free Software Foundation, Inc., 59 Temple Place, *
20
# * Suite 330, Boston, MA 02111-1307, USA *
22
# ******************************************************************************/
26
import FreeCADGui as Gui
27
from PySide import QtGui
28
from freecad.utils import get_python_exe
30
class RemoteDebugger():
31
def __init__(self, parent=None):
32
ui = App.getHomePath() + "Ext/freecad/gui/RemoteDebugger.ui"
33
self.dialog = Gui.PySideUic.loadUi(ui)
34
self.dialog.buttonBox.accepted.connect(self.accept)
35
self.dialog.buttonBox.rejected.connect(self.reject)
39
index = self.dialog.tabWidget.currentIndex()
41
if index == 0: # winpdb
42
passwd = self.dialog.lineEditPassword.text()
45
rpdb2.start_embedded_debugger(passwd, timeout = 30)
47
elif index == 1: # VS code
48
address = self.dialog.lineEditAddress.text()
49
port = self.dialog.spinBoxPort.value()
53
# get_python_exe is needed because debugpy needs a python interpreter to work.
54
# It does not have to be FC embedded interpreter.
55
# By default it attempts to use Freecad's PID mistaking it for python.
56
# https://github.com/microsoft/debugpy/issues/262
57
debugpy.configure(python=get_python_exe())
58
debugpy.listen((address, port))
59
debugpy.wait_for_client()
61
except Exception as e:
62
QtGui.QMessageBox.warning(self.dialog, "Failed to attach", str(e))
73
def attachToRemoteDebugger():
74
dlg = RemoteDebugger(Gui.getMainWindow())