def pytest_configure(config):
    socket = config.getvalue('pydevd')
    if socket is not None:
        addr, port = socket.split(':')

        # prepend path to sys.path
        path = config.getvalue('pydev_lib')
        if path:
            sys.path.insert(0, os.path.expandvars(os.path.expanduser(path)))

        redirect = config.getvalue('pydevd_io')
        stdout = redirect in ('both', 'stdout')
        stderr = redirect in ('both', 'stderr')

        from pydev import pydevd

        # salvaged from pydev's source:
        # - host: the user may specify another host, if the debug server is not
        #   in the same machine
        # - stdoutToServer: when this is true, the stdout is passed to the debug
        #   server
        # - stderrToServer: when this is true, the stderr is passed to the debug
        #   server so that they are printed in its console and not in this
        #   process console.
        # - port: specifies which port to use for communicating with the server
        #   (note that the server must be started in the same port). @note:
        #   currently it's hard-coded at 5678 in the client
        # - suspend: whether a breakpoint should be emulated as soon as this
        #   function is called.
        # - trace_only_current_thread: determines if only the current thread
        #   will be traced or all future threads will also have the tracing
        #   enabled.
        pydevd.settrace(host=addr, port=int(port), suspend=False, 
            stdoutToServer=stdout, stderrToServer=stderr,
            trace_only_current_thread=False, overwrite_prev_trace=False)
Esempio n. 2
0
def start_debugging():
    pydevd.settrace('localhost',
                    port=8585,
                    stdoutToServer=True,
                    stderrToServer=True,
                    suspend=False)
    entry()
Esempio n. 3
0
def generateMoleculeHierarchyTask(structure, debug=False):

    if debug:
        pydevd.settrace('localhost',
                        port=6901,
                        stdoutToServer=True,
                        stderrToServer=True)

    molecule = structure.molecule
    if not molecule.moleculeHierarchy:
        hierarchy = MoleculeHierarchy(molecule=molecule)
    else:
        hierarchy = molecule.moleculeHierarchy

    saltRemover = SaltRemover()
    mol = Chem.MolFromMolBlock(str(structure.molfile))
    base = saltRemover.StripMol(mol)

    if mol.GetNumAtoms() == base.GetNumAtoms():
        hierarchy.parent_molecule = molecule
    else:
        hierarchy.parent_molecule = getParentMolregnoFromBase(
            MolToMolBlock(base))

    hierarchy.active_molecule = hierarchy.parent_molecule

    try:
        hierarchy.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 4
0
def setup_remote_pydev_debug():
    """Required setup for remote debugging."""

    pydev_debug_host = os.environ.get('PYDEV_DEBUG_HOST')
    pydev_debug_port = os.environ.get('PYDEV_DEBUG_PORT')

    if not pydev_debug_host or not pydev_debug_port:
        return

    try:
        try:
            from pydev import pydevd
        except ImportError:
            import pydevd

        LOG.warning("Connecting to remote debugger. Once connected, resume "
                    "the program on the debugger to continue with the "
                    "initialization of the service.")
        pydevd.settrace(pydev_debug_host,
                        port=int(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': pydev_debug_host,
                'debug-port': pydev_debug_port
            })
        raise
Esempio n. 5
0
def init():
    from oslo.config import cfg
    CONF = cfg.CONF
    if 'remote_debug' not in CONF:
        return
    if not(CONF.remote_debug.host and CONF.remote_debug.port):
        return 
    
    from mvpn.openstack.common.gettextutils import _
    from mvpn.openstack.common import log as logging
    LOG = logging.getLogger(__name__)
    LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'),
              {'host': CONF.remote_debug.host,
               'port': CONF.remote_debug.port})
               
    from pydev import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=True,
                    stderrToServer=True)
    
    LOG.warn(_('WARNING: Using the remote debug option changes how '
               'Nova uses the eventlet library to support async IO. This '
               'could result in failures that do not occur under normal '
               'operation. Use at your own risk.'))
Esempio n. 6
0
def init():
    import nova.conf
    CONF = nova.conf.CONF

    # NOTE(markmc): gracefully handle the CLI options not being registered
    if 'remote_debug' not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    import logging
    from nova.i18n import _LW
    LOG = logging.getLogger(__name__)

    LOG.debug('Listening on %(host)s:%(port)s for debug connection',
              {'host': CONF.remote_debug.host,
               'port': CONF.remote_debug.port})

    try:
        from pydev import pydevd
    except ImportError:
        import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=False,
                    stderrToServer=False)

    LOG.warning(_LW('WARNING: Using the remote debug option changes how '
                    'Nova uses the eventlet library to support async IO. This '
                    'could result in failures that do not occur under normal '
                    'operation. Use at your own risk.'))
