Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlinnet/2c3c4e65e91a3f338ca93487c282f932 to your computer and use it in GitHub Desktop.
Save tlinnet/2c3c4e65e91a3f338ca93487c282f932 to your computer and use it in GitHub Desktop.
Automatically import bruker spectra on linux
From e02cbda303474e850129a1b8a71648fad53e10b4 Mon Sep 17 00:00:00 2001
From: Troels Schwarz-Linnet <tlinnet@gmail.com>
Date: Fri, 27 Oct 2017 19:34:49 +0200
Subject: [PATCH] Making patch according to
http://forum.mmass.org/viewtopic.php?id=274
---
gui/dlg_preferences.py | 5 ++---
gui/main_frame.py | 34 ++++++++++++++++++++++++++--------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/gui/dlg_preferences.py b/gui/dlg_preferences.py
index 514309a..f6b022e 100644
--- a/gui/dlg_preferences.py
+++ b/gui/dlg_preferences.py
@@ -54,8 +54,7 @@ class dlgPreferences(wx.Dialog):
self.notebook = wx.Notebook(self, -1)
# add pages
- if wx.Platform == '__WXMSW__':
- self.notebook.AddPage(self.makeCompassPanel(), 'CompassXport')
+ self.notebook.AddPage(self.makeCompassPanel(), 'CompassXport')
self.notebook.AddPage(self.makeUpdatesPage(), 'Software Updates')
# pack elements
@@ -162,4 +161,4 @@ class dlgPreferences(wx.Dialog):
config.main['compassDeleteFile'] = int(self.compassDeleteFile_check.GetValue())
# ----
-
\ No newline at end of file
+
diff --git a/gui/main_frame.py b/gui/main_frame.py
index 0d2ae14..3662696 100644
--- a/gui/main_frame.py
+++ b/gui/main_frame.py
@@ -3572,7 +3572,7 @@ class mainFrame(wx.Frame):
self.tmpCompassXport = False
# check platform
- if not wx.Platform == '__WXMSW__':
+ if not wx.Platform in ('__WXMSW__', '__WXGTK__'):
wx.Bell()
dlg = mwx.dlgMessage(self, title="Unable to convert data.", message="Unfortunately, it is not possible to use Bruker's CompassXport tool\non this platform.")
dlg.ShowModal()
@@ -3634,14 +3634,32 @@ class mainFrame(wx.Frame):
mode = choices[config.main['compassFormat']]
# convert data
- try:
- output = os.path.join(os.path.dirname(path), 'Analysis.'+config.main['compassFormat'])
- retcode = subprocess.call(['CompassXport.exe', '-a', path, '-o', output, '-raw', str(raw), '-mode', str(mode)], shell=True)
- if retcode == 0:
- self.tmpCompassXport = output
+ output = os.path.join(os.path.dirname(path), 'Analysis.'+config.main['compassFormat'])
+ if wx.Platform == '__WXMSW__':
+ try:
+ retcode = subprocess.call(['CompassXport.exe', '-a', path, '-o', output, '-raw', str(raw), '-mode', str(mode)], shell=True)
+ if retcode == 0:
+ self.tmpCompassXport = output
+ return
+ except:
return
- except:
- return
+ else:
+ try:
+ # python 2.7+ required
+ # winepath appends \n to output
+ path_wine = subprocess.check_output(['winepath', '-w', path]).strip()
+ output_wine = subprocess.check_output(['winepath', '-w', output]).strip()
+ except:
+ print sys.stderr, "Wine can't reach input file", path
+ return
+ try:
+ retcode = subprocess.call(['wine', 'c:/Program Files/Bruker Daltonik/CompassXport/CompassXport.exe', '-a', path_wine, '-o', output_wine, '-raw', str(raw), '-mode', str(mode)], shell=False)
+ if retcode == 0:
+ self.tmpCompassXport = output
+ return
+ except:
+ return
+
# ----
--
2.11.0 (Apple Git-81)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment