Skip to content

Commit

Permalink
Merge pull request #14 from CybercentreCanada/logging
Browse files Browse the repository at this point in the history
Logging
  • Loading branch information
cccs-rs authored Jun 9, 2022
2 parents d359919 + d0ae4d2 commit 9dc7011
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions document_preview/document_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def stop(self):
self.log.debug("Document preview service ended")

def libreoffice_conversion(self, file, convert_to="pdf"):
subprocess.check_output(
f"libreoffice --headless --convert-to {convert_to} --outdir " + self.working_directory + " " + file,
shell=True)
subprocess.run(["libreoffice", "--headless",
"--convert-to", convert_to,
"--outdir", self.working_directory, file], capture_output=True)

converted_file = [s for s in os.listdir(self.working_directory) if f".{convert_to}" in s][0]

Expand All @@ -40,9 +40,11 @@ def libreoffice_conversion(self, file, convert_to="pdf"):
return (False, None)

def office_conversion(self, file, orientation="portrait", page_range_end=2):
subprocess.check_output(
f"unoconv -f pdf -e PageRange=1-{page_range_end} -P PaperOrientation={orientation} -P PaperFormat=A3 -o {self.working_directory}/ {file}",
shell=True)
subprocess.run(["unoconv", "-f", "pdf",
"-e", f"PageRange=1-{page_range_end}",
"-P", f"PaperOrientation={orientation}",
"-P", "PaperFormat=A3",
"-o", f"{self.working_directory}/", file], capture_output=True)

converted_file = [s for s in os.listdir(self.working_directory) if f".pdf" in s]

Expand Down

0 comments on commit 9dc7011

Please sign in to comment.