def __convert_timestamp(self, date_str, time_str): """ Converts date and time strings into a timestamp. """ joined_str = "%s %s" % (date_str, time_str) joined_format = "%s %s" % (self._parser.DATE_FORMAT, self._parser.TIME_FORMAT) try: timestamp = datetime.strptime(joined_str, joined_format) except ValueError: return None else: return as_utc_time(timestamp)
def __convert_timestamp(self, date_str, time_str): """ Converts date and time strings into a timestamp. """ joined_str = '%s %s' % (date_str, time_str) joined_format = '%s %s' % (self._parser.DATE_FORMAT, self._parser.TIME_FORMAT) try: timestamp = datetime.strptime(joined_str, joined_format) except ValueError: return None else: return as_utc_time(timestamp)
def __parse_timestamp(self): """ Parses the timestamp. """ self.add_debug('Parse timestamp ...') for line in self._lines: if self.TIMESTAMP_MARKER in line: datestr = line.split(self.TIMESTAMP_MARKER)[1].strip() try: self.timestamp = \ as_utc_time(datetime.strptime(datestr, self.TIMESTAMP_FORMAT)) except ValueError as errmsg: self.add_error(errmsg) break if self.timestamp is None: msg = 'Unable do find time stamp!' self.add_error(msg)
def check_in(self): """ Checks this sample into a freezer. Requires the `checkout_date` attribute to be set so that we can determine if a freeze/thaw cycle increment is in order. :raises RuntimeError: If the `checkout_date` attribute is `None`. """ checkout_date = self.checkout_date if checkout_date is None: raise RuntimeError("Trying to check in a sample that has not " "been checked out.") if checkout_date.tzinfo is None: checkout_date = as_utc_time(self.checkout_date) checkout_secs = abs(get_utc_time() - checkout_date).seconds if checkout_secs > self.thaw_time: if self.freeze_thaw_cycles is None: self.freeze_thaw_cycles = 1 else: self.freeze_thaw_cycles += 1 self.checkout_date = None
def check_in(self): """ Checks this sample into a freezer. Requires the `checkout_date` attribute to be set so that we can determine if a freeze/thaw cycle increment is in order. :raises RuntimeError: If the `checkout_date` attribute is `None`. """ checkout_date = self.checkout_date if checkout_date is None: raise RuntimeError('Trying to check in a sample that has not ' 'been checked out.') if checkout_date.tzinfo is None: checkout_date = as_utc_time(self.checkout_date) checkout_secs = abs(get_utc_time() - checkout_date).seconds if checkout_secs > self.thaw_time: if self.freeze_thaw_cycles is None: self.freeze_thaw_cycles = 1 else: self.freeze_thaw_cycles += 1 self.checkout_date = None