Esempio n. 7
0
def init():
    from oslo.config import cfg
    CONF = cfg.CONF

    # NOTE(markmc): gracefully handle the CLI options not being registered
    if 'remote_debug' not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    from nova.i18n import _
    from nova.openstack.common import log as logging
    LOG = logging.getLogger(__name__)

    LOG.debug('Listening on %(host)s:%(port)s for debug connection',
              {'host': CONF.remote_debug.host,
               'port': CONF.remote_debug.port})

    try:
        from pydev import pydevd
    except ImportError:
        import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=False,
                    stderrToServer=False)

    LOG.warn(_('WARNING: Using the remote debug option changes how '
               'Nova uses the eventlet library to support async IO. This '
               'could result in failures that do not occur under normal '
               'operation. Use at your own risk.'))
Esempio n. 8
0
def generateCompoundImageTask(structure, debug=False):

    if debug:
        from pydev import pydevd
        pydevd.settrace('localhost', port=6901, stdoutToServer=True, stderrToServer=True)

    molecule = structure.molecule
    if not molecule.compoundImage:
        img = CompoundImages(molecule=molecule)
    else:
        img = molecule.compoundImage

    mol = Chem.MolFromMolBlock(str(structure.molfile))
    raw = Draw.MolToImage(mol, size=(500, 500))
    raw_thumb = Draw.MolToImage(mol, size=(128, 128))

    output = StringIO.StringIO()
    raw.save(output, 'PNG')
    img.png_500 = output.getvalue()
    output.close()

    output = StringIO.StringIO()
    raw_thumb.save(output, 'PNG')
    img.png = output.getvalue()
    output.close()

    try:
        img.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 9
0
def generateMoleculeHierarchyFromPipelinePilot(structure, debug=False):

    if debug:
        pydevd.settrace('localhost',
                        port=6901,
                        stdoutToServer=True,
                        stderrToServer=True)

    molecule = structure.molecule
    if not molecule.moleculeHierarchy:
        hierarchy = MoleculeHierarchy(molecule=molecule)
    else:
        hierarchy = molecule.moleculeHierarchy

    data = cleanup(structure.molfile, 'stripsalts')

    if not data['UPDATED']:
        hierarchy.parent_molecule = molecule
    else:
        hierarchy.parent_molecule = getParentMolregnoFromBase(
            data['UPDATEDCTAB'])

    hierarchy.active_molecule = hierarchy.parent_molecule

    try:
        hierarchy.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 10
0
def generateMoleculeHierarchyTask(structure, debug=False):

    if debug:
        pydevd.settrace('localhost', port=6901, stdoutToServer=True, stderrToServer=True)

    molecule = structure.molecule
    if not molecule.moleculeHierarchy:
        hierarchy = MoleculeHierarchy(molecule=molecule)
    else:
        hierarchy = molecule.moleculeHierarchy

    saltRemover = SaltRemover()
    mol = Chem.MolFromMolBlock(str(structure.molfile))
    base = saltRemover.StripMol(mol)

    if mol.GetNumAtoms() == base.GetNumAtoms():
        hierarchy.parent_molecule = molecule
    else:
        hierarchy.parent_molecule = getParentMolregnoFromBase(MolToMolBlock(base))

    hierarchy.active_molecule = hierarchy.parent_molecule

    try:
        hierarchy.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 11
0
def generateMoleculeHierarchyFromPipelinePilot(structure, debug=False):

    if debug:
        pydevd.settrace('localhost', port=6901, stdoutToServer=True, stderrToServer=True)

    molecule = structure.molecule
    if not molecule.moleculeHierarchy:
        hierarchy = MoleculeHierarchy(molecule=molecule)
    else:
        hierarchy = molecule.moleculeHierarchy

    data = cleanup(structure.molfile, 'stripsalts')

    if not data['UPDATED']:
        hierarchy.parent_molecule = molecule
    else:
        hierarchy.parent_molecule = getParentMolregnoFromBase(data['UPDATEDCTAB'])

    hierarchy.active_molecule = hierarchy.parent_molecule

    try:
        hierarchy.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 12
0
def generateCompoundPropertiesTask(structure, debug=False):
    if debug:
        pydevd.settrace('localhost', port=6901, stdoutToServer=True, stderrToServer=True)

    molecule = structure.molecule
    if not molecule.compoundProperty:
        prop = CompoundProperties(molecule=molecule)
    else:
        prop = molecule.compoundProperty

    saltRemover = SaltRemover()
    mol = Chem.MolFromMolBlock(str(structure.molfile))
    base = saltRemover.StripMol(mol)
    prop.hbd = Descriptors.CalcNumHBD(mol)
    prop.hba = Descriptors.CalcNumHBA(mol)
    prop.rtb = Descriptors.CalcNumRotatableBonds(mol)
    prop.alogp = Crippen.MolLogP(mol)
    prop.psa = Descriptors.CalcTPSA(mol)
    prop.full_mwt = NewDescriptors.MolWt(mol)
    # prop.exact_mass = Descriptors.CalcExactMolWt(mol)

    if base.GetNumAtoms():
        prop.mw_freebase = NewDescriptors.MolWt(base)

    
    prop.full_molformula = Descriptors.CalcMolFormula(mol)
    
    try:
        prop.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 13
