Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
for lib in [EGG, PDV]:
if lib not in sys.path:
sys.path.insert(0, lib)
import pydevd
try:
if not cmds.commandPort(':{}'.format(PORT), q=1):
cmds.commandPort(n=':{}'.format(PORT))
print(cmds.commandPort(':{}'.format(PORT), q=1))
pydevd.stoptrace()
pydevd.settrace(
"localhost", port=PORT - 1, stdoutToServer=True, stderrToServer=True
)
print("trace start")
except:
pydevd.stoptrace()
cmds.commandPort(n=':{}'.format(PORT), close=1)
print ("trace stop", "maya port {}".format(cmds.commandPort(':{}'.format(PORT), q=1)))
def debug_stop():
try:
import pydevd
pydevd.stoptrace()
except: pass
def attach(port, host, protocol=''):
try:
if protocol:
from _pydevd_bundle import pydevd_defaults
pydevd_defaults.PydevdCustomization.DEFAULT_PROTOCOL = protocol
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()
overwrite_prev_trace=_remote_debugging['overwrite_prev_trace'],
patch_multiprocessing=_remote_debugging['patch_multiprocessing'],
trace_only_current_thread=_remote_debugging['trace_only_current_thread'])
except SystemExit as error:
logger.error('Failed to connect to Python debug server at %s:%d: %s', host, port, error)
else:
logger.debug('Connected to Python debug server at %s:%d', host, port)
global remote_debugging
remote_debugging = _remote_debugging
global settrace
settrace = _settrace
global stoptrace
stoptrace = pydevd.stoptrace
remote_debugging_is_enabled = _remote_debugging['is_enabled']
if isinstance(remote_debugging_is_enabled, (list, set, tuple)):
app_name = path.splitext(path.basename(modules['__main__'].__file__))[0]
remote_debugging_is_enabled = app_name in remote_debugging_is_enabled
if remote_debugging_is_enabled is True:
settrace()
return
def killDebugThreads(self):
''' This kills all PyDevd Remote Debugger Threads '''
try:
self.updatePath()
import pydevd
pydevd.stoptrace()
except:
pass
pass
if os.path.isfile(script_path):
script_name = os.path.splitext(os.path.basename(script_path))[0]
script_dir = os.path.dirname(script_path)
sys.path.append(script_dir)
try:
module = importlib.import_module(script_name)
importlib.reload(module)
module.run({'isApplicationStartup': False})
finally:
del sys.path[-1]
if detach:
try:
import pydevd
pydevd.stoptrace()
except:
pass
except:
traceback.print_exc()
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
sys.path.insert(0, lib)
import pydevd
try:
if not cmds.commandPort(':{}'.format(PORT), q=1):
cmds.commandPort(n=':{}'.format(PORT))
print(cmds.commandPort(':{}'.format(PORT), q=1))
pydevd.stoptrace()
pydevd.settrace(
"localhost", port=PORT - 1, stdoutToServer=True, stderrToServer=True
)
print("trace start")
except:
pydevd.stoptrace()
cmds.commandPort(n=':{}'.format(PORT), close=1)
print ("trace stop", "maya port {}".format(cmds.commandPort(':{}'.format(PORT), q=1)))
sys.path.append(EGG)
sys.path.append(PYD)
sys.path.append(YUR)
import yurlungur as yr
yr.YNode("Camera").location.set(yr.YVector(1, 1, 1).array())
import pydevd
try:
# import hrpyc
# hrpyc.start_server(port=PORT, use_thread=False)
pydevd.settrace(HOST, port=PORT, stdoutToServer=True, stderrToServer=True)
yr.log(yr.name)
except:
pydevd.stoptrace()