예제 #1
0
    def guess_type(self, path):
        """Guess at the mime type for the specified file.
        """
        mimetype = srvmod.SimpleHTTPRequestHandler.guess_type(self, path)

        # If the default guess is too generic, try the python-magic library
        if mimetype == 'application/octet-stream' and magic_from_file:
            mimetype = magic_from_file(path, mime=True)

        return mimetype
예제 #2
0
    def guess_type(self, path):
        """Guess at the mime type for the specified file.
        """
        mimetype = srvmod.SimpleHTTPRequestHandler.guess_type(self, path)

        # If the default guess is too generic, try the python-magic library
        if mimetype == 'application/octet-stream' and magic_from_file:
            mimetype = magic_from_file(path, mime=True)

        return mimetype
예제 #3
0
    def __init__(self, stream):
        self.mime = magic_from_file(stream.name, mime=True)
        logging.debug(_('MIME type: %s'), self.mime)

        if self.mime in [
                b'application/x-object', b'application/x-executable',
                b'application/x-sharedlib'
        ]:
            self.binary = ELF(stream)
            self.system = 'linux'
            self.prefix = 'elf'
        elif self.mime == b'application/x-mach-binary':
            raise NotImplementedError(self.mime)
        elif self.mime == b'application/x-dosexec':
            self.binary = PE(stream)
            self.system = 'windows'
            self.prefix = 'pe'
        else:
            raise NotImplementedError(self.mime)
예제 #4
0
    def __init__(self, stream):
        self.mime = magic_from_file(stream.name, mime=True)
        logging.debug(_('MIME type: %s'), self.mime)

        if self.mime in [
                b'application/x-object',
                b'application/x-executable',
                b'application/x-sharedlib']:
            self.binary = ELF(stream)
            self.system = 'linux'
            self.prefix = 'elf'
        elif self.mime == b'application/x-mach-binary':
            raise NotImplementedError(self.mime)
        elif self.mime == b'application/x-dosexec':
            self.binary = PE(stream)
            self.system = 'windows'
            self.prefix = 'pe'
        else:
            raise NotImplementedError(self.mime)