 |
ATLAS Offline Software
|
◆ fifo()
def python.ext.silence.fifo |
( |
| ) |
|
Create a fifo in a temporary place.
Definition at line 33 of file silence.py.
35 Create a fifo in a temporary place.
38 filename = pjoin(tmpdir,
'myfifo')
42 print(
"Failed to create FIFO: %s" % e, file=stderr)
◆ make_fn()
def python.ext.silence.make_fn |
( |
|
what, |
|
|
|
res, |
|
|
* |
args |
|
) |
| |
◆ reader_thread_func()
def python.ext.silence.reader_thread_func |
( |
|
filename, |
|
|
|
filter_, |
|
|
|
real_stdout, |
|
|
|
filt_content |
|
) |
| |
Sit there, reading lines from the pipe `filename`, sending those for which
`filter_()` returns False to `real_stdout`
Definition at line 60 of file silence.py.
62 Sit there, reading lines from the pipe `filename`, sending those for which
63 `filter_()` returns False to `real_stdout`
65 with fdopen(osopen(filename, O_NONBLOCK | O_RDONLY))
as fd:
67 rlist, _, _ =
select([fd], [], [])
74 filt_content.write(line)
76 real_stdout.write(line)
◆ set_blocking()
def python.ext.silence.set_blocking |
( |
|
fd | ) |
|
Set FD to be blocking
Definition at line 51 of file silence.py.
55 flags = fcntl(fd, F_GETFL)
56 if flags & O_NONBLOCK:
58 fcntl(fd, F_SETFL, flags)
◆ silence()
def python.ext.silence.silence |
( |
|
filter_ = lambda line: True , |
|
|
|
file_ = stdout |
|
) |
| |
Prevent lines matching `filter_` ending up on `file_` (defaults to stdout)
Definition at line 92 of file silence.py.
92 def silence(filter_=lambda line:
True, file_=stdout):
94 Prevent lines matching `filter_` ending up on `file_` (defaults to stdout)
102 if not isinstance(file_, file):
107 saved_stdout = dup(file_.fileno())
110 from io
import StringIO
111 filt_content = StringIO()
113 with nested(fdopen(saved_stdout,
"w"),
fifo())
as (real_stdout, filename):
116 real_stdout, filt_content)
119 freopen(filename,
"w", stdout_file)
124 freopen(
"/dev/fd/%i" % saved_stdout,
"w", stdout_file)
127 print(
"Hit an exception. Filtered content:")
128 print(filt_content.getvalue())
◆ silence_sout_serr()
def python.ext.silence.silence_sout_serr |
( |
|
filter_ | ) |
|
Definition at line 132 of file silence.py.
133 from sys
import stdout, stderr
134 with nested(
silence(filter_, stdout),
silence(filter_, stderr))
as (so, se):
◆ test()
def python.ext.silence.test |
( |
| ) |
|
Definition at line 137 of file silence.py.
139 def filter_hello(line):
140 if line.startswith(
"Data source lookup using"):
143 print(
"Before with block..")
146 from DQUtils.db
import Databases
147 f = Databases.get_folder(
"DQMFONL")
148 print(
"Sensible stuff!")
152 print(
"I am after the silence block")
◆ test_with_exception()
def python.ext.silence.test_with_exception |
( |
| ) |
|
Definition at line 154 of file silence.py.
156 print(
"Before silence.")
158 with silence()
as filt_content:
160 raise RuntimeError(
"Error.")
163 print(
"After silence")
164 print(
"Stuff?", len(filt_content.getvalue()))
◆ threaded_file_reader()
def python.ext.silence.threaded_file_reader |
( |
* |
args | ) |
|
Operate a read_thread_func in another thread. Block with statement exit
until the function completes.
Definition at line 79 of file silence.py.
81 Operate a read_thread_func in another thread. Block with statement exit
82 until the function completes.
84 reader_thread = Thread(target=reader_thread_func, args=args)
◆ FILE_p
python.ext.silence.FILE_p = c_void_p |
◆ freopen
◆ pyapi
python.ext.silence.pyapi = PyDLL(None) |
◆ PyFile_AsFile
def python.ext.silence.PyFile_AsFile = make_fn(pyapi.PyFile_AsFile, FILE_p, py_object) |
◆ this_exe
python.ext.silence.this_exe = CDLL(None) |
def threaded_file_reader(*args)
def silence_sout_serr(filter_)
def test_with_exception()
void print(char *figname, TCanvas *c1)
def silence(filter_=lambda line:True, file_=stdout)
def make_fn(what, res, *args)
void select(const xAOD::IParticle *particle, const float coneSize, const xAOD::CaloClusterContainer *clusters, std::vector< bool > &mask)
def reader_thread_func(filename, filter_, real_stdout, filt_content)