예제 #1
0
    def __init__(self, host, client_port):
        self.client_port = client_port
        self.host = host
        try:
            import pydevd  #@UnresolvedImport
            if pydevd.GetGlobalDebugger() is None:
                raise RuntimeError(
                )  #Work as if the debugger does not exist as it's not connected.
        except:
            self.namespace = globals()
        else:
            #Adapted from the code in pydevd
            #patch provided by: Scott Schlesier - when script is run, it does not
            #pretend pydevconsole is not the main module, and
            #convince the file to be debugged that it was loaded as main
            sys.modules['pydevconsole'] = sys.modules['__main__']
            sys.modules['pydevconsole'].__name__ = 'pydevconsole'

            from imp import new_module
            m = new_module('__main__')
            sys.modules['__main__'] = m
            ns = m.__dict__
            try:
                ns['__builtins__'] = __builtins__
            except NameError:
                pass  #Not there on Jython...
            self.namespace = ns
        self.interpreter = InteractiveConsole(self.namespace)
        self._input_error_printed = False
예제 #2
0
파일: Aria.py 프로젝트: Merlin71/Aria2
def clean_exit():
    print 'Main thread termination'
    try:
        if pydevd.GetGlobalDebugger() is not None:
            print '#################################################'
            print '########   Remote debug session ended  ##########'
            print '#################################################'
            pydevd.stoptrace()
    except:
        pass
예제 #3
0
def breakpoint():
    global _BREAKPOINTS_ENABLED
    if not (is_debug_enabled() and _BREAKPOINTS_ENABLED):
        return

    import pydevd
    pydevd.settrace('localhost',
                    port=5678,
                    suspend=True,
                    stdoutToServer=True,
                    stderrToServer=True)
    import threading
    threading.settrace(pydevd.GetGlobalDebugger().trace_dispatch)
예제 #4
0
 def __enter__(self):
     # Enable trace
     self.old_trace = None
     try:
         import pydevd
         debugger = pydevd.GetGlobalDebugger()
         if debugger is not None:
             self.old_trace = debugger.trace_dispatch
     except ImportError:
         pass
     if self.old_trace is None:
         self.old_trace = sys._getframe(0).f_trace
     sys.settrace(self._trace)
     threading.settrace(self._trace)
예제 #5
0
def RemoteDebug():
    try:
        sys.path.append("/home/pi/eclipse-PyDev/pysrc/")
        import pydevd
        global pydevd
        pydevd.settrace('192.168.0.36',
                        port=5678,
                        suspend=True,
                        trace_only_current_thread=False)
        threading.settrace(pydevd.GetGlobalDebugger().trace_dispatch)
        os.environ['TERM'] = 'xterm'
        print("Remote Debug works")
    except ImportError:
        sys.stderr.write(
            "Error: " +
            "Add pysrc to sys.path.append statement or PYTHONPATH.\n")
        sys.exit(1)
예제 #6
0
    def attach_to_pydev():
        # remove any redirection from previous debugging
        if getattr(sys, "_pyxll_pydev_orig_stdout", None) is None:
            sys._pyxll_pydev_orig_stdout = sys.stdout
        if getattr(sys, "_pyxll_pydev_orig_stderr", None) is None:
            sys._pyxll_pydev_orig_stderr = sys.stderr

        sys.stdout = sys._pyxll_pydev_orig_stdout
        sys.stderr = sys._pyxll_pydev_orig_stderr

        # stop any existing PyDev debugger
        dbg = pydevd.GetGlobalDebugger()
        if dbg:
            dbg.FinishDebuggingSession()
            time.sleep(0.1)
            pydevd_tracing.SetTrace(None)

        # remove any additional info for the current thread
        if threading:
            try:
                del threading.currentThread().__dict__["additionalInfo"]
            except KeyError:
                pass

        pydevd.SetGlobalDebugger(None)
        pydevd.connected = False
        time.sleep(0.1)

        _log.info("Attempting to attach to the PyDev debugger")
        try:
            pydevd.settrace(stdoutToServer=True,
                            stderrToServer=True,
                            suspend=False)
        except Exception as e:
            xlcAlert("Failed to connect to PyDev\n"
                     "Check the debug server is running.\n"
                     "Error: %s" % e)
            return

        xlcAlert("Attatched to PyDev")
