bexchange.server package¶
Submodules¶
bexchange.server.backend module¶
- class bexchange.server.backend.HandledFiles(limit=500)[source]¶
Bases:
object
Keeps track of recently handled files. Probably should be either a sqlite db or a dictionary variant with an aged limit.
- class bexchange.server.backend.SimpleBackend(confdirs, nodename, authmgr, db_uri, source_db_uri, odim_source_file, tmpfolder=None)[source]¶
Bases:
Backend
A backend taking care of the exchange
- Parameters:
engine_or_url – an SqlAlchemy engine or a database url
storage – a ~.storage.FileStorage instance to use.
- add_configuration_file(f, runtime=False)[source]¶
Adds the configuration from a configuration file to the system. :param f: The filename containing the configuration in json format :param runtime: If the configuration is added at startup (False) or during operational run (True)
- classmethod from_conf(conf)[source]¶
create an instance from configuration parameters are looked up under ‘baltrad.exchange.server’.
- get_server_publickey()[source]¶
- Returns:
the public crypto key in PEM encoding that can be used by recipient to verify messages with
- get_server_uptime()[source]¶
- Returns:
the server uptime as a tuple of (days, hours, minutes, seconds)
- get_tmp_folder()[source]¶
Returns the global temporary folder name if defined :return the temporary folder name
- initialize_configuration(confdirs)[source]¶
Initializes the configuration from each dir :param confdirs: a list of directories where the configuration (.json) files can be found
- metadata_from_file(path)[source]¶
creates metadata from the file :param path: full path to the file :returns the metadata
- metadata_from_file_bdb(path)[source]¶
creates metadata from the file by adding it to the bdb :param path: full path to the file :returns the metadata
- metadata_from_file_internal(path)[source]¶
creates metadata from the file :param path: full path to the file :returns the metadata
- post_message(json_message, nodename)[source]¶
ensures that a posted message arrives to interested parties :param json_message: The json message :type path: string :param nodename: The origin that sent the message
- process_conf_dir(d)[source]¶
process one configuration dir. Will scan for all .json files in provided directory and determine if the files can be used for configuration or not. :param d: a directory containing configuration files
- processor_modified(fname, o)[source]¶
Called when a processor configuration file is modified., :param fname: the filename affected :param o: the actual processor
- processor_removed(fname, o)[source]¶
Called when removing a processor during runtime operation :param fname: the filename affected :param o: the actual processor
- publication_modified(fname, o)[source]¶
Called when a publication configuration file is modified., :param fname: the filename affected :param o: the actual publication
- publication_removed(fname, o)[source]¶
Called when removing a publication during runtime operation :param fname: the filename affected :param o: the actual publication
- publish(sid, path, meta)[source]¶
publishes the file on each interested publisher :param sid: The subscription id if any :param path: full path to the file to be published :param meta: meta of file to be published
- read_bdb_sources(odim_source_file)[source]¶
Reads and parses the odim sources :param odim_source_file: file containing the odim source definitions :returns a list of odim sources
- runner_modified(fname, o)[source]¶
Called when a runner configuration file is modified., :param fname: the filename affected :param o: the actual runner
- runner_removed(fname, o)[source]¶
Called when removing a runner during runtime operation :param fname: the filename affected :param o: the actual runner
- storage_modified(fname, o)[source]¶
Called when a storage configuration file is modified., :param fname: the filename affected :param o: the actual storage
- storage_removed(fname, o)[source]¶
Called when removing a storage during runtime operation :param fname: the filename affected :param o: the actual storage
- store_file(path, nid)[source]¶
handles an incomming file and determines if it should be managed by the subscriptions or not. :param path: the full path to the file to be handled :param nodename: the name/id of the node that the file comes from :returns the metadata from the file
- class bexchange.server.backend.config_handler(removed, modified, o)[source]¶
Bases:
object
Helper class that is registered for all configuration files so that it is possible to handle runtime changes.
- class bexchange.server.backend.monitor_conf_dir_inotify_handler(folders, fn_file_written, fn_file_removed)[source]¶
Bases:
ProcessEvent
Helper class to monitor a list of folders containing configuration files. Only will process files ending with .json. Both added and removed events will be forwarded.
- FILE_PATTERN = '.+.json$'¶
- MASK = 712¶
- match_file(filename)[source]¶
Matches the file so that it is following the wanted pattern. Typically *.json. :param filename: the filename that should be verified.
- process_IN_CLOSE_WRITE(event)[source]¶
Will be called by the inotify notifier when file event occurs. :param event: The file event
- process_IN_DELETE(event)[source]¶
Will be called by the inotify notifier when file event occurs. :param event: The file event
- process_IN_MOVED_FROM(event)[source]¶
Will be called by the inotify notifier when file event occurs. :param event: The file event
bexchange.server.sqlbackend module¶
- class bexchange.server.sqlbackend.SqlAlchemySourceManager(uri='sqlite:///tmp/baltrad-exchange-source.db', poolsize=10)[source]¶
Bases:
object
The DB manager providing source handling :param uri: The uri to database where sources are stored :param poolsize: the size of the db connection pool. In the case of sqlite, this will not be used
- add_sources(srclist)[source]¶
Adds the sources to the source database :param srclist: a list of bdbcommon.oh5.Sources
- property driver¶
database driver name
- Type:
return
- get_parent_source(parent)[source]¶
- Parameters:
parent – The id of the parent.
- Returns:
The parent source matching the string in parent.
bexchange.server.subscription module¶
- class bexchange.server.subscription.subscription(storages, subscription_id=None, active=True, ifilter=None, allow_duplicates=False, allowed_ids=[])[source]¶
Bases:
object
- filter_matching(meta)[source]¶
Matches the meta against the filter. :param meta: The metadata :return True if filter is None or if metadata matches the filter.
- class bexchange.server.subscription.subscription_manager[source]¶
Bases:
object
- classmethod create_subscription(storages, subscription_id, active, ifilter, allow_duplicates, allowed_ids)[source]¶
Creates a subscription instance :param storages: List of storage names :param subscription_id: Subscription id :param active: If subscription should be set to active or not :param ifilter: A filter instances :param allow_duplicate: If duplicates should be allowed or not :param allowed_ids: A list of ids that should be allowed for this subscription