0
def init():
    from oslo.config import cfg
    CONF = cfg.CONF

    # NOTE(markmc): gracefully handle the CLI options not being registered
    if 'remote_debug' not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    from nova.openstack.common.gettextutils import _
    from nova.openstack.common import log as logging
    LOG = logging.getLogger(__name__)

    LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'), {
        'host': CONF.remote_debug.host,
        'port': CONF.remote_debug.port
    })

    from pydev import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=False,
                    stderrToServer=False)

    LOG.warn(
        _('WARNING: Using the remote debug option changes how '
          'Nova uses the eventlet library to support async IO. This '
          'could result in failures that do not occur under normal '
          'operation. Use at your own risk.'))
Esempio n. 14
0
    def test_remote_debug(self):
        import sys
        sys.path.append('/home/api-dependencies/pycharm-debug.egg')
        from pydev import pydevd
        pydevd.settrace('192.168.1.11', port=51234, stdoutToServer=True, stderrToServer=True)

        print "foo"
        print "step 1"
        print "step 2"
Esempio n. 15
0
def _enable_pydev(debugger_host, debugger_port):
    try:
        from pydev import pydevd
    except ImportError:
        import pydevd

    pydevd.settrace(debugger_host,
                    port=int(debugger_port),
                    stdoutToServer=True,
                    stderrToServer=True)
Esempio n. 16
0
def _enable_pydev(debugger_host, debugger_port):
    try:
        from pydev import pydevd  # pylint: disable=import-outside-toplevel
    except ImportError:
        import pydevd  # pylint: disable=import-outside-toplevel

    pydevd.settrace(debugger_host,
                    port=int(debugger_port),
                    stdoutToServer=True,
                    stderrToServer=True)
Esempio n. 17
0
def _enable_pydev(debugger_host, debugger_port):
    try:
        from pydev import pydevd
    except ImportError:
        import pydevd

    pydevd.settrace(debugger_host,
                    port=int(debugger_port),
                    stdoutToServer=True,
                    stderrToServer=True)
Esempio n. 18
0
    def create(cls, host=None, binary=None, topic=None, manager=None,
               report_interval=None, periodic_enable=None,
               periodic_fuzzy_delay=None, periodic_interval_max=None,
               db_allowed=True):
        """Instantiates class and passes back application object.

        :param host: defaults to CONF.host
        :param binary: defaults to basename of executable
        :param topic: defaults to bin_name - 'nova-' part
        :param manager: defaults to CONF.<topic>_manager
        :param report_interval: defaults to CONF.report_interval
        :param periodic_enable: defaults to CONF.periodic_enable
        :param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
        :param periodic_interval_max: if set, the max time to wait between runs

        """
        if not host:
            host = CONF.host
        if not binary:
            binary = os.path.basename(sys.argv[0])
        if not topic:
            topic = binary.rpartition('nova-')[2]
        if not manager:
            manager_cls = ('%s_manager' %
                           binary.rpartition('nova-')[2])
            manager = CONF.get(manager_cls, None)
        if report_interval is None:
            report_interval = CONF.report_interval
        if periodic_enable is None:
            periodic_enable = CONF.periodic_enable
        if periodic_fuzzy_delay is None:
            periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
        if CONF.remote_debug.host and CONF.remote_debug.port:
            from pydev import pydevd
            LOG = logging.getLogger('nova')
            LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'),
                {'host': CONF.remote_debug.host,
                 'port': CONF.remote_debug.port})
            pydevd.settrace(host=CONF.remote_debug.host,
                            port=CONF.remote_debug.port,
                            stdoutToServer=False,
                            stderrToServer=False)
            LOG.warn(_('WARNING: Using the remote debug option changes how '
                'Nova uses the eventlet library to support async IO. This '
                'could result in failures that do not occur under normal '
                'operation. Use at your own risk.'))

        service_obj = cls(host, binary, topic, manager,
                          report_interval=report_interval,
                          periodic_enable=periodic_enable,
                          periodic_fuzzy_delay=periodic_fuzzy_delay,
                          periodic_interval_max=periodic_interval_max,
                          db_allowed=db_allowed)

        return service_obj
Esempio n. 19
0
def debug_here():
    # append pydev remote debugger
    if REMOTE_DBG:
        # Make pydev debugger works for auto reload.
        # Note pydevd module need to be copied in XBMC\system\python\Lib\pysrc
        try:
            from pydev import pydevd

            pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)
        except ImportError:
            sys.stderr.write("Error: " +
                             "You must add org.python.pydev.debug.pysrc to your PYTHONPATH.")
            sys.exit(1)
Esempio n. 20
0
def breakpoint():
    try:

        pydevd.settrace(
            "localhost",
            port=10000,
            stdoutToServer=True,
            stderrToServer=True,
            suspend=True,
            trace_only_current_thread=True,
            overwrite_prev_trace=True,
        )
    except Exception:
        pass
Esempio n. 21
0
def ConnectDebugger( host_ovr=None, port_ovr=None ):
	'''
	Connect a listening Eclipse debugger
	'''
	from pydev import pydevd

	if pydevd.connected:
		GEUtil.Warning( "In order to run another debug session you MUST restart the game.\n" )
		return

	if port_ovr:
		pydevd.settrace( host=host_ovr, port=port_ovr, suspend=False )
	else:
		pydevd.settrace( host=host_ovr, suspend=False )

	GEUtil.Msg( "Python debugger successfully connected!\n" )
Esempio n. 22
0
def ConnectDebugger(host_ovr=None, port_ovr=None):
    """
	Connect a listening Eclipse debugger
	"""
    from pydev import pydevd

    if pydevd.connected:
        GEUtil.Warning("In order to run another debug session you MUST restart the game.\n")
        return

    if port_ovr:
        pydevd.settrace(host=host_ovr, port=port_ovr, suspend=False)
    else:
        pydevd.settrace(host=host_ovr, suspend=False)

    GEUtil.Msg("Python debugger successfully connected!\n")
Esempio n. 23
0
def setup_remote_pydev_debug():
    if CONF.pydev_debug_host and CONF.pydev_debug_port:
        error_msg = ('Error setting up the debug environment.  Verify that the'
                     ' option --debug-url has the format <host>:<port> and '
                     'that a debugger processes is listening on that port.')

        try:
            from pydev import pydevd

            pydevd.settrace(CONF.pydev_debug_host,
                            port=CONF.pydev_debug_port,
                            stdoutToServer=True,
                            stderrToServer=True)
            return True
        except:
            LOG.exception(_(error_msg))
            raise
Esempio n. 24
0
def setup_remote_pydev_debug(host, port):

    error_msg = ('Error setting up the debug environment.  Verify that the'
                 ' option pydev_worker_debug_port 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:
        from pydev import pydevd

        pydevd.settrace(host,
                        port=port,
                        stdoutToServer=True,
                        stderrToServer=True)
        return True
    except:
        LOG.exception(error_msg)
        raise
Esempio n. 25
0
def setup_remote_pydev_debug(host, port):

        error_msg = ('Error setting up the debug environment.  Verify that the'
                     ' option pydev_worker_debug_port 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:
            from pydev import pydevd

            pydevd.settrace(host,
                            port=port,
                            stdoutToServer=True,
                            stderrToServer=True)
            return True
        except:
            LOG.exception(error_msg)
            raise
Esempio n. 26
0
def setup_remote_pydev_debug():
    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=CONF.pydev_debug_port, stdoutToServer=True, stderrToServer=True)
            return True
        except Exception:
            LOG.exception(
                _(
                    "Error setting up the debug environment. Verify that the "
                    "option --debug-url has the format <host>:<port> and that a "
                    "debugger processes is listening on that port."
                )
            )
            raise
Esempio n. 27
0
def setup_remote_pydev_debug(host, port):
    error_msg = _LE(
        "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)
Esempio n. 28
0
def setup_remote_pydev_debug():
    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=CONF.pydev_debug_port,
                            stdoutToServer=True,
                            stderrToServer=True)
            return True
        except Exception:
            LOG.exception(_LE(
                'Error setting up the debug environment. Verify that the '
                'option --debug-url has the format <host>:<port> and that a '
                'debugger processes is listening on that port.'))
            raise
Esempio n. 29
0
def pytest_configure(config):
    socket = config.getvalue('pydevd')
    if socket is not None:
        addr, port = socket.split(':')

        # prepend path to sys.path
        path = config.getvalue('pydev_lib')
        if path:
            sys.path.insert(0, os.path.expandvars(os.path.expanduser(path)))

        redirect = config.getvalue('pydevd_io')
        stdout = redirect in ('both', 'stdout')
        stderr = redirect in ('both', 'stderr')

        try:
            from pydev import pydevd
        except ImportError:
            # Newer pycharm-debug.egg
            import pydevd

        # salvaged from pydev's source:
        # - host: the user may specify another host, if the debug server is not
        #   in the same machine
        # - stdoutToServer: when this is true, the stdout is passed to the debug
        #   server
        # - stderrToServer: when this is true, the stderr is passed to the debug
        #   server so that they are printed in its console and not in this
        #   process console.
        # - port: specifies which port to use for communicating with the server
        #   (note that the server must be started in the same port). @note:
        #   currently it's hard-coded at 5678 in the client
        # - suspend: whether a breakpoint should be emulated as soon as this
        #   function is called.
        # - trace_only_current_thread: determines if only the current thread
        #   will be traced or all future threads will also have the tracing
        #   enabled.
        pydevd.settrace(host=addr,
                        port=int(port),
                        suspend=False,
                        stdoutToServer=stdout,
                        stderrToServer=stderr,
                        trace_only_current_thread=False,
                        overwrite_prev_trace=False)
Esempio n. 30
0
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
Esempio n. 31
0
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
Esempio n. 32
0
def init():
    from oslo.config import cfg
    CONF = cfg.CONF

    if 'remote_debug' not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    from xdrs.openstack.common.gettextutils import _
    from xdrs.openstack.common import log as logging
    LOG = logging.getLogger(__name__)

    LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'),
              {'host': CONF.remote_debug.host,
               'port': CONF.remote_debug.port})

    from pydev import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=False,
                    stderrToServer=False)
Esempio n. 33
0
def generateCompoundImageTask(structure, debug=False):

    if debug:
        from pydev import pydevd
        pydevd.settrace('localhost',
                        port=6901,
                        stdoutToServer=True,
                        stderrToServer=True)

    molecule = structure.molecule
    if not molecule.compoundImage:
        img = CompoundImages(molecule=molecule)
    else:
        img = molecule.compoundImage

    mol = Chem.MolFromMolBlock(str(structure.molfile))
    raw = Draw.MolToImage(mol, size=(500, 500))
    raw_thumb = Draw.MolToImage(mol, size=(128, 128))

    output = StringIO.StringIO()
    raw.save(output, 'PNG')
    img.png_500 = output.getvalue()
    output.close()

    output = StringIO.StringIO()
    raw_thumb.save(output, 'PNG')
    img.png = output.getvalue()
    output.close()

    try:
        img.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 34
0
def generateCompoundPropertiesTask(structure, debug=False):
    if debug:
        pydevd.settrace('localhost',
                        port=6901,
                        stdoutToServer=True,
                        stderrToServer=True)

    molecule = structure.molecule
    if not molecule.compoundProperty:
        prop = CompoundProperties(molecule=molecule)
    else:
        prop = molecule.compoundProperty

    saltRemover = SaltRemover()
    mol = Chem.MolFromMolBlock(str(structure.molfile))
    base = saltRemover.StripMol(mol)
    prop.hbd = Descriptors.CalcNumHBD(mol)
    prop.hba = Descriptors.CalcNumHBA(mol)
    prop.rtb = Descriptors.CalcNumRotatableBonds(mol)
    prop.alogp = Crippen.MolLogP(mol)
    prop.psa = Descriptors.CalcTPSA(mol)
    prop.full_mwt = NewDescriptors.MolWt(mol)
    # prop.exact_mass = Descriptors.CalcExactMolWt(mol)

    if base.GetNumAtoms():
        prop.mw_freebase = NewDescriptors.MolWt(base)

    prop.full_molformula = Descriptors.CalcMolFormula(mol)

    try:
        prop.save()

    except IntegrityError as e:
        if debug:
            print e.message
        else:
            raise e
Esempio n. 35
0
def init():
    from oslo.config import cfg

    CONF = cfg.CONF

    # NOTE(markmc): gracefully handle the CLI options not being registered
    if "remote_debug" not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    from rack.openstack.common.gettextutils import _
    from rack.openstack.common import log as logging

    LOG = logging.getLogger(__name__)

    LOG.debug(
        _("Listening on %(host)s:%(port)s for debug connection"),
        {"host": CONF.remote_debug.host, "port": CONF.remote_debug.port},
    )

    from pydev import pydevd

    pydevd.settrace(
        host=CONF.remote_debug.host, port=CONF.remote_debug.port, stdoutToServer=False, stderrToServer=False
    )

    LOG.warn(
        _(
            "WARNING: Using the remote debug option changes how "
            "Rack uses the eventlet library to support async IO. This "
            "could result in failures that do not occur under normal "
            "operation. Use at your own risk."
        )
    )
Esempio n. 36
0
def init():
    from oslo.config import cfg
    CONF = cfg.CONF

    if 'remote_debug' not in CONF:
        return

    if not (CONF.remote_debug.host and CONF.remote_debug.port):
        return

    from xdrs.openstack.common.gettextutils import _
    from xdrs.openstack.common import log as logging
    LOG = logging.getLogger(__name__)

    LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'), {
        'host': CONF.remote_debug.host,
        'port': CONF.remote_debug.port
    })

    from pydev import pydevd
    pydevd.settrace(host=CONF.remote_debug.host,
                    port=CONF.remote_debug.port,
                    stdoutToServer=False,
                    stderrToServer=False)
Esempio n. 37
0
    def create(cls,
               host=None,
               binary=None,
               topic=None,
               manager=None,
               report_interval=None,
               periodic_enable=None,
               periodic_fuzzy_delay=None,
               periodic_interval_max=None,
               db_allowed=True):
        """Instantiates class and passes back application object.

        :param host: defaults to CONF.host
        :param binary: defaults to basename of executable
        :param topic: defaults to bin_name - 'nova-' part
        :param manager: defaults to CONF.<topic>_manager
        :param report_interval: defaults to CONF.report_interval
        :param periodic_enable: defaults to CONF.periodic_enable
        :param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
        :param periodic_interval_max: if set, the max time to wait between runs

        """
        if not host:
            host = CONF.host
        if not binary:
            binary = os.path.basename(sys.argv[0])
        if not topic:
            topic = binary.rpartition('nova-')[2]
        if not manager:
            manager_cls = ('%s_manager' % binary.rpartition('nova-')[2])
            manager = CONF.get(manager_cls, None)
        if report_interval is None:
            report_interval = CONF.report_interval
        if periodic_enable is None:
            periodic_enable = CONF.periodic_enable
        if periodic_fuzzy_delay is None:
            periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
        if CONF.remote_debug.host and CONF.remote_debug.port:
            from pydev import pydevd
            LOG = logging.getLogger('nova')
            LOG.debug(_('Listening on %(host)s:%(port)s for debug connection'),
                      {
                          'host': CONF.remote_debug.host,
                          'port': CONF.remote_debug.port
                      })
            pydevd.settrace(host=CONF.remote_debug.host,
                            port=CONF.remote_debug.port,
                            stdoutToServer=False,
                            stderrToServer=False)
            LOG.warn(
                _('WARNING: Using the remote debug option changes how '
                  'Nova uses the eventlet library to support async IO. This '
                  'could result in failures that do not occur under normal '
                  'operation. Use at your own risk.'))

        service_obj = cls(host,
                          binary,
                          topic,
                          manager,
                          report_interval=report_interval,
                          periodic_enable=periodic_enable,
                          periodic_fuzzy_delay=periodic_fuzzy_delay,
                          periodic_interval_max=periodic_interval_max,
                          db_allowed=db_allowed)

        return service_obj
