jaffle.app.base

BaseJaffleApp

class BaseJaffleApp(app_name, jaffle_conf, jaffle_port, jaffle_status)[source]

Base class for Jaffle apps.

completer_class

The completer class for the interactive shell. It is required only if the app supports interactive shell.

lexer_class

The lexer class for the interactive shell. It is required only if the app supports interactive shell.

classmethod command_to_code(app_name, command)[source]

Converts a command comes from jaffle attach <app> to a code to be executed.

If the app supports jaffle attach, this method must be implemented.

Parameters:
  • app_name (str) – App name defined in jaffle.hcl.
  • command (str) – Command name received from the shell of jaffle attach.
Returns:

code – Code to be executed.

Return type:

str

execute_code(code, *args, **kwargs)[source]

Executes a code.

Parameters:
  • code (str) – Code to be executed. It will be formateed as code.format(*args, **kwargs).
  • args (list) – Positional arguments to code.format().
  • kwargs (dict) – Keyward arguments to code.formmat().
Returns:

future – Future which will have the execution result.

Return type:

tornado.gen.Future

execute_command(command, logger=None)[source]

Executes a command.

Parameters:
  • command (str) – Command to be executed.
  • logger (logging.Logger) – Logger.
Returns:

future – Future which will have the execution result.

Return type:

tornado.gen.Future

execute_job(job_name)[source]

Executes a job.

Parameters:job_name (str) – Job to be executed.
Returns:future – Future which will have the execution result.
Return type:tornado.gen.Future

Utility Functions

capture_method_output(method)[source]

Decorator for an app method to capture standard output and redirects it to the logger. stdout and stderr are logged with level INFO and WARNING respectively.

Parameters:method (function) – Method to be wrapped.