def get_seq_range_bytes(self, name, start, stop): pos, padding, size = self.starts[name] if (stop >= size): stop = size - 1 #raise IndexError("Stop index too large: " + str(stop)) if (start > stop): raise IndexError("Start index larger or equal to stop index: " + str(start) + ", " + str(stop)) if (start < 0): raise IndexError("Indices must be >= zero: " + str(start)) start_byte = start / 4 end_byte = stop / 4 byte_len = end_byte - start_byte + 1 f = open(self.file, "rb") f.seek(pos + start_byte, 0) s = f.read(byte_len) f.close() bytes = list(struct.unpack(">" + str(byte_len) + "B", s)) return bytes
def fill_parameters(self, data): """ Fill parameters with the provided data @param data: dictionnary with parameter name as key, and a dictionnary of {key: value} entries to fill the parameter @return True if the filling has been done @raise IndexError when provided name is not registered as a Parameter name @raise ValueError when parameter has not been correctly filled with provided values. Note that this exception has to be raised by the Parameter """ for name in data: if name not in self._parameters: raise IndexError("Name " + name + "is not in known parameters for this test") else: self._parameters[name].fill(data[name])
def get_by_index(self, i, j): if not self.are_indices_in_range(i, j): raise IndexError() return self.map.data[i * self.width + j]
def __getitem__(self, pos): if 0 <= pos[0] < self.rows and 0 <= pos[1] < self.cols: return self.data[pos[0]][pos[1]] else: raise IndexError("Index out of bounds ( %d, %d )" % (pos[0], pos[1]))
def __setitem__(self, pos, v): if 0 <= pos[0] < self.rows and 0 <= pos[1] < self.cols: self.data[pos[0]][pos[1]] = v else: raise IndexError("Index out of bounds ( %d, %d )" % (pos[0], pos[1]))
change_location(myConn, snid, site, location) if __name__ == "__main__": data_dir = "/sps/lsst/DataBE/ASPIC_production/" archive_dir = "/lsst-fr/data/camera/ASPIC_data" print 'running script %s ...' % sys.argv[0] print 'data_dir is ', data_dir print 'archive_dir is ', archive_dir try: chips = sys.argv[1] except IndexError: raise IndexError( 'chip idea input (e.g. 0001 or 01* or a file with chip ids) needs to be provided' ) if len(sys.argv) == 2: move_to = 'CCIN2P3/Cabinet' else: move_to = sys.argv[2] chipdirs, site, location = input_parsing(chips, move_to=move_to) #need to clean the list of usable logs logdir = os.path.join(data_dir, 'Logs') logfiles = glob.glob(os.path.join(logdir, "log-*.txt")) logfiles = filter( lambda x: (not 'try' in x) and (not 'Test' in x) and ( ('PreScreening' in x) or ('PostScreening' in x) or
def get_by_index(self, i, j): if not self.are_indices_within_map(i, j): raise IndexError() return self.data[i*self.width + j]