vispa package

Subpackages

Submodules

vispa.browser module

vispa.browser.append_to_session(key, value)

Adds a value to a list in the session

vispa.browser.client_agent()
vispa.browser.client_ip()
vispa.browser.client_referer()
vispa.browser.delete_session()
vispa.browser.get_session_value(key)
vispa.browser.has_session_value(key)
vispa.browser.set_session_value(key, value=None)
vispa.browser.update_to_session(key, data)

vispa.rest module

Dispatcher and controller for implementing a REST api in cherrypy.

class vispa.rest.RESTDispatcher(dispatch_method_name=None, translate='x00x01x02x03x04x05x06x07x08tnx0bx0crx0ex0fx10x11x12x13x14x15x16x17x18x19x1ax1bx1cx1dx1ex1f _______________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____x7fx80x81x82x83x84x85x86x87x88x89x8ax8bx8cx8dx8ex8fx90x91x92x93x94x95x96x97x98x99x9ax9bx9cx9dx9ex9fxa0xa1xa2xa3xa4xa5xa6xa7xa8xa9xaaxabxacxadxaexafxb0xb1xb2xb3xb4xb5xb6xb7xb8xb9xbaxbbxbcxbdxbexbfxc0xc1xc2xc3xc4xc5xc6xc7xc8xc9xcaxcbxccxcdxcexcfxd0xd1xd2xd3xd4xd5xd6xd7xd8xd9xdaxdbxdcxddxdexdfxe0xe1xe2xe3xe4xe5xe6xe7xe8xe9xeaxebxecxedxeexefxf0xf1xf2xf3xf4xf5xf6xf7xf8xf9xfaxfbxfcxfdxfexff')

Bases: cherrypy._cpdispatch.Dispatcher

Dispatches request to handler functions that are decorated with resolvers. Use it in conjunction with the RESTController class. Example:

class Controller(RESTController):

    @POST("user/:id(^\d+$)/name/:name")
    def set_user_name_by_id(self, id, new_name):
        pass

    @POST("user/:name/name/:name")
    def set_user_name_by_name(self, name, new_name):
        pass

Calls to POST /user/4/name/tom will be routed to the first handler, calls to POST /user/tom/name/tim to the second one. Thus, the order of handler definitions is important for the dispatcher to take precedence rules into account.

find_handler(path)

Implements cherrypy.dispatch.Dispatcher.find_handler(path).

find_node(path)

Trails the handler tree to find the correct RESTController instance.

class vispa.rest.RESTController

Bases: object

RESTController that should be used in conjunction the a RESTDispatcher. It’s only task is to prepare handlers at the end of its initialization.

vispa.rest.GET(fmt)
vispa.rest.POST(fmt)
vispa.rest.DELETE(fmt)

vispa.server module

class vispa.server.AbstractExtension(server)

Bases: object

Base class for Extensions

add_controller(controller)

Mount a CherryPy controller using the extension name for path.

Parameters:controller – filename relative to extension directory
add_workspace_directoy(directory='workspace')

Add files to be transferred to the worker.

Parameters:directoy – directory relative to extension directory
clear_workspace_instance(name, key=None, user=None, workspace=None, db=None)
config()
create_topic(topic='', view_id=None)
dependencies()

Return a list of Extension names this Extension depends on.

get_workspace_instance(name, key=None, user=None, workspace=None, db=None, **kwargs)
name()

Return the name of the Extension. This name is used as part of the URL.

setup()

Setup the extension.

class vispa.server.Server(**kwargs)

Bases: object

application()
extension(name)
extensions()
run()
start()

vispa.socketbus module

class vispa.socketbus.Bus
received_message(msg, window_id)
send(window_id=None, user_id=None, data=None, except_sessions=None, binary=False, encode_json=True, broadcast=False)
send_topic(topic, *args, **kwargs)
subscribe(topic, handler)
unsubscribe(topic, handler=None)
class vispa.socketbus.CleanerThread(*kargs, **kwargs)

Bases: threading.Thread

run()
class vispa.socketbus.PollingPublisher(window_id, user_id)
fetch(timeout=None)
received_message(msg)
send(data, binary=False, timeout=None)
class vispa.socketbus.SocketPublisher
vispa.socketbus.add_session(window_id, user_id, publisher)
vispa.socketbus.get_polling_publisher(window_id, user_id)
vispa.socketbus.remove_session(window_id, delay=False)

vispa.url module

Functions to translate a relative path into a valid url

vispa.url.clean(url)

Clean the url, multiple fix slashes and strip whitespaces

vispa.url.dynamic(*parts, **kwargs)

Create an absolute URL to non static content, e.g. controllers

vispa.url.join(*args)

Join all parameters into one clean url path.

vispa.url.static(*parts, **kwargs)

Create an absolute URL to static content, e.g. images

vispa.version module

vispa.workspace module

Functions to connect and control connections to workers

class vispa.workspace.Connection(userid, workspaceid, host, **kwargs)

Bases: object

CONNECTED = 2
CONNECTING = 1
DISCONNECTED = 0
DISCONNECTING = 3
STATUS_MESSAGES = {0: 'disconnected', 1: 'connecting', 2: 'connected', 3: 'disconnecting'}
active()
close()
connected(timeout=10)
errors()
host()
open(**kwargs)
poll()
rpyc()
send_status()
static send_workspace_status(userid, workspaceid, status)
status(new_status=None)
stdin()
stdout()
tempdir()
class vispa.workspace.ConnectionPool

Bases: object

SERVE_CONNECTION_INTERVAL = 0.2
clear(user=None, workspace=None)
connect(user, workspace, password=None)
connections_of_user(user)

Returns a list of tuples: (workspaceId, connection)

get(user, workspace, **kwargs)
get_workspace_connections(user, workspaces)

return a list of tuples with the workspace and the assosiated connection or None

class vispa.workspace.InstancePool

Bases: object

clear(user=None, workspace=None, classname=None, key=None)
get(_user, _workspace, classname=None, key=None, init_args=None, **kwargs)
class vispa.workspace.LocalConnectionFeeder

Bases: threading.Thread

callbacks = {}
run()
class vispa.workspace.LocalConnectionImpl(command, **kwargs)

Bases: object

close()
print_stderr(timeout=0)
set_on_feed(cb)
stream()
writeln(data)
class vispa.workspace.LoggingService(conn)

Bases: rpyc.core.service.Service

exposed_log(name, level, msg)
exposed_send(*args, **kwargs)
class vispa.workspace.SSHConnectionImpl(command, address, missing_host_key_policy='warning', **kwargs)

Bases: object

An SSH transport for Pushy, which uses Paramiko.

TIMEOUT = 30
address2host_port(host)
close()
print_stderr()
set_on_feed(cb)
stream()
writeln(data)
class vispa.workspace.WrappedChannelFile(file_, how)

Bases: object

close()
fileno()
vispa.workspace.add_directory_files(local, remote, **kwargs)
vispa.workspace.add_package_files(pkg, target=None)
vispa.workspace.add_remote_file(localfile, remotefile)
vispa.workspace.add_remote_files(files)
vispa.workspace.clear_instance(classname, key=None, user=None, workspace=None, db=None)

Remove all instances of type classname from the pool

vispa.workspace.connect(workspace, user=None, db=None, password=None)

Connect the selected workspace.

vispa.workspace.directory_files(local, remote, **kwargs)
vispa.workspace.disconnect(workspace=None, user=None, db=None)

Disconnect the selected workspace and remove all pooled instances.

vispa.workspace.disconnect_all(user=None, db=None)

Disconnect all workspaces and pooled instances of the selected user.

vispa.workspace.get_instance(classname, key=None, user=None, workspace=None, db=None, init_args=None)

Returns a pooled reference to a class instance of type classname.

vispa.workspace.module(modulename, user=None, workspace=None, db=None)

Returns a reference to a remote module

vispa.workspace.package_files(pkg, target_path, **kwargs)

vispa.wsgi module

vispa.wsgi.application(environ, start_response)

Module contents

Basic functionality for the VISPA platform

exception vispa.AjaxException(message, code=None, alert=True)

Bases: exceptions.Exception

AjaxException that is handled by the ajax tool and that can be raised in controller methods. message is the error message to show. code should be an integer that represents a specific type of exception. If code is None and message is an integer representing a http status code, the error message is set to the standard error message for that http error. If alert is True, the message is shown in a dialog in the GUI.

class vispa.Netstat

Bases: object

Parses /dev/net/tcp to determine which user owns the specified port

static get_socket_owner(local_ip, local_port, remote_ip, remote_port)

Returns the system id of the local user which established the specifiec connection

Parameters:
  • local_ip – ip address of the local peer
  • local_ip – port the local peer
  • remote_ip – ip address of the remote peer
  • remote_ip – port the remote peer
Return type:

user id of the user who opened this port or None

class vispa.VispaConfigParser(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False)

Bases: ConfigParser.SafeConfigParser

vispa.codepath(*args)
vispa.configpath(*args)
vispa.datapath(*args)

returns the path relative to the datapath

vispa.dump_thread_status(f=None)
vispa.dump_thread_status_on_signal(signal, stack)
vispa.exception_string()
vispa.fire_callback(topic, *args, **kwargs)
vispa.log_exception()
vispa.publish(topic, *args, **kwargs)
vispa.register_callback(topic, callback)
vispa.send_mail(addr, subject='', content='', sender_addr=None, smtp_host=None, smtp_port=None)

Send an email.

All arguments should be Unicode strings (plain ASCII works as well).

Only the real name part of sender and recipient addresses may contain non-ASCII characters.

The email will be properly MIME encoded and delivered though SMTP to localhost port 25. This is easy to change if you want something different.

The charset of the email will be the first one out of US-ASCII, ISO-8859-1 and UTF-8 that can represent all the characters occurring in the email.

vispa.set_codepath(p)
vispa.set_configpath(p)
vispa.set_datapath(p)
vispa.setup_thread_dump()
vispa.subscribe(topic, callback)
vispa.thread_stacktraces()