DebugClients/Python3/DebugClientBase.py

changeset 4563
881340f4bd0c
parent 4543
2e6a880670e9
child 4566
a2e8f3c420ec
equal deleted inserted replaced
4561:5bc6ed226471 4563:881340f4bd0c
334 334
335 @param exit flag indicating to terminate (boolean) 335 @param exit flag indicating to terminate (boolean)
336 """ 336 """
337 try: 337 try:
338 self.set_quit() 338 self.set_quit()
339 except: 339 except Exception:
340 pass 340 pass
341 341
342 # clean up asyncio. 342 # clean up asyncio.
343 self.disconnect() 343 self.disconnect()
344 self.debugging = False 344 self.debugging = False
774 try: 774 try:
775 value = eval( 775 value = eval(
776 arg, 776 arg,
777 self.currentThread.getCurrentFrame().f_globals, 777 self.currentThread.getCurrentFrame().f_globals,
778 self.currentThread.getFrameLocals(0)) 778 self.currentThread.getFrameLocals(0))
779 except: 779 except Exception:
780 # Report the exception and the traceback 780 # Report the exception and the traceback
781 try: 781 try:
782 type, value, tb = sys.exc_info() 782 type, value, tb = sys.exc_info()
783 sys.last_type = type 783 sys.last_type = type
784 sys.last_value = value 784 sys.last_value = value
808 _globals = self.currentThread.getCurrentFrame().f_globals 808 _globals = self.currentThread.getCurrentFrame().f_globals
809 _locals = self.currentThread.getFrameLocals(0) 809 _locals = self.currentThread.getFrameLocals(0)
810 try: 810 try:
811 code = compile(arg + '\n', '<stdin>', 'single') 811 code = compile(arg + '\n', '<stdin>', 'single')
812 exec(code, _globals, _locals) 812 exec(code, _globals, _locals)
813 except: 813 except Exception:
814 # Report the exception and the traceback 814 # Report the exception and the traceback
815 try: 815 try:
816 type, value, tb = sys.exc_info() 816 type, value, tb = sys.exc_info()
817 sys.last_type = type 817 sys.last_type = type
818 sys.last_value = value 818 sys.last_value = value
877 self.test = unittest.defaultTestLoader\ 877 self.test = unittest.defaultTestLoader\
878 .loadTestsFromName(tfn, utModule) 878 .loadTestsFromName(tfn, utModule)
879 except AttributeError: 879 except AttributeError:
880 self.test = unittest.defaultTestLoader\ 880 self.test = unittest.defaultTestLoader\
881 .loadTestsFromModule(utModule) 881 .loadTestsFromModule(utModule)
882 except: 882 except Exception:
883 exc_type, exc_value, exc_tb = sys.exc_info() 883 exc_type, exc_value, exc_tb = sys.exc_info()
884 self.write('{0}{1}\n'.format( 884 self.write('{0}{1}\n'.format(
885 DebugProtocol.ResponseUTPrepared, 885 DebugProtocol.ResponseUTPrepared,
886 str((0, str(exc_type), str(exc_value))))) 886 str((0, str(exc_type), str(exc_value)))))
887 self.__exceptionRaised() 887 self.__exceptionRaised()
996 _locals["sys"].stdout = __stdout 996 _locals["sys"].stdout = __stdout
997 else: 997 else:
998 exec(code, _globals, _locals) 998 exec(code, _globals, _locals)
999 except SystemExit as exc: 999 except SystemExit as exc:
1000 self.progTerminated(exc.code) 1000 self.progTerminated(exc.code)
1001 except: 1001 except Exception:
1002 # Report the exception and the traceback 1002 # Report the exception and the traceback
1003 try: 1003 try:
1004 exc_type, exc_value, exc_tb = sys.exc_info() 1004 exc_type, exc_value, exc_tb = sys.exc_info()
1005 sys.last_type = exc_type 1005 sys.last_type = exc_type
1006 sys.last_value = exc_value 1006 sys.last_value = exc_value
1504 "PyQt5." in str(type(obj)): 1504 "PyQt5." in str(type(obj)):
1505 qtVariable = True 1505 qtVariable = True
1506 qvar = obj 1506 qvar = obj
1507 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1507 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1508 ndict.update(mdict) 1508 ndict.update(mdict)
1509 except: 1509 except Exception:
1510 pass 1510 pass
1511 try: 1511 try:
1512 loc = {"dict": dict} 1512 loc = {"dict": dict}
1513 exec('mcdict = dict{0!s}.__class__.__dict__' 1513 exec('mcdict = dict{0!s}.__class__.__dict__'
1514 .format(access), globals(), loc) 1514 .format(access), globals(), loc)
1515 ndict.update(loc["mcdict"]) 1515 ndict.update(loc["mcdict"])
1516 if mdict and "sipThis" not in mdict.keys(): 1516 if mdict and "sipThis" not in mdict.keys():
1517 del rvar[0:2] 1517 del rvar[0:2]
1518 access = "" 1518 access = ""
1519 except: 1519 except Exception:
1520 pass 1520 pass
1521 try: 1521 try:
1522 loc = {"cdict": {}, "dict": dict} 1522 loc = {"cdict": {}, "dict": dict}
1523 exec('slv = dict{0!s}.__slots__'.format(access), 1523 exec('slv = dict{0!s}.__slots__'.format(access),
1524 globals(), loc) 1524 globals(), loc)
1525 for v in loc["slv"]: 1525 for v in loc["slv"]:
1526 try: 1526 try:
1527 loc["v"] = v 1527 loc["v"] = v
1528 exec('cdict[v] = dict{0!s}.{1!s}'.format( 1528 exec('cdict[v] = dict{0!s}.{1!s}'.format(
1529 access, v), globals, loc) 1529 access, v), globals, loc)
1530 except: 1530 except Exception:
1531 pass 1531 pass
1532 ndict.update(loc["cdict"]) 1532 ndict.update(loc["cdict"])
1533 exec('obj = dict{0!s}'.format(access), 1533 exec('obj = dict{0!s}'.format(access),
1534 globals(), loc) 1534 globals(), loc)
1535 obj = loc["obj"] 1535 obj = loc["obj"]
1537 if "PyQt4." in str(type(obj)) or \ 1537 if "PyQt4." in str(type(obj)) or \
1538 "PyQt5." in str(type(obj)): 1538 "PyQt5." in str(type(obj)):
1539 qtVariable = True 1539 qtVariable = True
1540 qvar = obj 1540 qvar = obj
1541 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1541 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1542 except: 1542 except Exception:
1543 pass 1543 pass
1544 else: 1544 else:
1545 try: 1545 try:
1546 ndict.update(dict[var[i]].__dict__) 1546 ndict.update(dict[var[i]].__dict__)
1547 ndict.update(dict[var[i]].__class__.__dict__) 1547 ndict.update(dict[var[i]].__class__.__dict__)
1550 if "PyQt4." in str(type(obj)) or \ 1550 if "PyQt4." in str(type(obj)) or \
1551 "PyQt5." in str(type(obj)): 1551 "PyQt5." in str(type(obj)):
1552 qtVariable = True 1552 qtVariable = True
1553 qvar = obj 1553 qvar = obj
1554 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1554 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1555 except: 1555 except Exception:
1556 pass 1556 pass
1557 try: 1557 try:
1558 slv = dict[var[i]].__slots__ 1558 slv = dict[var[i]].__slots__
1559 loc = {"cdict": {}, "dict": dict, 1559 loc = {"cdict": {}, "dict": dict,
1560 "var": var, "i": i} 1560 "var": var, "i": i}
1562 try: 1562 try:
1563 loc["v"] = v 1563 loc["v"] = v
1564 exec('cdict[v] = dict[var[i]].{0!s}' 1564 exec('cdict[v] = dict[var[i]].{0!s}'
1565 .format(v), 1565 .format(v),
1566 globals(), loc) 1566 globals(), loc)
1567 except: 1567 except Exception:
1568 pass 1568 pass
1569 ndict.update(loc["cdict"]) 1569 ndict.update(loc["cdict"])
1570 obj = dict[var[i]] 1570 obj = dict[var[i]]
1571 if "PyQt4." in str(type(obj)) or \ 1571 if "PyQt4." in str(type(obj)) or \
1572 "PyQt5." in str(type(obj)): 1572 "PyQt5." in str(type(obj)):
1573 qtVariable = True 1573 qtVariable = True
1574 qvar = obj 1574 qvar = obj
1575 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1575 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1576 except: 1576 except Exception:
1577 pass 1577 pass
1578 odict = dict 1578 odict = dict
1579 dict = ndict 1579 dict = ndict
1580 i += 1 1580 i += 1
1581 1581
1653 varlist.append( 1653 varlist.append(
1654 ('...', 'list', "{0:d}".format(len(obj)))) 1654 ('...', 'list', "{0:d}".format(len(obj))))
1655 elif repr(obj).startswith('('): 1655 elif repr(obj).startswith('('):
1656 varlist.append( 1656 varlist.append(
1657 ('...', 'tuple', "{0:d}".format(len(obj)))) 1657 ('...', 'tuple', "{0:d}".format(len(obj))))
1658 except: 1658 except Exception:
1659 pass 1659 pass
1660 1660
1661 self.write('{0}{1}\n'.format( 1661 self.write('{0}{1}\n'.format(
1662 DebugProtocol.ResponseVariable, str(varlist))) 1662 DebugProtocol.ResponseVariable, str(varlist)))
1663 1663
1896 else: 1896 else:
1897 if valtype == 'dict': 1897 if valtype == 'dict':
1898 rvalue = "{0:d}".format(len(value.keys())) 1898 rvalue = "{0:d}".format(len(value.keys()))
1899 else: 1899 else:
1900 rvalue = "{0:d}".format(len(value)) 1900 rvalue = "{0:d}".format(len(value))
1901 except: 1901 except Exception:
1902 rvalue = '' 1902 rvalue = ''
1903 1903
1904 if formatSequences: 1904 if formatSequences:
1905 if str(key) == key: 1905 if str(key) == key:
1906 key = "'{0!s}'".format(key) 1906 key = "'{0!s}'".format(key)
1947 break 1947 break
1948 pos -= 1 1948 pos -= 1
1949 1949
1950 try: 1950 try:
1951 comp = self.complete(text, state) 1951 comp = self.complete(text, state)
1952 except: 1952 except Exception:
1953 comp = None 1953 comp = None
1954 while comp is not None: 1954 while comp is not None:
1955 completions.append(comp) 1955 completions.append(comp)
1956 state += 1 1956 state += 1
1957 try: 1957 try:
1958 comp = self.complete(text, state) 1958 comp = self.complete(text, state)
1959 except: 1959 except Exception:
1960 comp = None 1960 comp = None
1961 1961
1962 self.write("{0}{1}||{2}\n".format(DebugProtocol.ResponseCompletion, 1962 self.write("{0}{1}||{2}\n".format(DebugProtocol.ResponseCompletion,
1963 str(completions), text)) 1963 str(completions), text))
1964 1964
2197 remoteAddress = ipOrHost 2197 remoteAddress = ipOrHost
2198 elif ipOrHost[0] in '0123456789': 2198 elif ipOrHost[0] in '0123456789':
2199 remoteAddress = ipOrHost 2199 remoteAddress = ipOrHost
2200 else: 2200 else:
2201 remoteAddress = self.__resolveHost(ipOrHost) 2201 remoteAddress = self.__resolveHost(ipOrHost)
2202 except: 2202 except Exception:
2203 remoteAddress = None 2203 remoteAddress = None
2204 sys.argv = [''] 2204 sys.argv = ['']
2205 if '' not in sys.path: 2205 if '' not in sys.path:
2206 sys.path.insert(0, '') 2206 sys.path.insert(0, '')
2207 if port >= 0: 2207 if port >= 0:

eric ide

mercurial