Skip to content

Commit 67927e9

Browse files
committed
dssp_stride plugin: Find binaries with shutil.which()
1 parent 3a80167 commit 67927e9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

plugins/dssp_stride.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@
7676
import tkinter.filedialog as tkFileDialog
7777
import tkinter.colorchooser as tkColorChooser
7878
import tkinter as Tkinter
79+
from shutil import which
7980
else:
8081
import tkSimpleDialog
8182
import tkMessageBox
8283
import tkFileDialog
8384
import tkColorChooser
8485
import Tkinter
86+
which = lambda cmd: None
8587

8688
# pymol lib
8789
try:
@@ -92,11 +94,7 @@
9294
sys.exit(1)
9395

9496
# external lib
95-
try:
96-
import Pmw
97-
except ImportError:
98-
print('Warning: failed to import Pmw. Exit ...')
99-
sys.exit(1)
97+
import Pmw
10098

10199
VERBOSE = True
102100

@@ -132,7 +130,7 @@ def __init__(self, app):
132130
Pmw.setbusycursorattributes(self.dialog.component('hull'))
133131

134132
# parameters used by DSSP
135-
self.pymol_sel = Tkinter.StringVar()
133+
self.pymol_sel = Tkinter.StringVar(value="all")
136134
self.dssp_bin = Tkinter.StringVar()
137135
self.stride_bin = Tkinter.StringVar()
138136
self.dssp_rlt_dict = {}
@@ -161,7 +159,7 @@ def __init__(self, app):
161159
else:
162160
if VERBOSE:
163161
print('DSSP_BIN not found in environmental variables.')
164-
self.dssp_bin.set('')
162+
self.dssp_bin.set(which('mkdssp') or '')
165163
if 'STRIDE_BIN' not in os.environ and 'PYMOL_GIT_MOD' in os.environ:
166164
if sys.platform.startswith('linux') and platform.machine() == 'x86_32':
167165
initialdir_stride = os.path.join(os.environ['PYMOL_GIT_MOD'], "Stride", "i86Linux2", "stride")
@@ -181,7 +179,7 @@ def __init__(self, app):
181179
else:
182180
if VERBOSE:
183181
print('STRIDE_BIN not found in environmental variables.')
184-
self.stride_bin.set('')
182+
self.stride_bin.set(which('stride') or '')
185183

186184
# DSSP visualization color
187185
# - H Alpha helix (4-12)

0 commit comments

Comments
 (0)