Logging and reporting tools for a wmt-exe environment.
wmtexe.reporter.Reporter(id, server, filename, **kwds)[source]¶Bases: threading.Thread
Event reporter for wmt-exe tasks.
| Parameters: | id : str
server : str
filename : str
**kwds
|
|---|
Attributes
daemon |
A boolean value indicating whether this thread is a daemon thread (True) or not (False). |
ident |
Thread identifier of this thread or None if it has not been started. |
name |
A string used for identification purposes only. |
Methods
getName() |
|
isAlive() |
Return whether the thread is alive. |
isDaemon() |
|
is_alive() |
Return whether the thread is alive. |
join([timeout]) |
Wait until the thread terminates. |
run() |
Start reporting on a task. |
setDaemon(daemonic) |
|
setName(name) |
|
start() |
Start the thread’s activity. |
stop() |
Stop reporting on a task. |
stopped() |
Check whether reporting has stopped. |
wmtexe.reporter.TaskCompleted[source]¶Bases: exceptions.Exception
Exception thrown when a wmt-exe task completes.
wmtexe.reporter.TaskStatus(id, server, filename, pid=None, prefix='.')[source]¶Bases: wmtexe.reporter.WmtTaskReporter
Task status manager for a wmt-exe environment.
| Parameters: | id : str
server : str
filename : str
pid : str, optional
prefix : str, optional
|
|---|
Attributes
elapsed |
Get the elapsed time in the simulation. |
id |
Get id of task. |
server |
Get server URL. |
status_file |
Get the status file. |
Methods
__call__() |
|
get_status() |
Get task status. |
report(status, message) |
Report task status using requests. |
report_error(message) |
Report an error. |
report_status() |
Report task status at regular intervals until task completes. |
report_success(message) |
Report successful task completion. |
report_with_curl(status, message) |
Report task status using curl. |
running() |
Test whether the simulation is running. |
status_with_line_nos([n]) |
Get status prepended with line numbers. |
elapsed¶Get the elapsed time in the simulation.
| Returns: | float
|
|---|
report_status()[source]¶Report task status at regular intervals until task completes.
| Returns: | Reponse
|
|---|
running()[source]¶Test whether the simulation is running.
| Returns: | bool
|
|---|
status_file¶Get the status file.
| Returns: | str
|
|---|
wmtexe.reporter.WmtTaskReporter(id, server)[source]¶Bases: object
Reporter for wmt-exe tasks.
| Parameters: | id : str
server : str
|
|---|
Attributes
id |
Get id of task. |
server |
Get server URL. |
Methods
report(status, message) |
Report task status using requests. |
report_error(message) |
Report an error. |
report_success(message) |
Report successful task completion. |
report_with_curl(status, message) |
Report task status using curl. |
id¶Get id of task.
| Returns: | str
|
|---|
report(status, message)[source]¶Report task status using requests.
| Parameters: | status : str
message : str
|
|---|---|
| Returns: | Reponse
|
report_error(message)[source]¶Report an error.
| Parameters: | message : str
|
|---|---|
| Returns: | Reponse
|
report_success(message)[source]¶Report successful task completion.
| Parameters: | message : str
|
|---|---|
| Returns: | Reponse
|
report_with_curl(status, message)[source]¶Report task status using curl.
| Parameters: | status : str
message : str
|
|---|---|
| Returns: | str
|
server¶Get server URL.
| Returns: | str
|
|---|
wmtexe.reporter.add_line_numbers(lines, start=0, fn=None)[source]¶Prefix lines with numbers.
| Parameters: | lines : list or list-like of str
start : int, optional
fn : str, optional
|
|---|---|
| Returns: | list
|
wmtexe.reporter.load_status_from_lines(lines)[source]¶Load task status from strings.
| Parameters: | lines : list or list-like of str
|
|---|---|
| Returns: | dict
|
wmtexe.reporter.logger = <logging.Logger object>¶Logger : Instance of Logging class.
wmtexe.reporter.open_reporter(id, server, fname)[source]¶Bases: object
Manager for a reporter in a wmt-exe environment.
| Parameters: | id : str
server : str
fname : str
|
|---|
wmtexe.reporter.read_wmt_status(fname)[source]¶Read the WMT status from a file.
| Parameters: | fname : str
|
|---|---|
| Returns: | dict
|
wmtexe.reporter.redirect_output(name, log_dir='.', join=False)[source]¶Bases: object
Manager for output and error logs.
| Parameters: | name : str
log_dir : str, optional
join : bool, optional
|
|---|
wmtexe.reporter.tail(fname, n=10, with_tail='tail')[source]¶Get the last lines in a file.
| Parameters: | fname : str
n : int, optional
with_tail : str, optional
|
|---|---|
| Returns: | str
|
wmtexe.reporter.tail_with_line_numbers(fname, n=10, with_tail='tail', with_wc='wc')[source]¶Get the last lines in a file, with line numbers.
| Parameters: | fname : str
n : int, optional
with_tail : str, optional
with_wc : str, optional
|
|---|---|
| Returns: | list
|