Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
d6e9fc1c
Unverified
Commit
d6e9fc1c
authored
Oct 04, 2018
by
Savici, Andrei T
Committed by
GitHub
Oct 04, 2018
Browse files
Merge pull request #23712 from mantidproject/workbench_print_statemets
Duplicate print statements to the console
parents
58dddea4
6462f81c
Changes
3
Hide whitespace changes
Inline
Side-by-side
qt/applications/workbench/workbench/plugins/logmessagedisplay.py
View file @
d6e9fc1c
...
...
@@ -29,6 +29,8 @@ from workbench.plugins.base import PluginWidget
# Default logs at notice
DEFAULT_LOG_PRIORITY
=
5
ORIGINAL_STDOUT
=
sys
.
stdout
ORIGINAL_STDERR
=
sys
.
stderr
class
LogMessageDisplay
(
PluginWidget
):
...
...
@@ -44,10 +46,10 @@ class LogMessageDisplay(PluginWidget):
self
.
setWindowTitle
(
self
.
get_plugin_title
())
# output capture
s
tdout_capture
,
stderr_capture
=
WriteToSignal
(),
WriteToSignal
(
)
stdout
_capture
.
sig_write_received
.
connect
(
self
.
display
.
appendNotice
)
s
tderr_capture
.
sig_write_received
.
connect
(
self
.
display
.
appendError
)
self
.
std
out
,
self
.
stderr
=
stdout_capture
,
stderr_capture
s
elf
.
stdout
=
WriteToSignal
(
ORIGINAL_STDOUT
)
s
elf
.
s
tdout
.
sig_write_received
.
connect
(
self
.
display
.
appendNotice
)
s
elf
.
stderr
=
WriteToSignal
(
ORIGINAL_STDERR
)
self
.
std
err
.
sig_write_received
.
connect
(
self
.
display
.
appendError
)
def
get_plugin_title
(
self
):
return
"Messages"
...
...
qt/python/mantidqt/utils/test/test_writetosignal.py
View file @
d6e9fc1c
...
...
@@ -18,6 +18,7 @@ from __future__ import (absolute_import)
# std imports
import
unittest
import
sys
# 3rdparty
from
qtpy.QtCore
import
QCoreApplication
,
QObject
...
...
@@ -38,7 +39,7 @@ class WriteToSignalTest(GuiTest):
def
test_connected_receiver_receives_text
(
self
):
recv
=
Receiver
()
writer
=
WriteToSignal
()
writer
=
WriteToSignal
(
sys
.
stdout
)
writer
.
sig_write_received
.
connect
(
recv
.
capture_text
)
txt
=
"I expect to see this"
writer
.
write
(
txt
)
...
...
qt/python/mantidqt/utils/writetosignal.py
View file @
d6e9fc1c
...
...
@@ -27,6 +27,9 @@ class WriteToSignal(QObject):
used to transform write requests to
Qt-signals. Mainly used to communicate
stdout/stderr across threads"""
def
__init__
(
self
,
original_out
):
QObject
.
__init__
(
self
)
self
.
__original_out
=
original_out
sig_write_received
=
Signal
(
str
)
...
...
@@ -40,4 +43,7 @@ class WriteToSignal(QObject):
return
False
def
write
(
self
,
txt
):
# write to the console
self
.
__original_out
.
write
(
txt
)
# emit the signal which will write to logging
self
.
sig_write_received
.
emit
(
txt
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment