Load sensors safely from file.
768576
def safe_load_sensors(self):
        """"""
        try:
            loaded = self._load_sensors()
        except (EOFError, ValueError):
            _LOGGER.error('Bad file contents: %s', self.persistence_file)
            loaded = False
        if not loaded:
            _LOGGER.warning('Trying backup file: %s', self.persistence_bak)
            try:
                if not self._load_sensors(self.persistence_bak):
                    _LOGGER.warning('Failed to load sensors from file: %s',
                                    self.persistence_file)
            except (EOFError, ValueError):
                _LOGGER.error('Bad file contents: %s', self.persistence_file)
                _LOGGER.warning('Removing file: %s', self.persistence_file)
                os.remove(self.persistence_file)
1224244
def recursive_load(search_root):
    """"""
    for root, dirs, files in os.walk(search_root):
        dir_name = os.path.basename(root)
        if dir_name == 'fixtures':
            for file_name in files:
                fixture_path = os.path.join(root, file_name)
                execute_manage('loaddata', fixture_path)
945794
def setup_sensors(self):
        """"""
        self._add_result = Sensor.float("add.result",
            "Last ?add result.", "", [-10000, 10000])
        self._add_result.set_value(0, Sensor.UNREACHABLE)

        self._time_result = Sensor.timestamp("time.result",
            "Last ?time result.", "")
        self._time_result.set_value(0, Sensor.INACTIVE)

        self._eval_result = Sensor.string("eval.result",
            "Last ?eval result.", "")
        self._eval_result.set_value('', Sensor.UNKNOWN)

        self._fruit_result = Sensor.discrete("fruit.result",
            "Last ?pick-fruit result.", "", self.FRUIT)
        self._fruit_result.set_value('apple', Sensor.ERROR)

        self.add_sensor(self._add_result)
        self.add_sensor(self._time_result)
        self.add_sensor(self._eval_result)
        self.add_sensor(self._fruit_result)
856525
def get_sensor_data(self):
        
        self.init_sdr()
        for sensor in self._sdr.get_sensor_numbers():
            rsp = self.raw_command(command=0x2d, netfn=4, data=(sensor,))
            if 'error' in rsp:
                if rsp['code'] == 203:  # Sensor does not exist, optional dev
                    continue
                raise exc.IpmiException(rsp['error'], code=rsp['code'])
            yield self._sdr.sensors[sensor].decode_sensor_reading(rsp['data'])
        self.oem_init()
        for reading in self._oem.get_sensor_data():
            yield reading
1238475
def load_fis(dir=None):
    """"""
    if dir is None:
        import tkFileDialog
        try:
            dir=tkFileDialog.askdirectory()
        except:
            return
    if dir is None:
        return None
    from os.path import walk
    walk(dir,fits_list,"*.fits")
272882
def inform(self, reading):
        """"""
        try:
            self._inform_callback(self._sensor, reading)
        except Exception:
            log.exception('Unhandled exception trying to send {!r} '
                          'for sensor {!r} of type {!r}'
                          .format(reading, self._sensor.name, self._sensor.type))
1017250
def load(self):
        """"""
        import h5py

        no_detectors_message = False
        with h5py.File(self.filename, 'r') as h5f:
            self.band_names = [b.decode('utf-8') for b in h5f.attrs['band_names'].tolist()]
            self.description = h5f.attrs['description'].decode('utf-8')
            if not self.platform_name:
                try:
                    self.platform_name = h5f.attrs['platform_name'].decode('utf-8')
                except KeyError:
                    LOG.warning("No platform_name in HDF5 file")
                    try:
                        self.platform_name = h5f.attrs[
                            'platform'] + '-' + h5f.attrs['satnum']
                    except KeyError:
                        LOG.warning(
                            "Unable to determine platform name from HDF5 file content")
                        self.platform_name = None

            if not self.instrument:
                try:
                    self.instrument = h5f.attrs['sensor'].decode('utf-8')
                except KeyError:
                    LOG.warning("No sensor name specified in HDF5 file")
                    self.instrument = INSTRUMENTS.get(self.platform_name)

            for bandname in self.band_names:
                self.rsr[bandname] = {}
                try:
                    num_of_det = h5f[bandname].attrs['number_of_detectors']
                except KeyError:
                    if not no_detectors_message:
                        LOG.debug("No detectors found - assume only one...")
                    num_of_det = 1
                    no_detectors_message = True

                for i in range(1, num_of_det + 1):
                    dname = 'det-{0:d}'.format(i)
                    self.rsr[bandname][dname] = {}
                    try:
                        resp = h5f[bandname][dname]['response'][:]
                    except KeyError:
                        resp = h5f[bandname]['response'][:]

                    self.rsr[bandname][dname]['response'] = resp

                    try:
                        wvl = (h5f[bandname][dname]['wavelength'][:] *
                               h5f[bandname][dname][
                                   'wavelength'].attrs['scale'])
                    except KeyError:
                        wvl = (h5f[bandname]['wavelength'][:] *
                               h5f[bandname]['wavelength'].attrs['scale'])

                    # The wavelength is given in micro meters!
                    self.rsr[bandname][dname]['wavelength'] = wvl * 1e6

                    try:
                        central_wvl = h5f[bandname][
                            dname].attrs['central_wavelength']
                    except KeyError:
                        central_wvl = h5f[bandname].attrs['central_wavelength']

                    self.rsr[bandname][dname][
                        'central_wavelength'] = central_wvl
914131
def load(self, filething):
        """"""

        fileobj = filething.fileobj

        self.metadata_blocks = []
        self.tags = None
        self.cuesheet = None
        self.seektable = None

        fileobj = StrictFileObject(fileobj)
        self.__check_header(fileobj, filething.name)
        while self.__read_metadata_block(fileobj):
            pass

        try:
            self.metadata_blocks[0].length
        except (AttributeError, IndexError):
            raise FLACNoHeaderError("Stream info block not found")

        if self.info.length:
            start = fileobj.tell()
            fileobj.seek(0, 2)
            self.info.bitrate = int(
                float(fileobj.tell() - start) * 8 / self.info.length)
        else:
            self.info.bitrate = 0
630002
def load_yaml_file(file_path: str):
    """"""
    with codecs.open(file_path, 'r') as f:
        return yaml.safe_load(f)
1048097
def load(self):
        """"""
        try:
            self._read()
            self._parse()
        except Exception as exc:
            self.failed = True

            params = {'path': self._path, 'exception': exc}
            if self.fail_silently:
                LOG.warning("Error processing message json file '%(path)s': "
                            "%(exception)s", params)
            else:
                raise exceptions.MessageFailure(
                    _("Error processing message json file '%(path)s': "
                      "%(exception)s") % params)
1182131
def load(self, filename, offset):
        """"""
        try:
            self.offset = offset
            # self.fd = open(filename, 'rb')
            # self.fd.close()
        except IOError:
            self.logger.error('Unable to load EfiSystem volume')
1156099
def from_files(controller, track_path, log_level=logging.ERROR):
        """"""
        rocket = Rocket(controller, track_path=track_path, log_level=log_level)
        rocket.connector = FilesConnector(track_path,
                                          controller=controller,
                                          tracks=rocket.tracks)
        return rocket
551859
def LoadChecksFromFiles(file_paths, overwrite_if_exists=True):
  """"""
  loaded = []
  for file_path in file_paths:
    configs = LoadConfigsFromFile(file_path)
    for conf in itervalues(configs):
      check = Check(**conf)
      # Validate will raise if the check doesn't load.
      check.Validate()
      loaded.append(check)
      CheckRegistry.RegisterCheck(
          check,
          source="file:%s" % file_path,
          overwrite_if_exists=overwrite_if_exists)
      logging.debug("Loaded check %s from %s", check.check_id, file_path)
  return loaded
871844
def load(self, file_path):
        '''  '''
        self.clear()
        self.__config = self.read_file(file_path)
257232
def load_file(self, filename):
        """"""
        filename = os.path.abspath(filename)

        with open(filename) as f:
            self.load_dict(yaml.load(f))

        self._loaded_files.append(filename)
407544
def load(self):
        """"""
        if self.is_file_persisted:
            self.object_file.open()
            temp = dill.loads(self.object_file.read())
            self.set_object(temp)
            self.object_file.close()
241804
def load(self, filename=None):
        """"""
        DataFile.load(self, filename)
        self.spectrum.filename = filename