biotite.application.WebApp

class biotite.application.WebApp(app_url, obey_rules=True)[source]

Bases: Application

The base class for all web based applications.

It allows for getting and setting the URL of the app and raises an RuleViolationError when a subclass calls violate_rule() (e.g. when the server was contacted too often.)

Be careful, when calling func:get_app_state(). This may involve a server contact and therefore frequent calls may raise a RuleViolationError.

Parameters
app_urlstr

URL of the web app.

obey_rulesbool, optional

If true, the application raises an RuleViolationError, if the server rules are violated. (Default: True)

app_url()

Get the URL of the web app.

Returns
urlstr

URL of the web app.

cancel()

Cancel the application when in RUNNING or FINISHED state.

clean_up()

Do clean up work after the application terminates.

PROTECTED: Optionally override when inheriting.

abstract evaluate()

Evaluate application results. Called in join().

PROTECTED: Override when inheriting.

get_app_state()

Get the current app state.

Returns
app_stateAppState

The current app state.

abstract is_finished()

Check if the application has finished.

PROTECTED: Override when inheriting.

Returns
finishedbool

True of the application has finished, false otherwise

join(timeout=None)

Conclude the application run and set its state to JOINED. This can only be done from the RUNNING or FINISHED state.

If the application is FINISHED the joining process happens immediately, if otherwise the application is RUNNING, this method waits until the application is FINISHED.

Parameters
timeoutfloat, optional

If this parameter is specified, the Application only waits for finishing until this value (in seconds) runs out. After this time is exceeded a TimeoutError is raised and the application is cancelled.

Raises
TimeoutError

If the joining process exceeds the timeout value.

abstract run()

Commence the application run. Called in start().

PROTECTED: Override when inheriting.

start()

Start the application run and set its state to RUNNING. This can only be done from the CREATED state.

violate_rule(msg=None)

Indicate that a server rule was violated, i.e. this raises a RuleViolationError unless obey_rules is false.

PROTECTED: Do not call from outside.

Parameters
msgstr, optional

A custom message for the RuleViolationError.

abstract wait_interval()

The time interval of is_finished() calls in the joining process.

PROTECTED: Override when inheriting.

Returns
intervalfloat

Time (in seconds) between calls of is_finished() in join()