Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/peircej/psychopy
Browse files Browse the repository at this point in the history
  • Loading branch information
peircej committed Feb 14, 2020
2 parents e1297b8 + 2e1ed15 commit 6a331e6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
7 changes: 7 additions & 0 deletions createInitFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def createInitFile(dist=None, version=None, sha=None):
from psychopy.tools.versionchooser import useVersion, ensureMinimal
# import readline here to get around an issue with sounddevice
# issues GH-2230 GH-2344 GH-2662
try:
import readline
except ImportError:
pass # all that will happen is the stderr/stdout might get redirected
"""


Expand Down
1 change: 1 addition & 0 deletions psychopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@
import readline
except ImportError:
pass # all that will happen is the stderr/stdout might get redirected

29 changes: 20 additions & 9 deletions psychopy/app/_psychopyApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ def __init__(self, arg=0, testMode=False, **kwargs):
self._stderr = sys.stderr
self._stdoutFrame = None

if self.prefs.app['debugMode']:
if not self.testMode:
self._lastRunLog = open(os.path.join(
self.prefs.paths['userPrefsDir'], 'last_app_load.log'),
'w')
sys.stderr = sys.stdout = lastLoadErrs = self._lastRunLog
logging.console.setLevel(logging.DEBUG)

# indicates whether we're running for testing purposes
self.osfSession = None
self.pavloviaSession = None
Expand Down Expand Up @@ -228,7 +233,7 @@ def onInit(self, showSplash=True, testMode=False):
) # transparency?
w, h = splashImage.GetSize()
splash.SetTextPosition((int(200), h-20))
splash.SetText(_translate("Copyright (C) 2019 OpenScienceTools.org"))
splash.SetText(_translate("Copyright (C) 2020 OpenScienceTools.org"))
else:
splash = None

Expand Down Expand Up @@ -348,7 +353,7 @@ def onInit(self, showSplash=True, testMode=False):
from psychopy.hardware import keyboard
if keyboard.macPrefsBad:
title = _translate("Mac keyboard security")
if platform.mac_ver() < '10.15':
if platform.mac_ver()[0] < '10.15':
settingName = 'Accessibility'
setting = 'Privacy_Accessibility'
else:
Expand Down Expand Up @@ -378,12 +383,6 @@ def onInit(self, showSplash=True, testMode=False):
# Open System Preference
workspace.openURL_(NSURL.URLWithString_(sys_pref_link))

# Runner captures standard streams until program closed
if not self.testMode:
self._stdout = sys.stdout = self.runner.stdOut
self._stderr = sys.stderr = self.runner.stdOut


# send anonymous info to www.psychopy.org/usage.php
# please don't disable this, it's important for PsychoPy's development
self._latestAvailableVersion = None
Expand Down Expand Up @@ -435,6 +434,18 @@ def onInit(self, showSplash=True, testMode=False):
self._appLoaded = True
if self.coder:
self.coder.setOutputWindow() # takes control of sys.stdout

# flush any errors to the last run log file
logging.flush()
sys.stdout.flush()
# we wanted debug mode while loading but safe to go back to info mode
if not self.prefs.app['debugMode']:
logging.console.setLevel(logging.INFO)
# Runner captures standard streams until program closed
if not self.testMode:
sys.stdout = self.runner.stdOut
sys.stderr = self.runner.stdOut

return True

def _wizard(self, selector, arg=''):
Expand Down
3 changes: 2 additions & 1 deletion psychopy/app/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,8 @@ def makeMenus(self):
self.recentFilesMenu = wx.Menu()
self.fileHistory.UseMenu(self.recentFilesMenu)
for filename in self.appData['fileHistory']:
self.fileHistory.AddFileToHistory(filename)
if os.path.exists(filename):
self.fileHistory.AddFileToHistory(filename)
self.Bind(wx.EVT_MENU_RANGE, self.OnFileHistory,
id=wx.ID_FILE1, id2=wx.ID_FILE9)
keys = self.app.keys
Expand Down
3 changes: 2 additions & 1 deletion psychopy/app/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ def onItemSelected(self, evt):
self.updateAlerts()

def updateAlerts(self):
prev = sys.stdout
# check for alerts
sys.stdout = sys.stderr = self.alertsCtrl
self.alertsCtrl.Clear()
Expand All @@ -620,7 +621,7 @@ def updateAlerts(self):
# update labels and text accordingly
self.alertsToggleBtn.SetLabelText("Alerts ({})".format(nAlerts))
sys.stdout.flush()
sys.stdout = sys.stderr= self.stdoutCtrl
sys.stdout = sys.stderr = prev
if nAlerts == 0:
self.setAlertsVisible(False)
# elif selected hidden then don't touch
Expand Down

0 comments on commit 6a331e6

Please sign in to comment.