jass package

Submodules

jass.annotations_manager module

jass.custom_logger module

Custom logging module.

jass.custom_logger.logError(genException)[source]

This function will take an object of the type GenericException and log it as an error.

jass.custom_logger.logInfo(genException)[source]

This function will take an object of the type GenericException and log it as information useful for non critical errors.

jass.custom_logger.logUnknownDebug(context, msg)[source]

A simple function to display a debug into logs

Parameters:
  • msg – Custom error message to put
  • context – The context to categorize the message
jass.custom_logger.logUnknownError(context, msg, e)[source]

This function will log all non custom exceptions

Parameters:
  • msg – Custom error message to put
  • context – The context to categorize the message
  • e – Exception object
jass.custom_logger.logUnknownInfo(context, msg)[source]

A simple function to display a info into logs

Parameters:
  • msg – Custom error message to put
  • context – The context to categorize the message
jass.custom_logger.logUnknownWarning(context, msg)[source]

A simple function to display a warning into logs

Parameters:
  • msg – Custom error message to put
  • context – The context to categorize the message

jass.document_manager module

jass.error module

jass.generic_exception module

exception jass.generic_exception.GenericException(code, *args)[source]

Bases: exceptions.Exception

Exception wrapper which defines custom functionality for the JASS.

code = 0
context = 'GenericException'

jass.mongo_utils module

Various utilities for mongoDB usage.

jass.mongo_utils.changeDocIdToMongoId(jsonDoc)[source]

Changes the _id to ObjectId. Will crash if jsonDoc is not a simple JSON object with _id field

jass.mongo_utils.changeDocIdToString(mongoDoc)[source]

Changes the _id to string. Will crash if mongoDoc is not a valid Mongo Document

jass.mongo_utils.isObjectId(strId)[source]

jass.reverse_proxied module

class jass.reverse_proxied.ReverseProxied(app)[source]

Bases: object

Obtained from flask: http://flask.pocoo.org/snippets/35/

Wrap the application in this middleware and configure the front-end server to add these headers, to let you quietly bind this to a URL other than / and to an HTTP scheme that is different than what is used locally.

In nginx:

location /myprefix {
    proxy_pass http://192.168.0.1:5001;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Scheme $scheme;
    proxy_set_header X-Script-Name /myprefix;
    }
Parameters:app – the WSGI application

jass.settings module

jass.simple_rest module

jass.singleton module

class jass.singleton.Singleton(decorated)[source]

A non-thread-safe helper class to ease implementing singletons. This should be used as a decorator – not a metaclass – to the class that should be a singleton.

The decorated class can define one __init__ function that takes only the self argument. Other than that, there are no restrictions that apply to the decorated class.

To get the singleton instance, use the Instance method. Trying to use __call__ will result in a TypeError being raised.

Limitations: The decorated class cannot be inherited from.

Source: http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern

Instance()[source]

Returns the singleton instance. Upon its first call, it creates a new instance of the decorated class and calls its __init__ method. On all subsequent calls, the already created instance is returned.

jass.storage_exception module

exception jass.storage_exception.AnnotationException(code, *args)[source]

Bases: jass.generic_exception.GenericException

Exceptions when manipulating Annotations

codeToMessage = {0: 'Unexpected Exception', 1: 'Invalid document object Id {0}', 2: 'Annotation: {0} in batch is missing a context for doc {1}', 3: 'Invalid document id detected: {0}, operation aborted.', 4: 'Annotation: {0} in batch is missing a required field for doc {1}', 5: 'Format {0} is not supported', 6: 'StorageType: {0} is not initialized ', 7: 'StorageType: {0} is not supported ', 8: 'Number of inserted annotations is not equal to the number of annotations in batch: {0} vs {1}', 9: 'Some of the document IDs have invalid format.'}
context = 'Annotation Storage Annotation'
exception jass.storage_exception.MongoDocumentException(code, *args)[source]

Bases: jass.generic_exception.GenericException

Exceptions occurring when Manipulating an object in MongoDB,

codeToMessage = {0: 'Unexpected Exception', 2: 'Storage document should not be empty.', 3: 'Storage document is missing the required @context field', 4: 'Storage document contains a reserved field : {0}', 5: 'Storage Document with id : {0} not found for update'}
context = 'Annotation Storage Document'
exception jass.storage_exception.StorageException(code, *args)[source]

Bases: jass.generic_exception.GenericException

Exceptions related to the functionality of the MongoDB database itself

codeToMessage = {1: 'Failed to connect to MongoDB', 2: 'Unexpected delete fail to MongoDB'}
context = 'Annotation Storage Storage'
exception jass.storage_exception.StorageRestExceptions(code, *args)[source]

Bases: jass.generic_exception.GenericException

Exception related to the rest part of the program

codeToMessage = {0: 'ErrorCode not supported. Please contact administrator if you see this error.', 1: 'Inconsistent document. The id contained in the document is not the same as the one called.', 2: 'Did not found the document requested', 3: 'Can not update document since the id described does not exist.', 4: 'The id supplied is not located in Human Storage. This request only works with Human Storage.', 5: 'One of the supplied request parameters is invalid.'}

jass.storage_manager module

jass.utility_rest module

Module contents