def __handle_file(self, plugin_file):
     # Uncompress the file.
     temp_dir = tempfile.gettempdir()
     if is_zipfile(plugin_file):
         compress_fd = zipfile.ZipFile(plugin_file, allowZip64=True)
         compress_fd.extractall(path=temp_dir)
     elif is_bz2file(plugin_file):
         #first check if we can handle as tar.bz2 (big chances)
         try:
             compress_fd = TarFile(name=plugin_file, mode="r:bz2")
             compress_fd.extractall(path=temp_dir)
         except CompressionError:
             print "Upz!, fail in compressed file handling, Retrying"
             try:
                 compress_fd = bz2.BZ2File(plugin_file)
                 tmp_fd = tempfile.TemporaryFile(suffix=".tar",
                                                 prefix="ncmprs")
                 tmp_fd.file.write(compress_fd.read())
                 tmp_fd.file.flush()
                 tar_fd = TarFile.taropen(name=None, fileobj=tmp_fd)
                 tar_fd.extractall(path=temp_dir)
                 tar_fd.close()
                 tmp_fd.close()
             except:
                 print "Upz!, fail in compressed file handling, Again! :("
                 return None
     elif is_gzipfile(plugin_file):
         #first check if we can handle as tar.gz (big chances)
         try:
             compress_fd = TarFile(name=plugin_file, mode="r:gz")
             compress_fd.extractall(path=temp_dir)
         except CompressionError:
             print "Upz!, fail in compressed file handling, Retrying"
             try:
                 compress_fd = gzip.GzipFile(plugin_file)
                 tmp_fd = tempfile.TemporaryFile(suffix=".tar",
                                                 prefix="ncmprs")
                 tmp_fd.file.write(compress_fd.read())
                 tmp_fd.file.flush()
                 tar_fd = TarFile.taropen(name=None, fileobj=tmp_fd)
                 tar_fd.extractall(path=temp_dir)
                 tar_fd.close()
                 tmp_fd.close()
             except:
                 print "Upz!, fail in compressed file handling, Again! :("
                 return None
     return self.__handle_dir(temp_dir)
 def __handle_file(self, plugin_file):
     # Uncompress the file.
     temp_dir = tempfile.gettempdir()
     if is_zipfile(plugin_file):
         compress_fd = zipfile.ZipFile(plugin_file, allowZip64=True)
         compress_fd.extractall(path=temp_dir)
     elif is_bz2file(plugin_file):
         #first check if we can handle as tar.bz2 (big chances)
         try:
             compress_fd = TarFile(name=plugin_file, mode="r:bz2")
             compress_fd.extractall(path=temp_dir)
         except CompressionError:
             print "Upz!, fail in compressed file handling, Retrying"
             try:
                 compress_fd = bz2.BZ2File(plugin_file)
                 tmp_fd = tempfile.TemporaryFile(suffix=".tar", prefix="ncmprs")
                 tmp_fd.file.write(compress_fd.read())
                 tmp_fd.file.flush()
                 tar_fd = TarFile.taropen(name=None, fileobj=tmp_fd)
                 tar_fd.extractall(path=temp_dir)
                 tar_fd.close()
                 tmp_fd.close()
             except:
                 print "Upz!, fail in compressed file handling, Again! :("
                 return None
     elif is_gzipfile(plugin_file):
         #first check if we can handle as tar.gz (big chances)
         try:
             compress_fd = TarFile(name=plugin_file, mode="r:gz")
             compress_fd.extractall(path=temp_dir)
         except CompressionError:
             print "Upz!, fail in compressed file handling, Retrying"
             try:
                 compress_fd = gzip.GzipFile(plugin_file)
                 tmp_fd = tempfile.TemporaryFile(suffix=".tar", prefix="ncmprs")
                 tmp_fd.file.write(compress_fd.read())
                 tmp_fd.file.flush()
                 tar_fd = TarFile.taropen(name=None, fileobj=tmp_fd)
                 tar_fd.extractall(path=temp_dir)
                 tar_fd.close()
                 tmp_fd.close()
             except:
                 print "Upz!, fail in compressed file handling, Again! :("
                 return None
     return self.__handle_dir(temp_dir)