def process(file, config, rcontext, columns=None): fullpath = file.fullpath if file.btype.startswith("Microsoft Outlook email folder"): readpst_path = libutil.get_executable("libpst", "readpst") tempdir = None try: tempdir = tempfile.mkdtemp(dir=config.EXTRACTDIR) p = subprocess.Popen( [readpst_path, '-e', '-q', '-o', tempdir, fullpath]) err = p.communicate()[1] if err is not None: raise Exception("readpst failed to extract " + fullpath) recursive.call_uforia_recursive(config, rcontext, tempdir, fullpath) return [fullpath] except: traceback.print_exc(file=sys.stderr) return None finally: try: if tempdir: pass #shutil.rmtree(tempdir) # delete directory except OSError as exc: traceback.print_exc(file=sys.stderr)
def _extractall(fullpath, tempdir): # Try extracting all 7zip data seven_zip_tool = libutil.get_executable("p7zip", "7z") # Path that leads to the extraction tool if seven_zip_tool is None: raise Exception("7zip tool not given") # Path that leads to the archive if fullpath is None: raise Exception("Archive path not given") # Path that leads to the destination if tempdir is None: raise Exception("Tempdir not given") # Call extract command try: # Run command in working directory, and pipe output to null device. # 7z has no standard option to allow silencing output. devnull = open(os.devnull, "w") # Works on Windows too p = subprocess.Popen([seven_zip_tool, "x", fullpath], cwd=tempdir, stdout=devnull) output = p.communicate()[0] # If error is given by command raise exception if output is not None: raise Exception(output) except Exception as e: raise Exception(str(e) + " Command failed with following " + "arguments: " + fullpath + " " + tempdir + " " + seven_zip_tool)
def _do_xpdf_extract(fullpath, tempdir): # XPdf pdfimages executable pdfimages_path = libutil.get_executable("xpdf", "pdfimages") if not os.path.exists(pdfimages_path): raise Exception("pdfimages not found at " + pdfimages_path) p = subprocess.Popen([pdfimages_path, '-j', fullpath, tempdir + "/Xpdf"]) err = p.communicate()[1] if err is not None: raise Exception("pdfimages failed to extract " + fullpath)
def _do_xpdf_extract(fullpath, tempdir): # XPdf pdfimages executable pdfimages_path = libutil.get_executable("xpdf", "pdfimages") if not os.path.exists(pdfimages_path): raise Exception("pdfimages not found at " + pdfimages_path) p = subprocess.Popen([ pdfimages_path, '-j', fullpath, tempdir + "/Xpdf" ]) err = p.communicate()[1] if err is not None: raise Exception("pdfimages failed to extract " + fullpath)
def process(file, config, rcontext, columns=None): fullpath = file.fullpath if file.btype.startswith("Microsoft Outlook email folder"): readpst_path = libutil.get_executable("libpst", "readpst") tempdir = None try: tempdir = tempfile.mkdtemp(dir=config.EXTRACTDIR) p = subprocess.Popen([ readpst_path, '-e', '-q', '-o', tempdir, fullpath ]) err = p.communicate()[1] if err is not None: raise Exception("readpst failed to extract " + fullpath) recursive.call_uforia_recursive(config, rcontext, tempdir, fullpath) return [fullpath] except: traceback.print_exc(file=sys.stderr) return None finally: try: if tempdir: pass #shutil.rmtree(tempdir) # delete directory except OSError as exc: traceback.print_exc(file=sys.stderr)