apaeffgen / PanConvert

GUI Wrapper for Pandoc (Crossplatform)
http://panconvert.free.nf
GNU General Public License v3.0
35 stars 2 forks source link

Be more portable - os.name == "posix" #1

Closed jirib closed 4 years ago

jirib commented 8 years ago

There are not only Windows, Linux and MacOS ;) Tested on recent OpenBSD (x86_64):

diff --git a/Panconvert.py b/Panconvert.py
index 24b88f1..5608dc8 100755
--- a/Panconvert.py
+++ b/Panconvert.py
@@ -376,7 +376,7 @@ class StartQT5(QtWidgets.QMainWindow):
         global openfile, filelist

         batch_settings = QSettings('Pandoc', 'PanConvert')
-        if platform.system() == 'Windows' or platform.system() == 'Linux':
+        if platform.system() == 'Windows' or os.name == "posix":
             batch_convert_files = bool(strtobool(batch_settings.value('batch_convert_files')))
             batch_convert_directory = bool(strtobool(batch_settings.value('batch_convert_directory')))
             batch_convert_recursive = bool(strtobool(batch_settings.value('batch_convert_recursive')))
@@ -488,7 +488,7 @@ class StartQT5(QtWidgets.QMainWindow):

         if settings.value('From_Markdown') is not None:
-            if platform.system() == 'Windows' or platform.system() == 'Linux':
+            if platform.system() == 'Windows' or os.name == "posix":
                 self.ui.StandardConversion.setChecked(strtobool(Standard_Conversion))
                 self.ui.BatchConversion.setChecked(strtobool(Batch_Conversion))
                 self.ui.ButtonFromMarkdown.setChecked(strtobool(From_Markdown))
diff --git a/source/converter/interface_pandoc.py b/source/converter/interface_pandoc.py
index dbcad6a..44a1343 100644
--- a/source/converter/interface_pandoc.py
+++ b/source/converter/interface_pandoc.py
@@ -39,7 +39,7 @@ def get_path_pandoc():

     if len(path_pandoc) == 0:

-        if platform.system() == 'Darwin' or platform.system() == 'Linux':
+        if os.name == "posix":
             args = ['which', 'pandoc']
             p = subprocess.Popen(
                 args,
diff --git a/source/converter/lyx.py b/source/converter/lyx.py
index da11101..c4c311a 100644
--- a/source/converter/lyx.py
+++ b/source/converter/lyx.py
@@ -31,7 +31,7 @@ def get_path_multimarkdown():

     if len(path_multimarkdown) == 0:

-        if platform.system() == 'Darwin' or platform.system() == 'Linux':
+        if os.name == "posix":
             args = ['which', 'multimarkdown']
             p = subprocess.Popen(
                 args,
@@ -82,4 +82,4 @@ def convert_markdown2lyx(text):
     except OSError:
         QtWidgets.QMessageBox.warning(None, 'Error-Message',
                                           'MultiMarkdown could not be found on your System. Is it installed?'
-                                          'If so, please check the MultiMarkdown Path in your Preferences.')
\ No newline at end of file
+                                          'If so, please check the MultiMarkdown Path in your Preferences.')
diff --git a/source/dialog_batch.py b/source/dialog_batch.py
index fdddcbe..9904e05 100644
--- a/source/dialog_batch.py
+++ b/source/dialog_batch.py
@@ -55,7 +55,7 @@ class BatchDialog(QtWidgets.QDialog):

         if batch_settings.value('batch_convert_directory') is not None:
-            if platform.system() == 'Windows' or platform.system() == 'Linux':
+            if platform.system() == 'Windows' or os.name == "posix":
                 self.ui.ParameterBatchconvertDirectory.setChecked(strtobool(parameterBatchconvertDirectory))
                 self.ui.ParameterBatchconvertFiles.setChecked(strtobool(parameterBatchconvertFiles))
                 self.ui.ParameterBatchconvertRecursive.setChecked(strtobool(parameterBatchconvertRecursive))
@@ -110,4 +110,4 @@ if __name__ == "__main__":
     app = QtWidgets.QApplication(sys.argv)
     myapp = BatchDialog()
     myapp.show()
-    myapp.exec_()
\ No newline at end of file
+    myapp.exec_()
diff --git a/source/dialog_preferences.py b/source/dialog_preferences.py
index e04e209..c625275 100644
--- a/source/dialog_preferences.py
+++ b/source/dialog_preferences.py
@@ -22,6 +22,7 @@ from PyQt5.QtCore import QSettings
 from PyQt5 import QtCore
 from source.gui.panconvert_diag_prefpane import Ui_DialogPreferences
 from distutils.util import strtobool
+import os
 import platform

 global path_pandoc, path_dialog
@@ -78,7 +79,7 @@ class PreferenceDialog(QtWidgets.QDialog):

         if settings.value('From_Markdown') is not None:
-            if platform.system() == 'Windows' or platform.system() == 'Linux':
+            if platform.system() == 'Windows' or os.name == "posix":
                 self.ui.ButtonFromMarkdown.setChecked(strtobool(From_Markdown))
                 self.ui.ButtonFromHtml.setChecked(strtobool(From_Html))
                 self.ui.ButtonFromLatex.setChecked(strtobool(From_Latex))
@@ -167,4 +168,4 @@ if __name__ == "__main__":
     app = QtWidgets.QApplication(sys.argv)
     myapp = PreferenceDialog()
     myapp.show()
-    myapp.exec_()
\ No newline at end of file
+    myapp.exec_()
apaeffgen commented 8 years ago

Could you please check if the Bug is now fixed for FreeBSD in the new code update? I checked Windows, Linux and Mac. These platforms work.