Skip to content

Commit

Permalink
third try to fix poppler path issue on mac os; preselect file name fo…
Browse files Browse the repository at this point in the history
…r pro6x; don't fill lineEdit with non-existing path on startup
  • Loading branch information
P1zz4br0etch3n committed May 21, 2020
1 parent 94fdfe2 commit 34ccbdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/build/settings/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"app_name": "pdf2pro6x",
"author": "Aron Schmidt",
"main_module": "src/main/python/main.py",
"version": "0.3.4"
"version": "0.3.5"
}
21 changes: 5 additions & 16 deletions src/main/python/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import subprocess
import sys

from PyQt5 import QtWidgets
Expand All @@ -11,18 +10,7 @@
from gui.main import Ui_MainWindow
from gui.poppler_not_installed_dialog import Ui_PopplerNotInstalledDialog
from gui.success_dialog import Ui_SuccessDialog
from pdf2pro6x import main


def _get_poppler_path_on_mac():
process = subprocess.run(['which', 'pdfinfo'], stdout=subprocess.PIPE)
print('try to find poppler path. return code is %d' % process.returncode)
if process.returncode == 0:
path = process.stdout.decode('utf-8').replace('/pdfinfo\n', '')
print('path is %s' % path)
return path
else:
return None
from pdf2pro6x import main, change_extension


class HideOnAcceptDialog(QtWidgets.QDialog):
Expand Down Expand Up @@ -51,7 +39,8 @@ def convert_slot():
ui_dialog = None

try:
path_to_pro6x, _ = QtWidgets.QFileDialog().getSaveFileName(filter='*.pro6x')
directory = change_extension(path_to_pdf, 'pro6x')
path_to_pro6x, _ = QtWidgets.QFileDialog().getSaveFileName(filter='*.pro6x', directory=directory)
if path_to_pro6x:
main(path_to_pdf, path_to_pro6x, poppler_path)
ui_dialog = Ui_SuccessDialog()
Expand All @@ -65,13 +54,13 @@ def convert_slot():

if __name__ == '__main__':
path_to_pdf = sys.argv[1] if len(sys.argv) > 1 else None
poppler_path = _get_poppler_path_on_mac() if is_mac() else None
poppler_path = '/usr/local/bin' if is_mac() else None

appctxt = ApplicationContext()
MainWindow = MainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
if path_to_pdf:
if path_to_pdf and os.path.exists(path_to_pdf):
MainWindow.set_path_to_pdf(path_to_pdf)
MainWindow.show()
sys.exit(appctxt.app.exec_())

0 comments on commit 34ccbdb

Please sign in to comment.