Skip to content

Commit 790850a

Browse files
committed
Merge branch 'fix-console' into 'develop'
fix updating current projects in console See merge request psyplot/psyplot-gui!35
2 parents 639b503 + 97eb0c3 commit 790850a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

psyplot_gui/console.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,21 @@ def update_mp(self, project):
244244
"""Update the `mp` variable in the shell is
245245
``rcParams['console.auto_set_mp']`` with a main project"""
246246
if self.rc["auto_set_mp"] and project is not None and project.is_main:
247-
self.run_command_in_shell("mp = psy.gcp(True)")
247+
try:
248+
self.run_command_in_shell("mp = psy.gcp(True)")
249+
except RuntimeError:
250+
# probably running a script that via IPythons `run` magick
251+
pass
248252

249253
def update_sp(self, project):
250254
"""Update the `sp` variable in the shell is
251255
``rcParams['console.auto_set_sp']`` with a sub project"""
252256
if self.rc["auto_set_sp"] and (project is None or not project.is_main):
253-
self.run_command_in_shell("sp = psy.gcp()")
257+
try:
258+
self.run_command_in_shell("sp = psy.gcp()")
259+
except RuntimeError:
260+
# probably running a script that via IPythons `run` magick
261+
pass
254262

255263
def show_current_help(self, to_end=False, force=False):
256264
"""Show the help of the object at the cursor position if

0 commit comments

Comments
 (0)