def __init__(self, target=None, hostname=None, probe_names=None): if iio_import_failed: raise HostError( 'Could not import "iio": {}'.format(iio_import_error)) super(BaylibreAcmeNetworkInstrument, self).__init__(target=target, iio_context=iio.NetworkContext(hostname), probe_names=probe_names) try: self.ssh_connection = SshConnection(hostname, username='******', password=None) except TargetError as e: msg = 'No SSH connexion could be established to {}: {}' self.logger.debug(msg.format(hostname, e)) self.ssh_connection = None
def create_context(scan_for_context, arg_uri, arg_ip): """ Method for creating the corresponding context. parameters: scan_for_context: type=bool Scan for available contexts and if only one is available use it. arg_uri: type=string The URI on which the program should look for a Context. arg_ip: type=string The IP on which the program should look for a Network Context. returns: type:iio.Context The resulted context. """ ctx = None try: if scan_for_context: contexts = iio.scan_contexts() if len(contexts) == 0: sys.stderr.write('No IIO context found.') exit(1) elif len(contexts) == 1: uri, _ = contexts.popitem() ctx = iio.Context(_context=uri) else: print('Multiple contexts found. Please select one using --uri!') for uri, _ in contexts: print(uri) elif arg_uri != '': ctx = iio.Context(_context=arg_uri) elif arg_ip != '': ctx = iio.NetworkContext(arg_ip) else: ctx = iio.Context() except FileNotFoundError: sys.stderr.write('Unable to create IIO context') exit(1) return ctx
def _network(self): self.ctx = iio.NetworkContext(self.arguments.network) return self