def test_parse_debug_meta_info(self): head = b'MODULE windows x86 C1C0FA629EAA4B4D9DD2ADE270A231CC1 BreakpadTestApp.pdb' self.assertDictEqual(parse_debug_meta_info(head), dict(debug_id='C1C0FA629EAA4B4D9DD2ADE270A231CC1', debug_file='BreakpadTestApp.pdb')) head = b'MODULE mac x86_64 476350E1D4033CF180A2A7E388A7B6E40 Chromium Framework' self.assertDictEqual(parse_debug_meta_info(head), dict(debug_id='476350E1D4033CF180A2A7E388A7B6E40', debug_file='Chromium Framework'))
def clean_file(self): file = self.cleaned_data["file"] try: head = file.readline().rstrip() meta = parse_debug_meta_info(head, exception=forms.ValidationError) self.cleaned_data.update(meta) except: raise forms.ValidationError(u"The file contains invalid data.") return file
def create(self, validated_data): if not validated_data.get('debug_id') or \ not validated_data.get('debug_file'): file = validated_data['file'] try: head = file.readline().rstrip() meta = parse_debug_meta_info(head, exception=serializers.ValidationError) validated_data.update(meta) except: raise serializers.ValidationError(u"The file contains invalid data.") return super(SymbolsSerializer, self).create(validated_data)
def create(self, validated_data): if not validated_data.get('debug_id') or \ not validated_data.get('debug_file'): file = validated_data['file'] try: head = file.readline().rstrip() meta = parse_debug_meta_info( head, exception=serializers.ValidationError) validated_data.update(meta) except: raise serializers.ValidationError( u"The file contains invalid data.") return super(SymbolsSerializer, self).create(validated_data)