예제 #7
0
from solariat_bottle.utils.oauth import get_twitter_oauth_credentials
from solariat_bottle.daemons.helpers import (StoppableThread)

from solariat_bottle.settings import LOGGER
from solariat_bottle.utils.config import sync_with_keyserver
sync_with_keyserver()

try:
    assert False  # set to True to get debugger connected to thread worker

    import threading
    import pydevd

    pydevd.connected = True
    pydevd.settrace(suspend=False)
    threading.settrace(pydevd.GetGlobalDebugger().trace_dispatch)
except (ImportError, AssertionError):
    pass


class Namespace:
    pass


class TimeoutBasket:
    " hold curl easy handles for timeout period "

    def __init__(self, timeout):
        self.timeout = timeout
        self.basket = {}
예제 #8
0
def traceMe():
    if DEBUG_SIM:
        import pydevd
        pydevd.settrace(suspend=False)
        pydevd.GetGlobalDebugger().setExceptHook(Exception, True, False)
예제 #9
0
if __name__ == '__main__':
    print(('Run as main: %s' % (__file__,)))
    import sys
    sys.stdout.flush()
    import pydevd
    # Just check that we're already connected
    assert pydevd.GetGlobalDebugger() is not None
    print('finish')
    sys.stdout.flush()
    print('TEST SUCEEDED!')
    sys.stdout.flush()
예제 #10
0
파일: _patch.py 프로젝트: tinylambda/circus
import threading
from threading import _active_limbo_lock, _active, _sys


debugger = False
try:
    # noinspection PyUnresolvedReferences
    import pydevd
    debugger = pydevd.GetGlobalDebugger()
except ImportError:
    pass

if not debugger:
    # see http://bugs.python.org/issue1596321
    if hasattr(threading.Thread, '_Thread__delete'):
        def _delete(self):
            try:
                with _active_limbo_lock:
                    del _active[self._Thread__ident]
            except KeyError:
                if 'dummy_threading' not in _sys.modules:
                    raise

        threading.Thread._Thread__delete = _delete
    else:
        def _delete(self):  # NOQA
            try:
                with _active_limbo_lock:
                    del _active[self._ident]
            except KeyError:
                if 'dummy_threading' not in _sys.modules:
예제 #11
0
                   print '--------  Blasted Formula  ---------------------'             
                   #print blasted_f
                   if 0:                        
                      blasted_f_with_replaced_n = replace_nstar_with_bools( blasted_f, \
                                                     decls, ackm_bools, ackm_bools_to_vars )            
                      f_with_ackm_reduction = ackerman_reduction_get( \
                                            blasted_f_with_replaced_n , ackm_bools_to_vars )
                   #print ackm_bools_to_vars            
                   z3_formulas_with_blasting.append( blasted_f )
            
            #benchmark_print_to_file(h, z3_formulas_with_blasting)            
            formulas_solver ( self, z3_formulas_with_blasting, decls["I"], I_args )
        
        print 'Total sovling time: ',watch.total_time,'sec'
    
                
if __name__ == '__main__':       
    # This is for debugging errors in Eclipse
    try:
        import pydevd
        pydevd.GetGlobalDebugger().setExceptHook(Exception, True, False)
    except ImportError:
        pass
                 
    h            =  HornBlaster()
    file_prefix  = "sll-find"
    program      =  open("../benchmarks/"+file_prefix+".fol").read()    
    h.output_smt = "../benchmarks/"+file_prefix+".smt2"
    h(program)