allow to switch to Pdb instance
16481
def trace_dispatch(self, frame, event, arg):
        """"""
        if hasattr(self, 'pdb'):
            return self.pdb.trace_dispatch(frame, event, arg)
        else:
            return Pdb.trace_dispatch(self, frame, event, arg)
680234
def load_pdb(self, pdbpath, as_string=False):
        """"""
        if as_string:
            self.sourcefiles['pdbcomplex.original'] = None
            self.sourcefiles['pdbcomplex'] = None
            self.sourcefiles['pdbstring'] = pdbpath
        else:
            self.sourcefiles['pdbcomplex.original'] = pdbpath
            self.sourcefiles['pdbcomplex'] = pdbpath
        self.information['pdbfixes'] = False
        pdbparser = PDBParser(pdbpath, as_string=as_string)  # Parse PDB file to find errors and get additonal data
        # #@todo Refactor and rename here
        self.Mapper.proteinmap = pdbparser.proteinmap
        self.Mapper.reversed_proteinmap = {v: k for k, v in self.Mapper.proteinmap.items()}
        self.modres = pdbparser.modres
        self.covalent = pdbparser.covalent
        self.altconf = pdbparser.altconformations
        self.corrected_pdb = pdbparser.corrected_pdb

        if not config.PLUGIN_MODE:
            if pdbparser.num_fixed_lines > 0:
                write_message('%i lines automatically fixed in PDB input file.\n' % pdbparser.num_fixed_lines)
                # Save modified PDB file
                if not as_string:
                    basename = os.path.basename(pdbpath).split('.')[0]
                else:
                    basename = "from_stdin"
                pdbpath_fixed = tmpfile(prefix='plipfixed.' + basename + '_', direc=self.output_path)
                create_folder_if_not_exists(self.output_path)
                self.sourcefiles['pdbcomplex'] = pdbpath_fixed
                self.corrected_pdb = re.sub(r'[^\x00-\x7F]+', ' ', self.corrected_pdb)  # Strip non-unicode chars
                if not config.NOFIXFILE:  # Only write to file if this option is not activated
                    with open(pdbpath_fixed, 'w') as f:
                        f.write(self.corrected_pdb)
                self.information['pdbfixes'] = True

        if not as_string:
            self.sourcefiles['filename'] = os.path.basename(self.sourcefiles['pdbcomplex'])
        self.protcomplex, self.filetype = read_pdb(self.corrected_pdb, as_string=True)

        # Update the model in the Mapper class instance
        self.Mapper.original_structure = self.protcomplex.OBMol
        write_message('PDB structure successfully read.\n')

        # Determine (temporary) PyMOL Name from Filename
        self.pymol_name = pdbpath.split('/')[-1].split('.')[0] + '-Protein'
        # Replace characters causing problems in PyMOL
        self.pymol_name = self.pymol_name.replace(' ', '').replace('(', '').replace(')', '').replace('-', '_')
        # But if possible, name it after PDBID in Header
        if 'HEADER' in self.protcomplex.data:  # If the PDB file has a proper header
            potential_name = self.protcomplex.data['HEADER'][56:60].lower()
            if extract_pdbid(potential_name) != 'UnknownProtein':
                self.pymol_name = potential_name
        write_message("Pymol Name set as: '%s'\n" % self.pymol_name, mtype='debug')

        # Extract and prepare ligands
        ligandfinder = LigandFinder(self.protcomplex, self.altconf, self.modres, self.covalent, self.Mapper)
        self.ligands = ligandfinder.ligands
        self.excluded = ligandfinder.excluded

        # Add polar hydrogens
        self.protcomplex.OBMol.AddPolarHydrogens()
        for atm in self.protcomplex:
            self.atoms[atm.idx] = atm
        write_message("Assigned polar hydrogens\n", mtype='debug')

        if len(self.excluded) != 0:
            write_message("Excluded molecules as ligands: %s\n" % ','.join([lig for lig in self.excluded]))

        if config.DNARECEPTOR:
            self.resis = [obres for obres in pybel.ob.OBResidueIter(
                self.protcomplex.OBMol) if obres.GetName() in config.DNA+config.RNA]
        else:
            self.resis = [obres for obres in pybel.ob.OBResidueIter(
                self.protcomplex.OBMol) if obres.GetResidueProperty(0)]

        num_ligs = len(self.ligands)
        if num_ligs == 1:
            write_message("Analyzing one ligand...\n")
        elif num_ligs > 1:
            write_message("Analyzing %i ligands...\n" % num_ligs)
        else:
            write_message("Structure contains no ligands.\n\n")
1100015
def _read_pdb(path):
        """"""
        r_mode = 'r'
        openf = open
        if path.endswith('.gz'):
            r_mode = 'rb'
            openf = gzip.open
        with openf(path, r_mode) as f:
            txt = f.read()
        if path.endswith('.gz'):
            if sys.version_info[0] >= 3:
                txt = txt.decode('utf-8')
            else:
                txt = txt.encode('ascii')
        return path, txt
953451
def deactivatePdpContextAccept():
    """"""
    a = TpPd(pd=0x8)
    b = MessageType(mesType=0x47)  # 01000111
    packet = a / b
    return packet
813760
def starter_bus(**kwargs) :
    ""
    return \
        Connection(dbus.Connection.bus_get(DBUS.BUS_STARTER, private = False)) \
        .register_additional_standard(**kwargs)
1239130
def enable(ctx):
    """"""

    if ctx.obj['username'] is None:
        log('Specify the username with "iso db user --username ..."')
        return

    change_user = ctx.obj['db'].objectmodels['user'].find_one({
        'name': ctx.obj['username']
    })

    change_user.active = True
    change_user.save()
    log('Done')
1365726
function switchAndClear(pkg) {
    switchState(false, pkg);

    //unload proxy routes
    proxy.deleteBy(app.config.get('public-port'), {user: pkg.user, appid: pkg.name});
  }
1259113
def cli(obj, environment, service, resource, event, group, tags, customer, start, duration, text, delete):
    """"""
    client = obj['client']
    if delete:
        client.delete_blackout(delete)
    else:
        if not environment:
            raise click.UsageError('Missing option "--environment" / "-E".')
        try:
            blackout = client.create_blackout(
                environment=environment,
                service=service,
                resource=resource,
                event=event,
                group=group,
                tags=tags,
                customer=customer,
                start=start,
                duration=duration,
                text=text
            )
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
            sys.exit(1)
        click.echo(blackout.id)
164922
def static_get_pdb_object(pdb_id, bio_cache = None, cache_dir = None):
        ''''''
        pdb_id = pdb_id.upper()

        if bio_cache:
            return bio_cache.get_pdb_object(pdb_id)

        if cache_dir:
            # Check to see whether we have a cached copy of the PDB file
            filepath = os.path.join(cache_dir, '{0}.pdb'.format(pdb_id))
            if os.path.exists(filepath):
                return PDB.from_filepath(filepath)

        # Get any missing files from the RCSB and create cached copies if appropriate
        pdb_contents = retrieve_pdb(pdb_id)
        if cache_dir:
            write_file(os.path.join(cache_dir, "%s.pdb" % pdb_id), pdb_contents)
        return PDB(pdb_contents)
294051
public void open() throws DBException
    {
        if (m_pDatabase == null)
        {
            PhysicalDatabaseParent pDBParent = null;
            Environment env = (Environment)this.getDatabaseOwner().getEnvironment();
            if (env != null)
                pDBParent = (PhysicalDatabaseParent)env.getPDatabaseParent(mapDBParentProperties, true);
            String databaseName = this.getDatabaseName(true);
            if (databaseName.endsWith(BaseDatabase.SHARED_SUFFIX))
                databaseName = databaseName.substring(0, databaseName.length() - BaseDatabase.SHARED_SUFFIX.length());
            else if (databaseName.endsWith(BaseDatabase.USER_SUFFIX))
                databaseName = databaseName.substring(0, databaseName.length() - BaseDatabase.USER_SUFFIX.length());
            char strPDatabaseType = this.getPDatabaseType();
            m_pDatabase = pDBParent.getPDatabase(databaseName, strPDatabaseType, false);
            if (m_pDatabase == null)
                m_pDatabase = this.makePDatabase(pDBParent, databaseName);
            m_pDatabase.addPDatabaseOwner(this);
        }
        m_pDatabase.open();
        
        super.open(); // Do any inherited
    }
705837
def make_pdb(self):
        """"""
        pdb_str = write_pdb(
            [self], ' ' if not self.parent else self.parent.id)
        return pdb_str
1060006
def parse_pdb_file(self):
        """"""
        self.pdb_parse_tree = {'info': {},
                               'data': {
                                   self.state: {}}
                               }
        try:
            for line in self.pdb_lines:
                self.current_line = line
                record_name = line[:6].strip()
                if record_name in self.proc_functions:
                    self.proc_functions[record_name]()
                else:
                    if record_name not in self.pdb_parse_tree['info']:
                        self.pdb_parse_tree['info'][record_name] = []
                    self.pdb_parse_tree['info'][record_name].append(line)
        except EOFError:
            # Raised by END record
            pass
        if self.new_labels:
            ampal_data_session.commit()
        return
859380
def pdebug(*args, **kwargs):
    """"""
    if should_msg(kwargs.get("groups", ["debug"])):
        # initialize colorama only if uninitialized
        global colorama_init
        if not colorama_init:
            colorama_init = True
            colorama.init()

        args = indent_text(*args, **kwargs)

        # write to stdout
        sys.stderr.write(colorama.Fore.CYAN)
        sys.stderr.write("".join(args))
        sys.stderr.write(colorama.Fore.RESET)
        sys.stderr.write("\n")
561996
def publish_pdb_state(self):
        
        if self._pdb_obj and self._do_publish_pdb_state:
            state = dict(namespace_view = self.get_namespace_view(),
                         var_properties = self.get_var_properties(),
                         step = self._pdb_step)
            self.send_spyder_msg('pdb_state', content={'pdb_state': state})
        self._do_publish_pdb_state = True
1290822
def switch(self, payload):
        """"""
        first = payload['first']
        second = payload['second']
        running = self.process_handler.is_running(first) or self.process_handler.is_running(second)
        if running:
            answer = {
                'message': "Can't switch running processes, "
                "please stop the processes before switching them.",
                'status': 'error'
            }

        else:
            switched = self.queue.switch(first, second)
            if switched:
                answer = {
                    'message': 'Entries #{} and #{} switched'.format(first, second),
                    'status': 'success'
                }
            else:
                answer = {'message': "One or both entries do not exist or are not queued/stashed.",
                          'status': 'error'}
        return answer
420007
def pdb_run(func: Callable, *args: Any, **kwargs: Any) -> None:
    
    # noinspection PyBroadException
    try:
        func(*args, **kwargs)
    except:  # nopep8
        type_, value, tb = sys.exc_info()
        traceback.print_exc()
        pdb.post_mortem(tb)
466012
def remote_pdb_handler(signum, frame):
    
    try:
        from remote_pdb import RemotePdb

        rdb = RemotePdb(host="127.0.0.1", port=0)
        rdb.set_trace(frame=frame)
    except ImportError:
        log.warning(
            "remote_pdb unavailable.  Please install remote_pdb to "
            "allow remote debugging."
        )
    # Restore signal handler for later
    signal.signal(signum, remote_pdb_handler)