def AddBuildInstance(self, build, dbfile_load_status, build_instance_id): if self.build_ids.has_key(build.name) == 0: self.AddBuild(build.name) if dbfile_load_status == -1: query = "INSERT INTO build_instance VALUES (NULL, %d, '%s', '%s', NULL, '%s', NOW(), NULL);" % ( self.build_ids[build.name], str(Parser.DateTimeFromString(build.start_time)), str(Parser.DateTimeFromString(build.end_time)), build.raw_file) self.curs.execute(query) self.build_instance_ids[build.name] = self.curs.insert_id() else: query = "UPDATE build_instance SET test_insert_time=NOW() where build_instance_id=%d;" % ( build_instance_id) self.curs.execute(query) self.build_instance_ids[build.name] = build_instance_id
def guess_datetime(datetime_string): """ Try to guess the datetime contained in a string of unknow format. @param datetime_string: the datetime representation. @type datetime_string: string @return: the guessed time. @rtype: L{time.struct_time} @raises ValueError: in case it's not possible to guess the time. """ if CFG_HAS_EGENIX_DATETIME: try: return Parser.DateTimeFromString(datetime_string).timetuple() except ValueError: pass else: for format in (None, '%x %X', '%X %x', '%Y-%M-%dT%h:%m:%sZ'): try: return time.strptime(datetime_string, format) except ValueError: pass raise ValueError("It is not possible to guess the datetime format of %s" % datetime_string)