Python pydevd.settrace() Examples
The following are 29
code examples of pydevd.settrace().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pydevd
, or try the search function
.
Example #1
Source File: addon.py From Kodi with GNU Lesser General Public License v3.0 | 7 votes |
def debug(func): if not DEBUG: return func def wrapper(*args, **kwargs): import pydevd pydevd.settrace('localhost', port=4242, stdoutToServer=True, stderrToServer=True) try: func(*args, **kwargs) except Exception as e: pydevd.stoptrace() raise pydevd.stoptrace() return wrapper
Example #2
Source File: attach_script.py From filmkodi with Apache License 2.0 | 6 votes |
def attach(port, host): try: import pydevd pydevd.stoptrace() #I.e.: disconnect if already connected # pydevd.DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = True # pydevd.DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS = 3 # pydevd.DebugInfoHolder.DEBUG_TRACE_LEVEL = 3 pydevd.settrace( port=port, host=host, stdoutToServer=True, stderrToServer=True, overwrite_prev_trace=True, suspend=False, trace_only_current_thread=False, patch_multiprocessing=False, ) except: import traceback;traceback.print_exc()
Example #3
Source File: config.py From sgx-kms with Apache License 2.0 | 6 votes |
def setup_remote_pydev_debug(): """Required setup for remote debugging.""" if CONF.pydev_debug_host and CONF.pydev_debug_port: try: try: from pydev import pydevd except ImportError: import pydevd pydevd.settrace(CONF.pydev_debug_host, port=int(CONF.pydev_debug_port), stdoutToServer=True, stderrToServer=True) except Exception: LOG.exception('Unable to join debugger, please ' 'make sure that the debugger processes is ' 'listening on debug-host \'%s\' debug-port \'%s\'.', CONF.pydev_debug_host, CONF.pydev_debug_port) raise
Example #4
Source File: debugger.py From script.service.kodi.callbacks with GNU General Public License v3.0 | 6 votes |
def startdebugger(): debugegg = '' if sys.platform.lower().startswith('win'): debugegg = os.path.expandvars('%programfiles(x86)%\\JetBrains\\PyCharm 2016.1\\debug-eggs\\pycharm-debug.egg') elif sys.platform.lower().startswith('darwin'): debugegg = '/Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg' elif sys.platform.lower().startswith('linux'): debugegg = os.path.expandvars(os.path.expanduser('~/Applications/pycharm-2016.1.4/debug-eggs/pycharm-debug.egg')) if os.path.exists(debugegg): sys.path.append(debugegg) try: import pydevd except ImportError: xbmc.log(msg = 'Debugger import error @: "%s"' % debugegg) pydevd = pydevd_dummy pydevd.settrace('localhost', port=51234, stdoutToServer=True, stderrToServer=True, suspend=False) else: xbmc.log(msg='Debugger not found @: "%s"' % debugegg)
Example #5
Source File: utils.py From searchlight with Apache License 2.0 | 6 votes |
def setup_remote_pydev_debug(host, port): error_msg = ('Error setting up the debug environment. Verify that the' ' option pydev_worker_debug_host is pointing to a valid ' 'hostname or IP on which a pydev server is listening on' ' the port indicated by pydev_worker_debug_port.') try: try: from pydev import pydevd except ImportError: import pydevd pydevd.settrace(host, port=port, stdoutToServer=True, stderrToServer=True) return True except Exception: with excutils.save_and_reraise_exception(): LOG.exception(error_msg)
Example #6
Source File: server.py From cloudify-manager with Apache License 2.0 | 6 votes |
def _detect_debug_environment(): """ Detect whether server is running in a debug environment if so, connect to debug server at a port stored in env[DEBUG_REST_SERVICE] """ try: docl_debug_path = os.environ.get('DEBUG_CONFIG') if docl_debug_path and os.path.isfile(docl_debug_path): with open(docl_debug_path, 'r') as docl_debug_file: debug_config = yaml.safe_load(docl_debug_file) if debug_config.get('is_debug_on'): import pydevd pydevd.settrace( debug_config['host'], port=53100, stdoutToServer=True, stderrToServer=True, suspend=False) except BaseException as e: raise Exception('Failed to connect to debug server, {0}: {1}'. format(type(e).__name__, str(e)))
Example #7
Source File: config.py From barbican with Apache License 2.0 | 6 votes |
def setup_remote_pydev_debug(): """Required setup for remote debugging.""" if CONF.pydev_debug_host and CONF.pydev_debug_port: try: try: from pydev import pydevd except ImportError: import pydevd pydevd.settrace(CONF.pydev_debug_host, port=int(CONF.pydev_debug_port), stdoutToServer=True, stderrToServer=True) except Exception: LOG.exception('Unable to join debugger, please ' 'make sure that the debugger processes is ' 'listening on debug-host \'%(debug-host)s\' ' 'debug-port \'%(debug-port)s\'.', {'debug-host': CONF.pydev_debug_host, 'debug-port': CONF.pydev_debug_port}) raise
Example #8
Source File: remote_debugger.py From mmvt with GNU General Public License v3.0 | 6 votes |
def execute(self, context): import sys user_preferences = context.user_preferences addon_prefs = user_preferences.addons[__name__].preferences eggpath = os.path.abspath(addon_prefs.eggpath) if not os.path.exists(eggpath): self.report({'ERROR'}, 'Unable to find debug egg at %r. Configure the addon properties ' 'in the User Preferences menu.' % eggpath) return {'CANCELLED'} if not any('pycharm-debug' in p for p in sys.path): sys.path.append(eggpath) import pydevd pydevd.settrace('localhost', port=1090, stdoutToServer=True, stderrToServer=True) return {'FINISHED'}
Example #9
Source File: data_panel.py From mmvt with GNU General Public License v3.0 | 6 votes |
def execute(self, context): fol = op.join(DataMakerPanel.pycharm_fol, 'debug-eggs') eggpath = op.join(fol, 'pydevd-pycharm.egg') if not op.exists(eggpath): eggpath = op.join(fol, 'pycharm-debug-py3k.egg') if not op.exists(eggpath): self.report({'ERROR'}, 'Unable to find debug egg at {}. Configure the addon properties ' 'in the User Preferences menu.'.format(eggpath)) return {'CANCELLED'} if not any('pycharm-debug' in p for p in sys.path): print('Adding eggpath to the path: {}'.format(eggpath)) sys.path.append(eggpath) import pydevd print('Waiting to connects to a PyCharm debugger on localhost:1090') pydevd.settrace('localhost', port=1090, stdoutToServer=True, stderrToServer=True) return {'FINISHED'}
Example #10
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
def _get_python_c_args(host, port, indC, args, setup): setup = _get_setup_updated_with_protocol_and_ppid(setup) # i.e.: We want to make the repr sorted so that it works in tests. setup_repr = setup if setup is None else (sorted_dict_repr(setup)) return ("import sys; sys.path.insert(0, r'%s'); import pydevd; pydevd.PydevdCustomization.DEFAULT_PROTOCOL=%r; " "pydevd.settrace(host=%r, port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=%r, client_access_token=%r, __setup_holder__=%s); " "%s" ) % ( pydev_src_dir, pydevd_constants.get_protocol(), host, port, setup.get('access-token'), setup.get('client-access-token'), setup_repr, args[indC + 1])
Example #11
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 votes |
def _get_python_c_args(host, port, indC, args): return ("import sys; sys.path.append(r'%s'); import pydevd; " "pydevd.settrace(host='%s', port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); %s" ) % ( pydev_src_dir, host, port, args[indC + 1])
Example #12
Source File: FlatCAMWorker.py From FlatCAM with MIT License | 5 votes |
def allow_debug(self): """ allow debuging/breakpoints in this threads should work from PyCharm and PyDev :return: """ if not self.pydevd_failed: try: import pydevd pydevd.settrace(suspend=False, trace_only_current_thread=True) except ImportError: self.pydevd_failed=True
Example #13
Source File: debug.py From deq with MIT License | 5 votes |
def backward(ctx, grad): import pydevd pydevd.settrace(suspend=False, trace_only_current_thread=True) grad_temp = grad.clone() return grad_temp, None
Example #14
Source File: debug.py From plugin.video.youtube with GNU General Public License v2.0 | 5 votes |
def debug_here(host='localhost'): import sys for comp in sys.path: if comp.find('addons') != -1: pydevd_path = os.path.normpath(os.path.join(comp, os.pardir, 'script.module.pydevd', 'lib')) sys.path.append(pydevd_path) break pass import pydevd pydevd.settrace(host, stdoutToServer=True, stderrToServer=True) pass
Example #15
Source File: scripts_utils.py From mmvt with GNU General Public License v3.0 | 5 votes |
def debug(port=1090): pycharm_fol = get_link_dir(get_links_dir(), 'pycharm', throw_exception=True) eggpath = op.join(pycharm_fol, 'debug-eggs', 'pycharm-debug-py3k.egg') if not any('pycharm-debug' in p for p in sys.path): sys.path.append(eggpath) import pydevd pydevd.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True)
Example #16
Source File: debugger.py From script.service.kodi.callbacks with GNU General Public License v3.0 | 5 votes |
def settrace(*args, **kwargs): pass
Example #17
Source File: IntegratorControl.py From PySimulator with GNU Lesser General Public License v3.0 | 5 votes |
def run(self): haveCOM = False try: ''' Do the numerical integration in a try branch to avoid losing the thread when an intended exception is raised ''' try: import pydevd pydevd.connected = True pydevd.settrace(suspend=False) except: # do nothing, since error message only indicates we are not in debug mode pass try: import pythoncom pythoncom.CoInitialize() # Initialize the COM library on the current thread haveCOM = True except: pass self.model.simulate() except SimulatorBase.Stopping: print("solver canceled ... ") except Exception, e: print("unexpected error ... ") print e
Example #18
Source File: debug.py From plugin.audio.tidal2 with GNU General Public License v3.0 | 5 votes |
def halt(self): ''' This is the Break-Point-Function ''' try: self.updatePath() import pydevd pydevd.settrace(self.debugServer, stdoutToServer=True, stderrToServer=True) except: pass
Example #19
Source File: app.py From quay with Apache License 2.0 | 5 votes |
def _request_start(): if os.getenv("PYDEV_DEBUG", None): import pydevd host, port = os.getenv("PYDEV_DEBUG").split(":") pydevd.settrace( host, port=int(port), stdoutToServer=True, stderrToServer=True, suspend=False, ) logger.debug( "Starting request: %s (%s)", request.request_id, request.path, extra={"request_id": request.request_id}, )
Example #20
Source File: api.py From cascade-server with Apache License 2.0 | 5 votes |
def debug(user=None): # Turn on debug printing automatically if a debugger is attached try: import pydevd pydevd.settrace() except ImportError: pass return None, httplib.OK
Example #21
Source File: hello_world_debug_extension.py From gxpy with BSD 2-Clause "Simplified" License | 5 votes |
def rungx(): # remote debug, MUST be removed/commented out for production # this will break inside a running "Debug Extension" configuration in PyCharm pydevd.settrace('localhost', port=34765, stdoutToServer=True, stderrToServer=True) gxc = gxpy.gx.GXpy() gxapi.GXSYS.display_message("GX Python", "Hello {}".format(gxc.gid))
Example #22
Source File: fd_general.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def execute(self, context): import pydevd pydevd.settrace() return {'FINISHED'}
Example #23
Source File: _debugger_case_settrace.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def ask_for_stop(use_back): import pydevd if use_back: pydevd.settrace(stop_at_frame=sys._getframe().f_back) else: pydevd.settrace() print('Will stop here if use_back==False.')
Example #24
Source File: sitecustomize.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def install_breakpointhook(): def custom_sitecustomize_breakpointhook(*args, **kwargs): import os hookname = os.getenv('PYTHONBREAKPOINT') if ( hookname is not None and len(hookname) > 0 and hasattr(sys, '__breakpointhook__') and sys.__breakpointhook__ != custom_sitecustomize_breakpointhook ): sys.__breakpointhook__(*args, **kwargs) else: sys.path.append(os.path.dirname(os.path.dirname(__file__))) import pydevd kwargs.setdefault('stop_at_frame', sys._getframe().f_back) pydevd.settrace(*args, **kwargs) if sys.version_info[0:2] >= (3, 7): # There are some choices on how to provide the breakpoint hook. Namely, we can provide a # PYTHONBREAKPOINT which provides the import path for a method to be executed or we # can override sys.breakpointhook. # pydevd overrides sys.breakpointhook instead of providing an environment variable because # it's possible that the debugger starts the user program but is not available in the # PYTHONPATH (and would thus fail to be imported if PYTHONBREAKPOINT was set to pydevd.settrace). # Note that the implementation still takes PYTHONBREAKPOINT in account (so, if it was provided # by someone else, it'd still work). sys.breakpointhook = custom_sitecustomize_breakpointhook else: if sys.version_info[0] >= 3: import builtins as __builtin__ # Py3 else: import __builtin__ # In older versions, breakpoint() isn't really available, so, install the hook directly # in the builtins. __builtin__.breakpoint = custom_sitecustomize_breakpointhook sys.__breakpointhook__ = custom_sitecustomize_breakpointhook # Install the breakpoint hook at import time.
Example #25
Source File: remotedebug.py From SMA-EM with GNU General Public License v2.0 | 5 votes |
def config(config): # prepare mqtt settings print('debug feature enabled') debughost = config.get('debughost', None) debugport = config.get('debugport', None) if None not in (debughost,debugport): try: print('activate debug for '+debughost+' Port '+str(debugport)) pydevd.settrace(debughost, port=int(debugport), stdoutToServer=True, stderrToServer=True) except Exception as e: print( '...failed') print(e) pass
Example #26
Source File: export_dxf.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def _exportItem(ctx, o, mw, drawing, settings): """ Export one item from export list. mw - modelview """ if settings['verbose']: print('Exporting %s' % o) #mx = ob.matrix.copy() #print 'deb: ob =', ob #--------- #print 'deb: ob.type =', ob.type #--------- #print 'deb: mx =\n', mx #--------- #print 'deb: mw0 =\n', mw0 #--------- #mx_n is trans-matrix for normal_vectors for front-side faces mx = o.matrix_world viewRotation = mw.to_euler().to_matrix() mx_n = o.rotation_euler.to_matrix() * viewRotation mx *= mw #mx_inv = mx.copy().invert() elayer, ecolor, eltype = getCommons(o, settings) if settings['verbose']: print('elayer=%s, ecolor=%s, eltype=%s' % (elayer, ecolor, eltype)) #TODO: use o.boundBox for drawing extends ?? if elayer != None and not drawing.containsLayer(elayer): if ecolor!=None: tempcolor = ecolor else: tempcolor = settings['layercolor_def'] drawing.addLayer(elayer, tempcolor) if DEBUG: pydevd.settrace() if (o.type == 'MESH') and settings['mesh_as']: from .primitive_exporters.mesh_exporter import MeshDXFExporter e = MeshDXFExporter(settings) elif (o.type == 'CURVE') and settings['curve_as']: from .primitive_exporters.curve_exporter import CurveDXFExporter e = CurveDXFExporter(settings) elif (o.type == 'EMPTY') and settings['empty_as']: from .primitive_exporters.empty_exporter import EmptyDXFExporter e = EmptyDXFExporter(settings) elif (o.type == 'TEXT') and settings['text_as']: from .primitive_exporters.text_exporter import TextDXFExporter e = TextDXFExporter(settings) elif (o.type == 'CAMERA') and settings['camera_as']: from .primitive_exporters.camera_exporter import CameraDXFExporter e = CameraDXFExporter(settings) elif (o.type == 'LAMP') and settings['lamp_as']: from .primitive_exporters.lamp_exporter import LampDXFExporter e = LampDXFExporter(settings) return e.export(ctx, drawing, o, mx, mx_n, color=ecolor, layer=elayer, lineType=eltype)
Example #27
Source File: export_dxf.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def exportDXF(context, filePath, settings): """ Main entry point into export facility. """ print("----------\nExporting to {}".format(filePath)) import time time1 = time.clock() if settings['verbose']: print("Generating Object list for export... (Root parents only)") scene = context.scene if settings['onlySelected'] is True: objects = (ob for ob in scene.objects if ob.is_visible(scene) and ob.select and ob.type in SUPPORTED_TYPES) else: objects = (ob for ob in scene.objects if ob.is_visible(scene) and ob.type in SUPPORTED_TYPES) if DEBUG: pydevd.settrace() mw = get_view_projection_matrix(context, settings) try: # add Entities -------------------- #todo: fixme: seems to be the reason for missing BLOCK-export #if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp') #else: tmp_me = None drawing = MigiusDXFLibDrawing() exported = 0 for o in objects: if _exportItem(context, o, mw, drawing, settings): exported +=1 if not drawing.isEmpty(): # NOTE: Only orthographic projection used now. # if PERSPECTIVE: # generate view border - passepartout # from .primitive_exporters.viewborder_exporter import ViewBorderDXFExporter # e = ViewBorderDXFExporter(settings) # e.export(drawing, ob, mx, mw) drawing.convert(filePath) duration = time.clock() - time1 print('%s objects exported in %.2f seconds. -----DONE-----' %\ (exported, duration)) except IOError: print('DXF Exporter: Write Error: ', filePath) except Exception as e: print('Nothing exported. Error: %s' % str(e)) print("Finished") #-------------------------------------------------
Example #28
Source File: _debugger_case_pydevd_customization.py From PyDev.Debugger with Eclipse Public License 1.0 | 4 votes |
def main(): env = os.environ.copy() pythonpath = env.get('PYTHONPATH', '') env['PYTHONPATH'] = os.path.dirname(__file__) + os.pathsep + \ os.path.dirname(os.path.dirname(os.path.dirname(__file__))) from _pydevd_bundle.pydevd_constants import HTTP_JSON_PROTOCOL from _pydevd_bundle.pydevd_defaults import PydevdCustomization PydevdCustomization.DEFAULT_PROTOCOL = HTTP_JSON_PROTOCOL import pydevd from _pydev_bundle import pydev_log pydev_log.debug('Argv received: %s', sys.argv) port = int(sys.argv[1]) print('before pydevd.settrace') pydevd.settrace(port=port, patch_multiprocessing=True, suspend=True) print('after pydevd.settrace') import subprocess if '--use-c-switch' in sys.argv: child_process = subprocess.Popen( [sys.executable, '-u', '-c', 'import _debugger_case_pydevd_customization;_debugger_case_pydevd_customization.call()'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, ) elif '--posix-spawn' in sys.argv: env = os.environ.copy() args = ['-u', '_debugger_case_pydevd_customization.py', '--simple-call'] pid = os.posix_spawn(sys.executable, args, env) os.waitpid(pid, 0) child_process = None # We don't really have a subprocess.Popen instance in this case. else: child_process = subprocess.Popen( [sys.executable, '-u', '_debugger_case_pydevd_customization.py', '--simple-call'], cwd=os.path.dirname(__file__), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, ) if child_process: stdout, stderr = child_process.communicate() assert b'called' in stdout, 'Did not find b"called" in stdout:\n>>%s<<\nstderr:\n>>%s<<\n' % (stdout, stderr) print('TEST SUCEEDED!') # break 2 here
Example #29
Source File: attach_script.py From PyDev.Debugger with Eclipse Public License 1.0 | 4 votes |
def attach(port, host, protocol=''): try: import sys fix_main_thread = 'threading' not in sys.modules if fix_main_thread: def on_warn(msg): from _pydev_bundle import pydev_log pydev_log.warn(msg) def on_exception(msg): from _pydev_bundle import pydev_log pydev_log.exception(msg) def on_critical(msg): from _pydev_bundle import pydev_log pydev_log.critical(msg) fix_main_thread_id(on_warn=on_warn, on_exception=on_exception, on_critical=on_critical) else: from _pydev_bundle import pydev_log # @Reimport pydev_log.debug('The threading module is already imported by user code.') if protocol: from _pydevd_bundle import pydevd_defaults pydevd_defaults.PydevdCustomization.DEFAULT_PROTOCOL = protocol import pydevd # I.e.: disconnect/reset if already connected. pydevd.SetupHolder.setup = None py_db = pydevd.get_global_debugger() if py_db is not None: py_db.dispose_and_kill_all_pydevd_threads(wait=False) # pydevd.DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = True # pydevd.DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS = 3 # pydevd.DebugInfoHolder.DEBUG_TRACE_LEVEL = 3 pydevd.settrace( port=port, host=host, stdoutToServer=True, stderrToServer=True, overwrite_prev_trace=True, suspend=False, trace_only_current_thread=False, patch_multiprocessing=False, ) except: import traceback traceback.print_exc()