def do_save_raw_crash(boto_connection, raw_crash, dumps, crash_id): if dumps is None: dumps = MemoryDumpsMapping() raw_crash_as_string = boto_connection._convert_mapping_to_string( raw_crash ) boto_connection.submit( crash_id, "raw_crash", raw_crash_as_string ) dump_names_as_string = boto_connection._convert_list_to_string( dumps.keys() ) boto_connection.submit( crash_id, "dump_names", dump_names_as_string ) # we don't know what type of dumps mapping we have. We do know, # however, that by calling the memory_dump_mapping method, we will # get a MemoryDumpMapping which is exactly what we need. dumps = dumps.as_memory_dumps_mapping() for dump_name, dump in dumps.iteritems(): if dump_name in (None, '', 'upload_file_minidump'): dump_name = 'dump' boto_connection.submit(crash_id, dump_name, dump)
def test_simple(self): mdm = MemoryDumpsMapping({ 'upload_file_minidump': 'binary_data', 'moar_dump': "more binary data", }) ok_(mdm.as_memory_dumps_mapping() is mdm) fdm = mdm.as_file_dumps_mapping('a', '/tmp', 'dump') ok_(fdm.as_file_dumps_mapping() is fdm) eq_(fdm.as_memory_dumps_mapping(), mdm)
def save_raw_crash(self, raw_crash, dumps, crash_id): if dumps is None: dumps = MemoryDumpsMapping() files = { crash_id + self.config.json_file_suffix: json.dumps(raw_crash) } in_memory_dumps = dumps.as_memory_dumps_mapping() files.update(dict((self._get_dump_file_name(crash_id, fn), dump) for fn, dump in in_memory_dumps.iteritems())) self._save_files(crash_id, files)
def save_raw_crash(self, raw_crash, dumps, crash_id): if dumps is None: dumps = MemoryDumpsMapping() files = { crash_id + self.config.json_file_suffix: json.dumps(raw_crash) } in_memory_dumps = dumps.as_memory_dumps_mapping() files.update( dict((self._get_dump_file_name(crash_id, fn), dump) for fn, dump in in_memory_dumps.iteritems())) self._save_files(crash_id, files)
def test_simple(self): mdm = MemoryDumpsMapping({ 'upload_file_minidump': 'binary_data', 'moar_dump': "more binary data", }) ok_(mdm.as_memory_dumps_mapping() is mdm) fdm = mdm.as_file_dumps_mapping( 'a', '/tmp', 'dump' ) ok_(fdm.as_file_dumps_mapping() is fdm) eq_(fdm.as_memory_dumps_mapping(), mdm)
def _make_test_crash(self, crash_id=CRASH_ID_1): self.fsrts.save_raw_crash({"test": "TEST"}, MemoryDumpsMapping({ 'foo': 'bar', self.fsrts.config.dump_field: 'baz' }), crash_id)
def test_get_raw_dumps(self): self._make_test_crash() eq_(self.fsrts.get_raw_dumps(self.CRASH_ID_1), MemoryDumpsMapping({ 'foo': 'bar', self.fsrts.config.dump_field: 'baz' })) assert_raises(CrashIDNotFound, self.fsrts.get_raw_dumps, self.CRASH_ID_2)
def _get_raw_crash_from_form(self): """this method creates the raw_crash and the dumps mapping using the POST form""" dumps = MemoryDumpsMapping() raw_crash = DotDict() raw_crash.dump_checksums = DotDict() for name, value in self._form_as_mapping().iteritems(): name = self._no_x00_character(name) if isinstance(value, basestring): if name != "dump_checksums": raw_crash[name] = self._no_x00_character(value) elif hasattr(value, 'file') and hasattr(value, 'value'): dumps[name] = value.value raw_crash.dump_checksums[name] = \ self.checksum_method(value.value).hexdigest() elif isinstance(value, int): raw_crash[name] = value else: raw_crash[name] = value.value return raw_crash, dumps
def do_get_raw_dumps(boto_connection, crash_id): try: dump_names_as_string = boto_connection.fetch( crash_id, "dump_names" ) dump_names = boto_connection._convert_string_to_list( dump_names_as_string ) # when we fetch the dumps, they are by default in memory, so we'll # put them into a MemoryDumpMapping. dumps = MemoryDumpsMapping() for dump_name in dump_names: if dump_name in (None, '', 'upload_file_minidump'): dump_name = 'dump' dumps[dump_name] = boto_connection.fetch( crash_id, dump_name ) return dumps except boto_connection.ResponseError as x: raise CrashIDNotFound( '%s not found: %s' % (crash_id, x) )