DebugClients/Python/DebugClientBase.py

changeset 4563
881340f4bd0c
parent 4543
2e6a880670e9
child 4566
a2e8f3c420ec
equal deleted inserted replaced
4561:5bc6ed226471 4563:881340f4bd0c
374 374
375 @param exit flag indicating to terminate (boolean) 375 @param exit flag indicating to terminate (boolean)
376 """ 376 """
377 try: 377 try:
378 self.set_quit() 378 self.set_quit()
379 except: 379 except Exception:
380 pass 380 pass
381 381
382 # clean up asyncio. 382 # clean up asyncio.
383 self.disconnect() 383 self.disconnect()
384 self.debugging = 0 384 self.debugging = 0
770 if cmd == DebugProtocol.RequestEval: 770 if cmd == DebugProtocol.RequestEval:
771 try: 771 try:
772 value = eval( 772 value = eval(
773 arg, self.currentThread.getCurrentFrame().f_globals, 773 arg, self.currentThread.getCurrentFrame().f_globals,
774 self.currentThread.getFrameLocals(0)) 774 self.currentThread.getFrameLocals(0))
775 except: 775 except Exception:
776 # Report the exception and the traceback 776 # Report the exception and the traceback
777 try: 777 try:
778 type, value, tb = sys.exc_info() 778 type, value, tb = sys.exc_info()
779 sys.last_type = type 779 sys.last_type = type
780 sys.last_value = value 780 sys.last_value = value
803 _globals = self.currentThread.getCurrentFrame().f_globals 803 _globals = self.currentThread.getCurrentFrame().f_globals
804 _locals = self.currentThread.getFrameLocals(0) 804 _locals = self.currentThread.getFrameLocals(0)
805 try: 805 try:
806 code = compile(arg + '\n', '<stdin>', 'single') 806 code = compile(arg + '\n', '<stdin>', 'single')
807 exec code in _globals, _locals 807 exec code in _globals, _locals
808 except: 808 except Exception:
809 # Report the exception and the traceback 809 # Report the exception and the traceback
810 try: 810 try:
811 type, value, tb = sys.exc_info() 811 type, value, tb = sys.exc_info()
812 sys.last_type = type 812 sys.last_type = type
813 sys.last_value = value 813 sys.last_value = value
875 self.test = unittest.defaultTestLoader\ 875 self.test = unittest.defaultTestLoader\
876 .loadTestsFromName(tfn, utModule) 876 .loadTestsFromName(tfn, utModule)
877 except AttributeError: 877 except AttributeError:
878 self.test = unittest.defaultTestLoader\ 878 self.test = unittest.defaultTestLoader\
879 .loadTestsFromModule(utModule) 879 .loadTestsFromModule(utModule)
880 except: 880 except Exception:
881 exc_type, exc_value, exc_tb = sys.exc_info() 881 exc_type, exc_value, exc_tb = sys.exc_info()
882 self.write( 882 self.write(
883 '%s%s\n' % ( 883 '%s%s\n' % (
884 DebugProtocol.ResponseUTPrepared, 884 DebugProtocol.ResponseUTPrepared,
885 unicode((0, str(exc_type), str(exc_value))))) 885 unicode((0, str(exc_type), str(exc_value)))))
994 _locals["sys"].stdout = __stdout 994 _locals["sys"].stdout = __stdout
995 else: 995 else:
996 exec code in _globals, _locals 996 exec code in _globals, _locals
997 except SystemExit, exc: 997 except SystemExit, exc:
998 self.progTerminated(exc.code) 998 self.progTerminated(exc.code)
999 except: 999 except Exception:
1000 # Report the exception and the traceback 1000 # Report the exception and the traceback
1001 try: 1001 try:
1002 type, value, tb = sys.exc_info() 1002 type, value, tb = sys.exc_info()
1003 sys.last_type = type 1003 sys.last_type = type
1004 sys.last_value = value 1004 sys.last_value = value
1493 "PyQt5." in str(type(obj)): 1493 "PyQt5." in str(type(obj)):
1494 qtVariable = True 1494 qtVariable = True
1495 qvar = obj 1495 qvar = obj
1496 qvtype = ("%s" % type(qvar))[1:-1]\ 1496 qvtype = ("%s" % type(qvar))[1:-1]\
1497 .split()[1][1:-1] 1497 .split()[1][1:-1]
1498 except: 1498 except Exception:
1499 pass 1499 pass
1500 try: 1500 try:
1501 exec 'mcdict = dict%s.__class__.__dict__' % access 1501 exec 'mcdict = dict%s.__class__.__dict__' % access
1502 ndict.update(mcdict) # __IGNORE_WARNING__ 1502 ndict.update(mcdict) # __IGNORE_WARNING__
1503 if mdict and "sipThis" not in mdict.keys(): # __IGNORE_WARNING__ 1503 if mdict and "sipThis" not in mdict.keys(): # __IGNORE_WARNING__
1504 del rvar[0:2] 1504 del rvar[0:2]
1505 access = "" 1505 access = ""
1506 except: 1506 except Exception:
1507 pass 1507 pass
1508 try: 1508 try:
1509 cdict = {} 1509 cdict = {}
1510 exec 'slv = dict%s.__slots__' % access 1510 exec 'slv = dict%s.__slots__' % access
1511 for v in slv: # __IGNORE_WARNING__ 1511 for v in slv: # __IGNORE_WARNING__
1512 try: 1512 try:
1513 exec 'cdict[v] = dict%s.%s' % (access, v) 1513 exec 'cdict[v] = dict%s.%s' % (access, v)
1514 except: 1514 except Exception:
1515 pass 1515 pass
1516 ndict.update(cdict) 1516 ndict.update(cdict)
1517 exec 'obj = dict%s' % access 1517 exec 'obj = dict%s' % access
1518 access = "" 1518 access = ""
1519 if "PyQt4." in str(type(obj)) or \ 1519 if "PyQt4." in str(type(obj)) or \
1520 "PyQt5." in str(type(obj)): 1520 "PyQt5." in str(type(obj)):
1521 qtVariable = True 1521 qtVariable = True
1522 qvar = obj 1522 qvar = obj
1523 qvtype = ("%s" % type(qvar))[1:-1]\ 1523 qvtype = ("%s" % type(qvar))[1:-1]\
1524 .split()[1][1:-1] 1524 .split()[1][1:-1]
1525 except: 1525 except Exception:
1526 pass 1526 pass
1527 else: 1527 else:
1528 try: 1528 try:
1529 ndict.update(dict[var[i]].__dict__) 1529 ndict.update(dict[var[i]].__dict__)
1530 ndict.update(dict[var[i]].__class__.__dict__) 1530 ndict.update(dict[var[i]].__class__.__dict__)
1534 "PyQt5." in str(type(obj)): 1534 "PyQt5." in str(type(obj)):
1535 qtVariable = True 1535 qtVariable = True
1536 qvar = obj 1536 qvar = obj
1537 qvtype = ("%s" % type(qvar))[1:-1]\ 1537 qvtype = ("%s" % type(qvar))[1:-1]\
1538 .split()[1][1:-1] 1538 .split()[1][1:-1]
1539 except: 1539 except Exception:
1540 pass 1540 pass
1541 try: 1541 try:
1542 cdict = {} 1542 cdict = {}
1543 slv = dict[var[i]].__slots__ 1543 slv = dict[var[i]].__slots__
1544 for v in slv: 1544 for v in slv:
1545 try: 1545 try:
1546 exec 'cdict[v] = dict[var[i]].%s' % v 1546 exec 'cdict[v] = dict[var[i]].%s' % v
1547 except: 1547 except Exception:
1548 pass 1548 pass
1549 ndict.update(cdict) 1549 ndict.update(cdict)
1550 obj = dict[var[i]] 1550 obj = dict[var[i]]
1551 if "PyQt4." in str(type(obj)) or \ 1551 if "PyQt4." in str(type(obj)) or \
1552 "PyQt5." in str(type(obj)): 1552 "PyQt5." in str(type(obj)):
1553 qtVariable = True 1553 qtVariable = True
1554 qvar = obj 1554 qvar = obj
1555 qvtype = ("%s" % type(qvar))[1:-1]\ 1555 qvtype = ("%s" % type(qvar))[1:-1]\
1556 .split()[1][1:-1] 1556 .split()[1][1:-1]
1557 except: 1557 except Exception:
1558 pass 1558 pass
1559 odict = dict 1559 odict = dict
1560 dict = ndict 1560 dict = ndict
1561 i += 1 1561 i += 1
1562 1562
1616 varlist.append(('...', 'dict', "%d" % len(obj.keys()))) 1616 varlist.append(('...', 'dict', "%d" % len(obj.keys())))
1617 elif unicode(repr(obj)).startswith('['): 1617 elif unicode(repr(obj)).startswith('['):
1618 varlist.append(('...', 'list', "%d" % len(obj))) 1618 varlist.append(('...', 'list', "%d" % len(obj)))
1619 elif unicode(repr(obj)).startswith('('): 1619 elif unicode(repr(obj)).startswith('('):
1620 varlist.append(('...', 'tuple', "%d" % len(obj))) 1620 varlist.append(('...', 'tuple', "%d" % len(obj)))
1621 except: 1621 except Exception:
1622 pass 1622 pass
1623 1623
1624 self.write('%s%s\n' % ( 1624 self.write('%s%s\n' % (
1625 DebugProtocol.ResponseVariable, unicode(varlist))) 1625 DebugProtocol.ResponseVariable, unicode(varlist)))
1626 1626
1846 else: 1846 else:
1847 if valtype == 'dict': 1847 if valtype == 'dict':
1848 rvalue = "%d" % len(value.keys()) 1848 rvalue = "%d" % len(value.keys())
1849 else: 1849 else:
1850 rvalue = "%d" % len(value) 1850 rvalue = "%d" % len(value)
1851 except: 1851 except Exception:
1852 rvalue = '' 1852 rvalue = ''
1853 1853
1854 if formatSequences: 1854 if formatSequences:
1855 if unicode(key) == key: 1855 if unicode(key) == key:
1856 key = "'%s'" % key 1856 key = "'%s'" % key
1897 break 1897 break
1898 pos -= 1 1898 pos -= 1
1899 1899
1900 try: 1900 try:
1901 comp = self.complete(text, state) 1901 comp = self.complete(text, state)
1902 except: 1902 except Exception:
1903 comp = None 1903 comp = None
1904 while comp is not None: 1904 while comp is not None:
1905 completions.append(comp) 1905 completions.append(comp)
1906 state += 1 1906 state += 1
1907 try: 1907 try:
1908 comp = self.complete(text, state) 1908 comp = self.complete(text, state)
1909 except: 1909 except Exception:
1910 comp = None 1910 comp = None
1911 1911
1912 self.write("%s%s||%s\n" % (DebugProtocol.ResponseCompletion, 1912 self.write("%s%s||%s\n" % (DebugProtocol.ResponseCompletion,
1913 unicode(completions), text)) 1913 unicode(completions), text))
1914 1914
2145 remoteAddress = ipOrHost 2145 remoteAddress = ipOrHost
2146 elif ipOrHost[0] in '0123456789': 2146 elif ipOrHost[0] in '0123456789':
2147 remoteAddress = ipOrHost 2147 remoteAddress = ipOrHost
2148 else: 2148 else:
2149 remoteAddress = self.__resolveHost(ipOrHost) 2149 remoteAddress = self.__resolveHost(ipOrHost)
2150 except: 2150 except Exception:
2151 remoteAddress = None 2151 remoteAddress = None
2152 sys.argv = [''] 2152 sys.argv = ['']
2153 if '' not in sys.path: 2153 if '' not in sys.path:
2154 sys.path.insert(0, '') 2154 sys.path.insert(0, '')
2155 if port >= 0: 2155 if port >= 0:

eric ide

mercurial