moti package¶
Subpackages¶
- moti.utils package
- Subpackages
- Submodules
- moti.utils.connection module
- moti.utils.consumer module
- moti.utils.database_reader module
- moti.utils.handle_config module
- moti.utils.listener module
- moti.utils.misc module
- moti.utils.parser module
- moti.utils.protocol module
- moti.utils.publisher module
- moti.utils.reader module
- moti.utils.transfer module
- Module contents
Submodules¶
moti.api module¶
-
class
moti.api.API(host, port, database_url)¶ Bases:
object-
get_result(user_id, snapshot_id, result_name)¶ Parameters: - user_id (int or str) – a user id
- snapshot_id (int or str) – a snapshot id
- result_name (str) – a field name
Returns: A dictionary representing the field of the snapshot This dictionary also has a copy of all files in the dictionary found in the database on it’s top level
Return type: dict
-
get_snapshot(user_id, snapshot_id)¶ Parameters: - user_id (int or str) – a user id
- snapshot_id (int or str) – a snapshot id
Returns: A dictionary representing the snapshot
Return type: dict
-
get_snapshots(user_id)¶ Parameters: user_id (int or str) – a user id Returns: A list of all snapshots correlated to user Return type: list
-
get_user(user_id)¶ Parameters: user_id (int or str) – a user id Returns: a dictionary with all personal information of the user Return type: dict
-
get_users()¶ Returns: A list of all users in the database Return type: list
-
setup()¶ This functions uses the basic API functions changing them to a desired format and routing with flask
-
-
moti.api.generate_urls(dic, url)¶ For every path to a file in dic add an entry containing it’s designated url
Parameters: - dic (dict) – a dictionary
- url (str) – a base url string
-
moti.api.get_all_files(dic, current)¶ Iterating over current dictionary going recursivly into every dictionary inside if a key: path to file entry is found somewhere inside current then key: path to file is added to top level of dic
Parameters: - dic (dict) – a dictionary
- current (dict) – a dictionary, should be a copy of dic for first call
-
moti.api.is_file(val)¶ Parameters: val (Object) – anything Returns: True if val is an existing file, False otherwise Return type: bool
moti.cli module¶
moti.client module¶
-
moti.client.reader_to_server(snapshot)¶ Parameters: snapshot (ReaderSnapshot) – a snapshot as generated by reader Returns: client-server protocol snapshot Return type: Snapshot
-
moti.client.upload_sample(host='127.0.0.1', port='8000', path='sample.mind.gz', config=None)¶ If a config file is present set all other params to values specified in config file
This function uploads all snapshots in the provided path to the server
Parameters: - host (str(,optional)) – ip of server, defaults to ‘127.0.0.1’
- port (int or str(,optional)) – port of server, defaults to ‘8000’
- path (str(,optional)) – path to snapshots, defaults to ‘sample.mind.gz’
- config (str(,optional)) – a name of config file, defaults to None
moti.parsers module¶
-
moti.parsers.run_parser(field, data)¶ Parameters: - field (str) – name of a field
- data (encoded path) – data to parse
Returns: parsed data
Return type: json string
moti.saver module¶
-
class
moti.saver.Saver(database_url)¶ Bases:
object-
get_savers()¶ Import all savers in ./utils/savers Every saver should have ‘saver’ in the name of it’s file Only one saver per file The name of file should be in snake case The name of saver should be in camel case and the same as file’s name The saver should have ‘protocol’ variable so it can be chosen by that variable
-
save(topic, data)¶
-
moti.server module¶
-
moti.server.run_server(publish, host='127.0.0.1', port=8000)¶ Run the server
Parameters: - publish (callable) – a publish function/class
- host (str(,optional)) – the ip of the server, defaults to ‘127.0.0.1’
- port (int or str(,optional)) – the port number of the server, defaults to 8000
-
moti.server.session_handler(client, publish)¶ Handles all hello -> config -> snapshot sessions with a client
Parameters: - client (Connection) – the connection object of client
- publish – publisher function/class