FreeCAD

Форк
0
/
RemoteDebugger.py 
75 строк · 3.3 Кб
1
# -*- coding: utf-8 -*-
2
#/******************************************************************************
3
# *   Copyright (c) 2020 Werner Mayer <wmayer[at]users.sourceforge.net>        *
4
# *                                                                            *
5
# *   This file is part of the FreeCAD CAx development system.                 *
6
# *                                                                            *
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.         *
11
# *                                                                            *
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.                     *
16
# *                                                                            *
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                                   *
21
# *                                                                            *
22
# ******************************************************************************/
23

24

25
import FreeCAD as App
26
import FreeCADGui as Gui
27
from PySide import QtGui
28
from freecad.utils import get_python_exe
29

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)
36

37
    def accept(self):
38
        try:
39
            index = self.dialog.tabWidget.currentIndex()
40

41
            if index == 0: # winpdb
42
                passwd = self.dialog.lineEditPassword.text()
43

44
                import rpdb2
45
                rpdb2.start_embedded_debugger(passwd, timeout = 30)
46

47
            elif index == 1: # VS code
48
                address = self.dialog.lineEditAddress.text()
49
                port = self.dialog.spinBoxPort.value()
50

51
                import debugpy
52

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()
60

61
        except Exception as e:
62
            QtGui.QMessageBox.warning(self.dialog, "Failed to attach", str(e))
63

64
        self.dialog.accept()
65

66
    def reject(self):
67
        self.dialog.reject()
68

69
    def exec_(self):
70
        self.dialog.exec_()
71

72

73
def attachToRemoteDebugger():
74
    dlg = RemoteDebugger(Gui.getMainWindow())
75
    dlg.exec_()
76

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.