123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- import urllib
- import urllib2
- import json
- # Helper functions
- taskname = "test"
- address = "http://localhost:8001"
- last_output = None
- def _input(value):
- # Ugly json encoding of primitives
- value = '"%s"' if type(value) == str else value
- urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": value, "taskname": taskname})))
- def _output():
- try:
- global last_output
- last_output = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname})))
- return last_output
- except:
- raise UnknownError()
- def _output_last():
- return last_output
- # Exceptions
- class UnknownError(Exception):
- pass
- class UnknownIdentifier(Exception):
- pass
- class UnknownType(Exception):
- pass
- class UnsupportedValue(Exception):
- pass
- class CompilationError(Exception):
- pass
- class NoSuchAttribute(Exception):
- pass
- class UnknownModel(Exception):
- pass
- class ConnectionError(Exception):
- pass
- class ModelExists(Exception):
- pass
- class PermissionDenied(Exception):
- pass
- # Main MvC operations
- def init():
- """Starts up the connection to the Modelverse."""
- pass
- # return None
- # raises ConnectionError
- # raises UnknownError
- def login(username, password):
- """Log in an existing user."""
- pass
- # return None
- # raises UnknownError
- # raises PermissionDenied
- def register(username, password):
- """Register a new user."""
- pass
- # return None
- # raises UnknownError
- # raises UserExists
- def model_add(model_name, metamodel_name):
- """Instantiate a new model."""
- pass
- # return None
- # raises UnknownModel
- # raises ModelExists
- # raises UnknownError
- def model_modify(model_name):
- """Modify an existing model."""
- pass
- # return is_write
- # raises UnknownModel
- # raises PermissionDenied
- # raises UnknownError
- def model_list():
- """List all models."""
- pass
- # return [(model1, metamodel1), (model2, metamodel2), ...]
- # raises UnknownError
- def model_list_full():
- """List full information on all models."""
- pass
- # return [(model1, metamodel1, owner1, group1, permissions1), (model2, metamodel2, owner2, group2, permissions2), ...]
- # raises UnknownError
- def model_overwrite(model_name, new_model):
- """Upload a new model and overwrite an existing model."""
- pass
- # return None
- # raises UnknownModel
- # raises PermissionDenied
- # raises CompilationError
- # raises UnknownError
- # Actual operations on the model
- def list():
- """Return a list of all IDs and the type of the element"""
- pass
- # return [(name1, type1), (name2, type2), ...]
- # raises UnknownError
- def types():
- """Return a list of all types usable in the model"""
- pass
- # return [type1, type2, ...]
- # raises UnknownError
- def read(ID):
- """Return a tuple of information on the element: its type and source/target (None if not an edge)"""
- pass
- # return (type, (source, target))
- # raises UnknownError
- # raises UnknownIdentifier
- def read_attrs(ID):
- """Return a dictionary of attribute value pairs"""
- pass
- # return {attr1: value1, attr2: value2, ...}
- # raises UnknownError
- def transformation_add_MT_language():
- """Create a new Model Transformation language out of a set of metamodels."""
- raise NotImplementedError()
- def transformation_add_MT():
- """Create a new model transformation."""
- raise NotImplementedError()
- def transformation_add_AL():
- """Create a new action language fragment."""
- raise NotImplementedError()
- def transformation_add_MANUAL():
- """Create a new manual model operation."""
- raise NotImplementedError()
- def transformation_execute():
- """Execute an existing model operation."""
- raise NotImplementedError()
- def transformation_list():
- """List existing model operations."""
- raise NotImplementedError()
- def transformation_list_full():
- """List detailed information on model operations."""
- raise NotImplementedError()
- def transformation_detail():
- """List full details of a a model operation."""
- raise NotImplementedError()
- def transformation_RAMify():
- """Ramify an existing metamodel."""
- raise NotImplementedError()
- def process_execute():
- """Execute a process model."""
- raise NotImplementedError()
- def permission_modify():
- """Modify permissions of a model."""
- raise NotImplementedError()
- def permission_owner():
- """Modify the owning user of a model."""
- raise NotImplementedError()
- def permission_group():
- """Modify the owning group of a model."""
- raise NotImplementedError()
- def group_create():
- """Create a new group."""
- raise NotImplementedError()
- def group_delete():
- """Delete a group of which you are an owner."""
- raise NotImplementedError()
- def group_owner_add():
- """Add a new owning user to a group you own."""
- raise NotImplementedError()
- def group_owner_delete():
- """Delete an owning user to a group you own."""
- raise NotImplementedError()
- def group_join():
- """Add a new user to a group you own."""
- raise NotImplementedError()
- def group_kick():
- """Delete a user from a group you own."""
- raise NotImplementedError()
- def group_list():
- """List existing groups."""
- raise NotImplementedError()
- def admin_promote():
- """Promote a user to admin status."""
- raise NotImplementedError()
- def admin_demote():
- """Demote a user from admin status."""
- raise NotImplementedError()
- def user_logout():
- """Log out the current user. A new login will be required afterwards."""
- pass
- # return None
- # raises UnknownException
- def user_delete():
- """Removes the current user. A new login will be required afterwards."""
- pass
- # return None
- # raises UnknownException
- def instantiate(typename, edge=None, ID=""):
- """Create a new instance of the specified typename, between the selected elements (if not None), and with the provided ID (if any)"""
- pass
- # return instantiated_ID
- # raises UnknownError
- # raises UnknownType
- # raises UnknownIdentifier
- def delete(ID):
- """Delete the element with the given ID"""
- pass
- # return None
- # raises UnknownError
- # raises UnknownIdentifier
- def attr_assign(ID, attr, value):
- """Assign a value to an attribute"""
- pass
- # return None
- # raises UnknownError
- # raises UnknownIdentifier
- # raises NoSuchAttribute
- # raises UnsupportedValue
- def attr_assign_code(ID, attr, code):
- """Assign a piece of Action Language code to the attribute"""
- pass
- # return None
- # raises UnknownError
- # raises UnknownIdentifier
- # raises NoSuchAttribute
- # raises UnsupportedValue
- def upload(new_model):
- """Overwrite the current model with the provided model"""
- pass
- # return None
- # raises UnknownError
- # raises CompilationError
- def read_outgoing(ID, typename):
- """Returns a list of all outgoing associations of a specific type ("" = all)"""
- pass
- # return [name1, name2, ...]
- # raises UnknownError
- # raises UnknownIdentifier
- # raises UnknownType
- def read_incoming(ID, typename):
- """Returns a list of all incoming associations of a specific type ("" = all)"""
- pass
- # return [name1, name2, ...]
- # raises UnknownError
- # raises UnknownIdentifier
- # raises UnknownType
|