-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge/fix conflicts with pull request #9
- Loading branch information
Showing
41 changed files
with
314 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# | ||
# The Qubes OS Project, http://www.qubes-os.org | ||
# The Qubes OS Project, https://www.qubes-os.org | ||
# | ||
# Copyright (C) 2013 Joanna Rutkowska <[email protected]> | ||
# | ||
|
@@ -19,11 +19,12 @@ | |
# | ||
# | ||
|
||
build: | ||
make manpages -C doc | ||
PANDOC=pandoc -s -f markdown -t man | ||
NAME := convert-pdf | ||
|
||
install-vm: | ||
make install -C doc | ||
install-vm: build | ||
install -d $(DESTDIR)/usr/share/man/man1 | ||
install -D qvm-$(NAME).1.gz $(DESTDIR)/usr/share/man/man1/ | ||
python3 setup.py install -O1 $(PYTHON_PREFIX_ARG) --root $(DESTDIR) | ||
install -d $(DESTDIR)/etc/qubes-rpc | ||
ln -s ../../usr/lib/qubes/qpdf-convert-server $(DESTDIR)/etc/qubes-rpc/qubes.PdfConvert | ||
|
@@ -39,6 +40,15 @@ install-dom0: | |
rm -f $(DESTDIR)/usr/bin/qvm-convert-pdf | ||
rm -f $(DESTDIR)/usr/lib/qubes/qpdf-convert-server | ||
|
||
qvm-$(NAME).1: README.md | ||
$(PANDOC) $< > $@ | ||
|
||
qvm-$(NAME).1.gz: qvm-$(NAME).1 | ||
gzip -f $< | ||
|
||
build: qvm-$(NAME).1.gz | ||
|
||
clean: | ||
rm -rf debian/changelog.* | ||
rm -rf pkgs | ||
rm -f qvm-$(NAME).1.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pkgname=(qubes-pdf-converter) | ||
pkgver=$(cat version) | ||
pkgrel=1 | ||
arch=(x86_64) | ||
pkgdesc=$(grep "Summary:" ./rpm_spec/qpdf-converter.spec.in | sed 's/Summary://' | xargs) | ||
url=$(git remote get-url origin) | ||
license=(GPL) | ||
makedepends=(git pandoc python-setuptools) | ||
depends=(libreoffice graphicsmagick zenity poppler python-nautilus python-click python-pillow python-tqdm python-magic) | ||
|
||
build() { | ||
ln -s "$srcdir"/../ "$srcdir/src" | ||
} | ||
package() { | ||
cd src | ||
make install-vm DESTDIR="$pkgdir/" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9 | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
Source: qubes-pdf-converter | ||
Section: admin | ||
Priority: extra | ||
Priority: optional | ||
Maintainer: Jason Mehring <[email protected]> | ||
Build-Depends: | ||
debhelper (>= 9~), | ||
dh-python, | ||
python3-setuptools, | ||
pandoc, | ||
quilt | ||
X-Python-Version: 2.7 | ||
Standards-Version: 3.9.5 | ||
Homepage: http://www.qubes-os.org | ||
Build-Depends: pandoc, python3-setuptools, debhelper (>= 9) | ||
# For the futures version of debian, delete the "compat" file, and add the line below in "Build-Depends" | ||
# debhelper-compat (= 12) | ||
Standards-Version: 4.5.0 | ||
Homepage: https://github.com/QubesOS/qubes-app-linux-pdf-converter | ||
|
||
Package: qubes-pdf-converter | ||
Section: admin | ||
Architecture: any | ||
Depends: | ||
Depends: | ||
poppler-utils, | ||
imagemagick, | ||
libreoffice, | ||
graphicsmagick, | ||
python3 (>= 3.7.0), | ||
python3-nautilus | python-nautilus, | ||
python3-click, | ||
python3-pillow, | ||
python3-tqdm, | ||
python3-magic, | ||
${misc:Depends} | ||
Description: The Qubes service for converting untrusted PDF files into trusted ones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: qubes-pdf-converter | ||
Source: <http://www.qubes-os.org/> | ||
Source: <https://github.com/QubesOS/qubes-app-linux-pdf-converter> | ||
|
||
Files: * | ||
Copyright: 2014-2015 Qubes Developers | ||
|
@@ -16,7 +16,7 @@ License: GPL-2+ | |
GNU General Public License for more details. | ||
. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/> | ||
along with this program. If not, see <https://www.gnu.org/licenses/> | ||
. | ||
On Debian systems, the complete text of the GNU General | ||
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". | ||
|
@@ -34,7 +34,7 @@ Copyright: 2015 Jason Mehring <[email protected]> License: GPL-2+ | |
GNU General Public License for more details. | ||
. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/> | ||
along with this program. If not, see <https://www.gnu.org/licenses/> | ||
. | ||
On Debian systems, the complete text of the GNU General | ||
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
## Note that policy parsing stops at the first match, | ||
## so adding anything below "$anyvm $anyvm action" line will have no effect | ||
## so adding anything below "@anyvm @anyvm action" line will have no effect | ||
|
||
## Please use a single # to start your custom comments | ||
|
||
$anyvm $dispvm allow | ||
@anyvm @dispvm allow | ||
@anyvm @anyvm deny |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# The Qubes OS Project, http://www.qubes-os.org | ||
# The Qubes OS Project, https://www.qubes-os.org | ||
# | ||
# Copyright (C) 2013 Joanna Rutkowska <[email protected]> | ||
# Copyright (C) 2020 Jason Phan <[email protected]> | ||
|
@@ -21,20 +21,19 @@ | |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
||
import asyncio | ||
import click | ||
import functools | ||
import logging | ||
import shutil | ||
import signal | ||
import subprocess | ||
import sys | ||
import tqdm | ||
|
||
from enum import Enum, auto | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from PIL import Image | ||
from tempfile import TemporaryDirectory | ||
from PIL import Image | ||
import tqdm | ||
import click | ||
|
||
CLIENT_VM_CMD = ["/usr/bin/qrexec-client-vm", "@dispvm", "qubes.PdfConvert"] | ||
|
||
|
@@ -184,7 +183,6 @@ async def recvline(proc): | |
untrusted_data = await proc.stdout.readline() | ||
if not untrusted_data: | ||
raise EOFError | ||
|
||
return untrusted_data.decode("ascii").rstrip() | ||
|
||
|
||
|
@@ -232,6 +230,7 @@ async def convert(self, bar): | |
:param bar: Progress bar to update upon completion | ||
""" | ||
cmd = [ | ||
"gm", | ||
"convert", | ||
"-size", | ||
f"{self.dim.width}x{self.dim.height}", | ||
|
@@ -294,7 +293,6 @@ async def _dim(self, proc): | |
size = width * height * 3 | ||
else: | ||
raise ValueError | ||
|
||
return ImageDimensions(width, height, size) | ||
|
||
|
||
|
@@ -390,10 +388,12 @@ async def _save_reps(self, pages): | |
|
||
for page in pages: | ||
try: | ||
images.append(await asyncio.get_running_loop().run_in_executor( | ||
None, | ||
Image.open, | ||
Path(self.pdf.parent, f"{page}.png")) | ||
images.append( | ||
await asyncio.get_running_loop().run_in_executor( | ||
None, | ||
Image.open, | ||
Path(self.pdf.parent, f"{page}.png") | ||
) | ||
) | ||
except IOError as e: | ||
for image in images: | ||
|
@@ -549,7 +549,6 @@ async def _send(self): | |
None, | ||
self.path.read_bytes | ||
) | ||
|
||
try: | ||
await send(self.proc, data) | ||
except BrokenPipeError as e: | ||
|
@@ -582,7 +581,6 @@ def _archive(self, archive): | |
async def run(params): | ||
suffix = "s" if len(params["files"]) > 1 else "" | ||
print(f"Sending file{suffix} to Disposable VM{suffix}...\n") | ||
|
||
tasks = [] | ||
jobs = [Job(f, i) for i, f in enumerate(params["files"])] | ||
for job in jobs: | ||
|
@@ -612,7 +610,10 @@ async def run(params): | |
if tqdm.__version__ >= "4.34.0": | ||
print() | ||
else: | ||
print() if len(jobs) == 1 else print("\n" * len(jobs)) | ||
if len(jobs) == 1: | ||
print() | ||
else: | ||
print("\n" * len(jobs)) | ||
|
||
while not ERROR_LOGS.empty(): | ||
err_msg = await ERROR_LOGS.get() | ||
|
Oops, something went wrong.