Esempio n. 38
0
def parse_commands(argv):
    global g_verbose

    u = """[options] <db file>"""

    version = "nimstat " + (nimstat.Version)
    parser = OptionParser(usage=u, version=version)

    opt = bootOpts("delim", "d", "Delimiter between csv fields", ',')
    opt.add_opt(parser)
    opt = bootOpts("verbose", "v", "Print more output", 1, count=True)
    opt.add_opt(parser)
    opt = bootOpts("quiet", "q", "Print no output", False, flag=True)
    opt.add_opt(parser)
    opt = bootOpts("load", "i", "load an accounting file into the database",
                   None)
    opt.add_opt(parser)
    opt = bootOpts("loglevel",
                   "l",
                   "Controls the level of detail in the log file",
                   "info",
                   vals=["debug", "info", "warn", "error"])
    opt.add_opt(parser)
    opt = bootOpts("logfile", "F", "specify a log file", None)
    opt.add_opt(parser)

    opt = bootOpts(
        "starttime", "s",
        "Specify the earliest time at which you want data YYYY:MM:DD:HH", None)
    opt.add_opt(parser)
    opt = bootOpts(
        "endtime", "e",
        "Specify the latest time at which you want data YYYY:MM:DD:HH", None)
    opt.add_opt(parser)

    opt = bootOpts("percenttotal", "P",
                   "A total possible number to graph a grouping against.",
                   None)
    opt.add_opt(parser)

    opt = bootOpts("defaultcpucount", "j", "Default CPU Count.", 1)
    opt.add_opt(parser)

    opt = bootOpts("makestack",
                   "J",
                   "use stacked bargrpah for usage",
                   False,
                   flag=True)
    opt.add_opt(parser)

    opt = bootOpts("remotedebug", "x", SUPPRESS_HELP, False, flag=True)
    opt.add_opt(parser)

    opt = bootOpts(
        "max", "m",
        "The maximum number of results to show in a graph (the least significant data will be grouped as 'other').  Only applies to user based requests",
        None)
    opt.add_opt(parser)

    opt = bootOpts(
        "outputdir", "o",
        "The output directory where the graphs and data files will be created",
        os.path.expanduser("~/.nimstat/%s" %
                           (str(uuid.uuid4()).split('-')[0])))
    opt.add_opt(parser)

    # graph options
    opt = bootOpts("xaxis", "X", "The x axis label", None)
    opt.add_opt(parser)
    opt = bootOpts("yaxis", "Y", "The y axis label", None)
    opt.add_opt(parser)
    opt = bootOpts("title", "T", "The Title of the Graph", None)
    opt.add_opt(parser)
    opt = bootOpts("subtitle", "S", "The Subtitle of the Graph", None)
    opt.add_opt(parser)
    opt = bootOpts("xtics", "W", "Show X tic labels", False, flag=True)
    opt.add_opt(parser)
    opt = bootOpts("legend", "L", "Make a legend", False, flag=True)
    opt.add_opt(parser)
    opt = bootOpts("labellen", "Q", "Label length", None)
    opt.add_opt(parser)

    opt = bootOpts("column",
                   "c",
                   "Select the column",
                   None,
                   vals=[
                       "user.dn",
                       "create_events.request_minutes",
                       "create_events.charge",
                       "create_events.cpu_count",
                       "create_events.memory",
                       "remove_events.charge",
                   ])
    opt.add_opt(parser)

    opt = bootOpts("function",
                   "f",
                   "The function to perform on the selected data set",
                   None,
                   vals=["count", "sum"])
    opt.add_opt(parser)

    opt = bootOpts("aggregator",
                   "a",
                   "The field to group by",
                   None,
                   vals=["weekly", "monthly", "user"])
    opt.add_opt(parser)

    opt = bootOpts("graph",
                   "G",
                   "The type of graph to make",
                   None,
                   vals=["pie", "bar", "line", "percent"])
    opt.add_opt(parser)

    opt = bootOpts(
        "loaduptime", "u",
        "load the uptime of the system from the FG inca data.  provide the testname",
        None)  #"nimbus-clientStatus")
    opt.add_opt(parser)
    opt = bootOpts("uptimehost", "K", "hostname for uptime", "hotel")
    opt.add_opt(parser)

    (options, args) = parser.parse_args(args=argv)

    if options.remotedebug:
        try:
            from pydev import pydevd
            debug_cs = os.environ['NIMSTAT_DEBUG_CS'].split(':')
            debug_host = debug_cs[0]
            debug_port = int(debug_cs[1])
            pydevd.settrace(debug_host,
                            port=debug_port,
                            stdoutToServer=True,
                            stderrToServer=True)
        except ImportError, e:
            print "Could not import remote debugging library: %s\n" % str(e)
        except KeyError:
            print "If you want to do remote debugging please set the env NIMSTAT_DEBUG_CS to the contact string of you expected debugger.\n"
Esempio n. 39
0
import sys

if __name__ == '__main__':
    if len(sys.argv) < 2:
        sys.stderr.write("Not enough arguments")
        sys.exit(1)

    port = int(sys.argv[1])

    x = 0

    from pydev import pydevd
    pydevd.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True)

    x = 1
    x = 2
    x = 3

    print("OK")
Esempio n. 40
0
"""


from __future__ import absolute_import
import atexit
import gettext
import logging
import os
import time
import unittest
import sys


if os.environ.get("PYDEV_DEBUG", "False") == 'True':
    from pydev import pydevd
    pydevd.settrace('10.0.2.2', port=7864, stdoutToServer=True,
                    stderrToServer=True)


def add_support_for_localization():
    """Adds support for localization in the logging.

    If ../nova/__init__.py exists, add ../ to Python search path, so that
    it will override what happens to be installed in
    /usr/(local/)lib/python...

    """
    path = os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)
    possible_topdir = os.path.normpath(path)
    if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
        sys.path.insert(0, possible_topdir)
Esempio n. 41
0
import sys
import time

from ZO import ui, display
# TODO : This stuff will only work on a PC
from ZO.ui import Button
from ZO.zero_one import ZeroOneException
from kbhit import KBHit

# TODO : Also put this is a PC wrapper
if 'debug' in sys.argv:
    sys.path.append('./pydev')
    from pydev import pydevd

    pydevd.settrace('localhost',
                    port=51234,
                    stdoutToServer=True,
                    stderrToServer=True)

import time, threading


def foo():
    print(time.ctime())
    threading.Timer(0.2, foo).start()


def main():
    def setup_logging():
        print("setup_logging")

        logging.basicConfig(
Esempio n. 42
0
import sys

# Changing "ENABLED" to True requires the presence of the library ("pycharm-debug.egg")
# as well as a socket opened (which happens when you activiate the 'Python remote' debug
# configuration in PyCharm on the specified host with the same port configured).

ENABLED = False

HOST = "localhost"
PORT = 51234

def connect_debugger_if_enabled():
    if not ENABLED:
        return
    
    try:
        from pydev import pydevd
    except ImportError, e:
        print >>sys.stderr, "Could not import remote debugging library: %s" % str(e)
        return

    pydevd.settrace(HOST, port=PORT, stdoutToServer=True, stderrToServer=True)
Esempio n. 43
0
import os
import sys

#
# Import this file to enable PyCharm debugging.
#

PYCHARM_DEBUG_EGG = '/opt/pycharm-1.2/pycharm-debug.egg'

if os.path.exists(PYCHARM_DEBUG_EGG):
    print "Enabling PyCharm debugging..."
    try:
        sys.path.append(PYCHARM_DEBUG_EGG)
        from pydev import pydevd
        pydevd.settrace('localhost', port=50000, suspend=False)
        print "Connected to PyCharm"
    except SystemExit:
        print "Unable to connect to PyCharm"
Esempio n. 44
0
def start_debugging():
    pydevd.settrace('localhost', port=8585, stdoutToServer=True, stderrToServer=True, suspend=False)
    entry()
Esempio n. 45
0
 def enable_pycharm_debug(cmd):
     from pydev import pydevd
     pydevd.settrace('localhost', port=1292)
Esempio n. 46
0
    def run(self):
        """Thread start implementation."""
        settrace('localhost', port=6789, stdoutToServer=True,
            stderrToServer=True)
        self.mutex.lock()
        self.stopMe = 0
        self.mutex.unlock()
        mode = self.mode()
        self.zip = None
        # prepare output
        if mode == "TILE_DIR":
            self.tmp = None
            if self.mapurl:
                self.writeMapurlFile()

            if self.viewer:
                self.writeLeafletViewer()
        elif mode == "ZIP":
            self.zip = zipfile.ZipFile(
                unicode(self.output.absoluteFilePath()), "w")
            self.tmp = QTemporaryFile()
            self.tmp.setAutoRemove(False)
            self.tmp.open(QIODevice.WriteOnly)
            self.tempFileName = self.tmp.fileName()
        else:  # mode == "MBTILES":
            self.setup_mbtiles()

        self.rangeChanged.emit(self.tr("Searching tiles..."), 0)

        useTMS = 1
        if self.tmsConvention:
            useTMS = -1

        self.countTiles(Tile(0, 0, 0, useTMS))

        if self.interrupted:
            #del self.tiles[:]
            #self.tiles = None

            if self.zip is not None and mode == "ZIP":
                self.zip.close()
                self.zip = None

                self.tmp.close()
                self.tmp.remove()
                self.tmp = None
            if self.con is not None and mode == "MBTILES":
                optimize_database(self.con)

            self.processInterrupted.emit()

        self.rangeChanged.emit(self.tr("Rendering: %v from %m (%p%)"), len(self.tiles))

        self.painter = QPainter()
        if self.antialias:
            self.painter.setRenderHint(QPainter.Antialiasing)

        for t in self.tiles:
            self.render(t)

            self.updateProgress.emit()

            self.mutex.lock()
            s = self.stopMe
            self.mutex.unlock()
            if s == 1:
                self.interrupted = True
                break

        if self.zip is not None and mode == "ZIP":
            self.zip.close()
            self.zip = None

        if self.con is not None and mode == "MBTILES":
            optimize_database(self.con)

        if not self.interrupted:
            self.processFinished.emit()
        else:
            self.processInterrupted.emit()
Esempio n. 47
0
#!/usr/bin/python

import psycopg2
from pydev import pydevd

pydevd.settrace('localhost', port=$SERVER_PORT, stdoutToServer=True, stderrToServer=True)

conn = psycopg2.connect(database="tournament")

print "Opened database successfully"

cur = conn.cursor()
cur.execute('''CREATE TABLE COMPANY
       (ID INT PRIMARY KEY     NOT NULL,
       NAME           TEXT    NOT NULL,
       AGE            INT     NOT NULL,
       ADDRESS        CHAR(50),
       SALARY         REAL);''')
print "Table created successfully"

conn.commit()
conn.close()
Esempio n. 48
0
 def console(self, options):
     if options.debug_pydev:
         from pydev import pydevd
         pydevd.settrace()
     return self.launch(options=options, console=True)
Esempio n. 49
0
        设置监控模板属性
        :param uid::"/zport/dmd/Devices/Server/SSH/Linux/devices/172.168.10.14/MySQLSSH/datasources/mysqlssh"
        :param data:{"cycletime":30,"eventKey":"123421"}
        :return:
        '''
        obj = self._getObject(uid)
        info = self._getDataSourceInfoFromObject(obj)
        newId = None
        if 'newId' in data:
            newId = data['newId']
            del data['newId']
            info.rename(newId)

        for key in data.keys():
            if hasattr(info, key):
                setattr(info, key, data[key])
        return info


if __name__ == '__main__':
    Monitor = SetMonitor()
    from pydev import pydevd
    pydevd.settrace('192.168.1.153',
                    port=7000,
                    stdoutToServer=True,
                    stderrToServer=True)
    ip = '172.168.10.10'
    zProperty = 'zCommandPort'
    value = '22'
    Monitor.setZenProperty(ip, zProperty, value)
Esempio n. 50
0
 def enable_pycharm_debug(cmd):
     from pydev import pydevd
     pydevd.settrace('localhost', port=1292)
Esempio n. 51
0
import os
import time
import unittest
import six
import sys
import proboscis

from nose import config
from nose import core

from tests.colorizer import NovaTestRunner

if os.environ.get("PYDEV_DEBUG", "False") == 'True':
    from pydev import pydevd
    pydevd.settrace('10.0.2.2',
                    port=7864,
                    stdoutToServer=True,
                    stderrToServer=True)


def add_support_for_localization():
    """Adds support for localization in the logging.

    If ../nova/__init__.py exists, add ../ to Python search path, so that
    it will override what happens to be installed in
    /usr/(local/)lib/python...

    """
    path = os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)
    possible_topdir = os.path.normpath(path)
    if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
        sys.path.insert(0, possible_topdir)
Esempio n. 52
0
        options.verbose = 0
    g_verbose = options.verbose

    if options.outstream:
        global g_outfile
        g_outfile = open(options.outstream, "w")
    else:
        g_outfile = None

    if options.remotedebug:
        try:
            from pydev import pydevd
            debug_cs = os.environ['CLOUDINITD_DEBUG_CS'].split(':')
            debug_host = debug_cs[0]
            debug_port = int(debug_cs[1])
            pydevd.settrace(debug_host, port=debug_port, stdoutToServer=True, stderrToServer=True)
        except ImportError, e:
            print_chars(0, "Could not import remote debugging library: %s\n" % str(e), color="red", bold=True)
        except KeyError:
            print_chars(0, "If you want to do remote debugging please set the env CLOUDINITD_DEBUG_CS to the contact string of you expected debugger.\n", color="red", bold=True)
        except:
            print_chars(0, "Please verify the format of your contact string to be <hostname>:<port>.\n", color="red", bold=True)

    global g_options
    g_options = options
    return (args, options)

def friendly_timedelta(td):
    if td is None:
        s = None
    else:
Esempio n. 53
0
    def console(self, options: Namespace) -> int:
        if options.debug_pydev:
            from pydev import pydevd

            pydevd.settrace()
        return self.launch(options=options, console=True)