Context manager entry; open wallet.
        For use when keeping agent open across multiple calls.

        :return: current object
161826
async def open(self) -> '_BaseAgent':
        

        LOGGER.debug('_BaseAgent.open >>>')

        # Do not open pool independently: let relying party decide when to go on-line and off-line
        await self.wallet.open()

        LOGGER.debug('_BaseAgent.open <<<')
        return self
733129
async def close_wallet(handle: int) -> None:
    

    logger = logging.getLogger(__name__)
    logger.debug("close_wallet: >>> handle: %i", handle)

    if not hasattr(close_wallet, "cb"):
        logger.debug("close_wallet: Creating callback")
        close_wallet.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_handle = c_int32(handle)

    await do_call('indy_close_wallet',
                  c_handle,
                  close_wallet.cb)

    logger.debug("close_wallet: <<<")
491528
def delete_wallet(self, wallet_name):
        
        return make_request(
            '{}wallet/{}'.format(self.url, wallet_name),
            method='DELETE',
            timeout=self.timeout,
            client=self._client)
986025
async def close(self) -> None:
        

        LOGGER.debug('Wallet.close >>>')

        if not self.handle:
            LOGGER.warning('Abstaining from closing wallet %s: already closed', self.name)
        else:
            LOGGER.debug('Closing wallet %s', self.name)
            await wallet.close_wallet(self.handle)
            self._handle = None
            if self.auto_remove:
                LOGGER.info('Automatically removing wallet %s', self.name)
                await self.remove()
        self._handle = None

        LOGGER.debug('Wallet.close <<<')
600782
def managed_context_entry(process_name,
                          classname,
                          token,
                          time_qualifier,
                          trigger_frequency='every 60',
                          state_machine_name=STATE_MACHINE_DISCRETE,
                          is_on=True,
                          exchange=EXCHANGE_MANAGED_WORKER,
                          blocking_type=BLOCKING_NORMAL,
                          present_on_boxes=None,
                          time_grouping=1,
                          arguments=None,
                          queue=None,
                          routing=None,
                          source=None,
                          sink=None,
                          pid_file=None,
                          log_file=None):
    
    _ROUTING_PREFIX = 'routing_'
    _QUEUE_PREFIX = 'queue_'

    if arguments is not None:
        assert isinstance(arguments, dict)

    process_entry = ManagedProcessEntry(
        process_name=process_name,
        trigger_frequency=trigger_frequency,
        state_machine_name=state_machine_name,
        is_on=is_on,
        blocking_type=blocking_type,
        classname=classname,
        token=token,
        source=source,
        sink=sink,
        mq_queue=queue if queue is not None else _QUEUE_PREFIX + token + time_qualifier,
        mq_routing_key=routing if routing is not None else _ROUTING_PREFIX + token + time_qualifier,
        mq_exchange=exchange,
        present_on_boxes=present_on_boxes,
        arguments=arguments if arguments is not None else dict(),
        time_qualifier=time_qualifier,
        time_grouping=time_grouping,
        log_filename=log_file if log_file is not None else token + time_qualifier + '.log',
        pid_filename=pid_file if pid_file is not None else token + time_qualifier + '.pid')
    return process_entry
200446
def open(self):
        
        
        self.device = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
        if self.device is None:
            raise NoDeviceError()
        try:
            if self.device.is_kernel_driver_active(self.interface):
                self.device.detach_kernel_driver(self.interface) 
            self.device.set_configuration()
            usb.util.claim_interface(self.device, self.interface)
        except usb.core.USBError as e:
            raise HandleDeviceError(e)
3150
def daemon_context_entry(process_name,
                         classname,
                         token,
                         exchange=EXCHANGE_UTILS,
                         present_on_boxes=None,
                         arguments=None,
                         queue=None,
                         routing=None,
                         pid_file=None,
                         log_file=None):
    
    _ROUTING_PREFIX = 'routing_'
    _QUEUE_PREFIX = 'queue_'
    _SUFFIX = '_daemon'

    if arguments is not None:
        assert isinstance(arguments, dict)

    process_entry = DaemonProcessEntry(
        process_name=process_name,
        classname=classname,
        token=token,
        mq_queue=queue if queue is not None else _QUEUE_PREFIX + token + _SUFFIX,
        mq_routing_key=routing if routing is not None else _ROUTING_PREFIX + token + _SUFFIX,
        mq_exchange=exchange,
        present_on_boxes=present_on_boxes,
        arguments=arguments if arguments is not None else dict(),
        log_filename=log_file if log_file is not None else token + _SUFFIX + '.log',
        pid_filename=pid_file if pid_file is not None else token + _SUFFIX + '.pid')
    return process_entry
701800
async def get_anchor_did(self) -> str:
        

        LOGGER.debug('Wallet.get_anchor_did >>>')

        if not self.handle:
            LOGGER.debug('Wallet.get_anchor_did <!< Wallet %s is closed', self.name)
            raise WalletState('Wallet {} is closed'.format(self.name))

        rv = None
        dids_with_meta = json.loads(await did.list_my_dids_with_meta(self.handle))  # list

        latest = 0
        for did_with_meta in dids_with_meta:
            try:
                meta = json.loads(did_with_meta['metadata']) if did_with_meta['metadata'] else {}
                if not meta.get('anchor', False):
                    continue
                if isinstance(meta, dict) and meta.get('since', -1) > latest:
                    rv = did_with_meta.get('did')
            except json.decoder.JSONDecodeError:
                continue  # it's not an anchor DID, carry on

        LOGGER.debug('Wallet.get_anchor_did <<< %s', rv)
        return rv
1058503
def update_context(self, ctx):
        
        assert isinstance(ctx, dict)
        ctx[str(self.context_id)] = self.value
518209
def open(self):
        
        with self._lock:
            if self._thread_will_exit:
                # If the background thread has read self._stopped as True
                # there is a chance that it has not yet exited. The call to
                # join should not block indefinitely because there is no
                # other work done outside the while loop in self._run.
                try:
                    self._thread.join()
                except ReferenceError:
                    # Thread terminated.
                    pass
            self._thread_will_exit = False
            self._stopped = False
        started = False
        try:
            started = self._thread and self._thread.is_alive()
        except ReferenceError:
            # Thread terminated.
            pass

        if not started:
            thread = threading.Thread(target=self._run, name=self._name)
            thread.daemon = True
            self._thread = weakref.proxy(thread)
            _register_executor(self)
            thread.start()
232399
def freerun_context_entry(process_name,
                          entry_name,
                          classname,
                          token,
                          trigger_frequency,
                          is_on=True,
                          present_on_boxes=None,
                          description=None,
                          arguments=None,
                          exchange=EXCHANGE_FREERUN_WORKER,
                          queue=None,
                          routing=None,
                          pid_file=None,
                          log_file=None):
    
    _ROUTING_PREFIX = 'routing_'
    _QUEUE_PREFIX = 'queue_'
    _SUFFIX = '_freerun'

    if arguments is not None:
        assert isinstance(arguments, dict)

    process_entry = FreerunProcessEntry(
        process_name=process_name,
        entry_name=entry_name,
        trigger_frequency=trigger_frequency,
        state_machine_name=STATE_MACHINE_FREERUN,
        is_on=is_on,
        classname=classname,
        token=token,
        present_on_boxes=present_on_boxes,
        description=description,
        mq_queue=queue if queue is not None else _QUEUE_PREFIX + token + _SUFFIX,
        mq_routing_key=routing if routing is not None else _ROUTING_PREFIX + token + _SUFFIX,
        mq_exchange=exchange,
        arguments=arguments if arguments is not None else dict(),
        log_filename=log_file if log_file is not None else token + _SUFFIX + '.log',
        pid_filename=pid_file if pid_file is not None else token + _SUFFIX + '.pid')
    return process_entry
1066836
def extend_recently_opened_by_current_open_state_machines(self):
        
        from rafcon.gui.singleton import state_machine_manager_model as state_machine_manager_m
        for sm_m in state_machine_manager_m.state_machines.values():
            self.update_recently_opened_state_machines_with(sm_m.state_machine)
632899
async def open_async(self):
        
        self.set_pump_status("Opening")
        self.partition_context = PartitionContext(self.host, self.lease.partition_id,
                                                  self.host.eh_config.client_address,
                                                  self.host.eh_config.consumer_group,
                                                  self.loop)
        self.partition_context.lease = self.lease
        self.partition_context.event_processor_context = self.lease.event_processor_context
        self.processor = self.host.event_processor(self.host.event_processor_params)
        try:
            await self.processor.open_async(self.partition_context)
        except Exception as err:  # pylint: disable=broad-except
            # If the processor won't create or open, only thing we can do here is pass the buck.
            # Null it out so we don't try to operate on it further.
            await self.process_error_async(err)
            self.processor = None
            self.set_pump_status("OpenFailed")

        # If Open Async Didn't Fail call OnOpenAsync
        if self.pump_status == "Opening":
            await self.on_open_async()
1274186
def open(self, autocommit=False):
    """"""
    self.data_access.open(autocommit=autocommit)
    return self
469561
def _get_state(wallet_name: str) -> _STATE:
        

        dir_sentinel = RevRegBuilder.dir_tails_sentinel(wallet_name)
        file_pid = join(dir_sentinel, '.pid')
        file_start = join(dir_sentinel, '.start')
        file_stop = join(dir_sentinel, '.stop')

        if isfile(file_stop):
            return _STATE.STOPPING

        if isfile(file_start) or isfile(file_pid):
            return _STATE.RUNNING

        return _STATE.ABSENT
8255
def start(**kwargs):
    
    if CORE_MANAGER.started:
        raise RuntimeConfigError('Current context has to be stopped to start '
                                 'a new context.')

    try:
        waiter = kwargs.pop('waiter')
    except KeyError:
        waiter = hub.Event()
    common_config = CommonConf(**kwargs)
    hub.spawn(CORE_MANAGER.start, *[], **{'common_conf': common_config,
                                          'waiter': waiter})
    return True
1244679
def importaccount(ctx, account, role):
    
    from peerplaysbase.account import PasswordKey

    password = click.prompt("Account Passphrase", hide_input=True)
    account = Account(account, peerplays_instance=ctx.peerplays)
    imported = False

    if role == "owner":
        owner_key = PasswordKey(account["name"], password, role="owner")
        owner_pubkey = format(
            owner_key.get_public_key(), ctx.peerplays.rpc.chain_params["prefix"]
        )
        if owner_pubkey in [x[0] for x in account["owner"]["key_auths"]]:
            click.echo("Importing owner key!")
            owner_privkey = owner_key.get_private_key()
            ctx.peerplays.wallet.addPrivateKey(owner_privkey)
            imported = True

    if role == "active":
        active_key = PasswordKey(account["name"], password, role="active")
        active_pubkey = format(
            active_key.get_public_key(), ctx.peerplays.rpc.chain_params["prefix"]
        )
        if active_pubkey in [x[0] for x in account["active"]["key_auths"]]:
            click.echo("Importing active key!")
            active_privkey = active_key.get_private_key()
            ctx.peerplays.wallet.addPrivateKey(active_privkey)
            imported = True

    if role == "memo":
        memo_key = PasswordKey(account["name"], password, role=role)
        memo_pubkey = format(
            memo_key.get_public_key(), ctx.peerplays.rpc.chain_params["prefix"]
        )
        if memo_pubkey == account["memo_key"]:
            click.echo("Importing memo key!")
            memo_privkey = memo_key.get_private_key()
            ctx.peerplays.wallet.addPrivateKey(memo_privkey)
            imported = True

    if not imported:
        click.echo("No matching key(s) found. Password correct?")