core Package
core Package
The core package includes the modules implementing the MVC system.
application Module
Provides the Application class, in charge of managing the different
application states.
-
class vinstall.core.application.Application(view, first_stage)[source]
Bases: object
Small implementation of a state pattern for managing the application
flow. Must be intialized with the controller class implementing the first
stage of the application. This class takes the control from there, and
guides the process until the final stage, collecting the data provided by
the user and executing the commands provided by the controller objects
in the final stage.
-
handle_command()[source]
Push the command into the processing queue
We use the temporary list in self.commands so we can handle “previous” properly.
-
handle_process()[source]
Handle the process method of the current controller
-
import_view_module()[source]
Get the view module and import it into the global namespace.
-
next(*args)[source]
Jump to the next step of the application, processing the current
state first.
-
previous(*args)[source]
Jump to the previous state of the application.
-
process_queue()[source]
Build a processing object and process the commands queue.
There are two cases to handle. If the function provided by the user
is a generator function, we initialize it using the user input as
arguments and we use the result of yield to build a command object,
pushing it to the processing queue. If it is a regular function,
we push a tuple of (func, args).
-
run()[source]
Run the application. This method will import the view module first,
and start the UI loop.
-
set_callbacks()[source]
Set the next and previous controller as callbacks of the window’s
next and previous buttons.
-
show()[source]
Present the current state of the application to the user.
-
stop()[source]
Stop the application.
command Module
Command Pattern
-
class vinstall.core.command.BatchProcessor(input_queue, output_queue=None)[source]
Bases: vinstall.core.observer.Observable, threading.Thread
Process items in a thread and notify observers.
Subscribers can connect to these signals:
- “job-start”: The processing of the input queue started
- “job-end”: All the items in the queue have been processed
- “item-process-start”: Emited before a single item is processed
- “item-process-end”: Emited after a single item processing finished
-
items_processed()[source]
The aproximated size of the already finished items
-
process_item(item)[source]
Process a single item.
-
run()[source]
Overrides Thread.run
-
signals = ('process-item-start', 'process-item-end', 'job-start', 'job-end')
-
class vinstall.core.command.BatchProcessorTestCase(methodName='runTest')[source]
Bases: unittest.TestCase
-
testRun()[source]
-
class vinstall.core.command.Command(func, *args, **kwargs)[source]
Bases: object
-
class vinstall.core.command.CommandTestCase(methodName='runTest')[source]
Bases: unittest.TestCase
-
testCommand()[source]
-
class vinstall.core.command.ProcessingFacade(input_queue, observer=None)[source]
Bases: object
-
add_command(func, *args, **kwargs)[source]
Create a Command instance and add it to the stack.
-
execute_all()[source]
Execute all the commands and notify subscribers.
-
class vinstall.core.command.ProcessingFacadeTestCase(methodName='runTest')[source]
Bases: unittest.TestCase
-
testAddCommand()[source]
Create a Command instance and add it to the stack.
-
testExecuteAll()[source]
-
testObserver()[source]
controller Module
Provides a base class for controllers.
-
class vinstall.core.controller.Controller[source]
Bases: object
Base class for defining the controller interface, there is no real need
for subclassing this.
-
next()[source]
Return the class implementing the next stage.
-
previous()[source]
Return the class implementing the previous stage.
-
process(*args)[source]
Callback executed with the form values as arguments.
-
render()[source]
This method returns a Render object.
core Module
Utilities for declaring classes as views of certain model.
-
exception vinstall.core.core.RegistryError[source]
Bases: exceptions.Exception
Exception raised for registry errors.
-
vinstall.core.core.get_main_window()[source]
Returns the main window for a given view
-
vinstall.core.core.get_view(model)[source]
Answer with a view registered for the given model
-
vinstall.core.core.main_window(cls)[source]
Class decorator for registering a main window
-
vinstall.core.core.renders(model)[source]
Returns a class decorator that can be used for registering a view
against certain model.
log Module
A logging facility for Vinstall.
-
vinstall.core.log.get_logger(name, level=10)[source]
Get a logger, used just to avoid duplication of these line.
Call it with __main__ as argument.
model Module
Classes representing option types.
-
class vinstall.core.model.BoolOption(name, short_desc=None, help_text=None)[source]
Bases: object
User is expected to provide a boolean value.
-
class vinstall.core.model.ExclusiveOptionList(*options)[source]
Bases: object
User is expected to select one option from a list.
-
append(option)[source]
Append an option to the list.
-
class vinstall.core.model.IPAddress(name, short_desc=None, help_text=None)[source]
Bases: object
Internet Protocol model.
-
class vinstall.core.model.NumericOption(name, minvalue=0, maxvalue=0, short_desc=None, help_text=None)[source]
Bases: object
User is expected to provide a numeric value.
-
class vinstall.core.model.SimpleText(text, short_desc=None, help_text=None)[source]
Bases: object
informative text label.
-
process = False
-
class vinstall.core.model.TextOption(name, maxlen=0, short_desc=None, help_text=None)[source]
Bases: object
User is expected to provide data in form of text.
observer Module
Observer implementation
-
class vinstall.core.observer.Observable[source]
Bases: object
Implement some methods for subscribing callables to events.
-
connect(signal, func, *args, **kwargs)[source]
Connect a callable object to a signal.
- Parameters:
signal: a signal registered in cls.signal
func: a callable object that will be executed when signal is
emited.
Any extra parameters will be passed to the connected callable,
after the object affected by the signal.
-
disconnect(signal, func)[source]
Disconnect a callable conected to the given signal.
- Parameters:
- signal: a signal registered in cls.signal
func: a connected callable object.
-
emit(signal, obj)[source]
Emit a signal and execute its callbacks.
-
signals = []
render Module
The render module provides a Render class, which responsibility is to
allow access to the view objects at runtime.
-
class vinstall.core.render.Render(title, intro, *options)[source]
Bases: object
Given a set of model objects, find the proper view and setup window
properties.
-
get_renderer(model)[source]
Given a model, return its view.
-
get_user_input()[source]
Get the widgets state. Used by controller instances for getting user
input. The _process attribute in renderers are set by the core module,
and they indicate if the widget provides a value entered by the user or
not (for example, simple text labels do not provide any value, and they
are not processed by the controller.process method)
-
get_widgets()[source]
Get the list of configured widgets.
-
main_window[source]
Lazy initialization of the main window object.
-
setup_widgets()[source]
Initialize the widgets for each model.
-
update_main_window()[source]
Update the attributes of the main window instance and refresh the
view.
view Module
User interface abstraction layer.
Deprecated in favor of the core module.
-
class vinstall.core.view.View[source]
Bases: object
Base class for views
-
accept()[source]
This method should return the main widget, usually a container
widget. The widget returned by this method will be added directly to
the main window.
-
configure()[source]
The configure method should setup the widget or widgets that are
components of this view. Use this method for setting widget properties,
adding components to a container widget and anything you need to
represent the model properly.
-
connect()[source]
The connect method must provide a way for adding observers.
Sometimes this method can delegate its responsibility to another one,
for example the connect method in a gtk widget.
This methodisnot needed in the Urwid implementation.
-
get_value()[source]
Returns the value entered by the user.
-
main_window = None
-
renders[source]
The renders class attribute must reference the model class that this
class will render.
-
show()[source]
the show method makes all the widgets visible. It’s not needed in
the Urwid implementation.
-
views = set([])