bexchange.net package¶
Submodules¶
bexchange.net.connections module¶
- class bexchange.net.connections.backup_connection(backend, arguments)[source]¶
Bases:
publisher_connectionBackup connection, expects a list of senders in arguments. Where all senders are run.
- class bexchange.net.connections.combined_connection(backend, arguments)[source]¶
Bases:
publisher_connectionCombined connection is a way to combine different connection types into one so that you for example can have different connections in one. For example, assume that you always wants a file to be sent to a specific target and then that you want a sequence of fail over connections after that.
- class bexchange.net.connections.connection_manager[source]¶
Bases:
objectThe connection manager is used for creating connection instances from the provided configuration
- class bexchange.net.connections.distributed_connection(backend, arguments)[source]¶
Bases:
publisher_connectionDistributed connection, expects a list of senders in arguments. Where all senders are run. This is the same behavior as the backup connection but it’s here for readability.
- class bexchange.net.connections.failover_connection(backend, arguments)[source]¶
Bases:
publisher_connectionFailover connection, expects a list of senders in arguments. Where they are tried in order until one works.
- publish(path, meta)[source]¶
Publishes the file using the senders. When first successful publishing has successfully been transmitted, the method returns. If on the other hand no senders are successfully used an exception will be thrown. :param path: The path to the file :param meta: The metadata of the file
- class bexchange.net.connections.publisher_connection(backend)[source]¶
Bases:
objectpublisher connections are used for publishing files in various ways without taking the protocol / sender into account. Each (or most) publisher_connection is associated with one or more senders.
- class bexchange.net.connections.simple_connection(backend, arguments)[source]¶
Bases:
publisher_connectionSimple connection, only parsing arguments according to. sender class + arguments.
bexchange.net.fetchers module¶
- class bexchange.net.fetchers.baseuri_fetcher(backend, aid, arguments)[source]¶
Bases:
fetcherBase class for fetching data using basic file transmission protocols like sftp, ftp, …
- class bexchange.net.fetchers.baseuri_patternmatching_fetcher(backend, aid, arguments)[source]¶
Bases:
baseuri_fetcherBase class for fetching data using basic file transmission protocols like sftp, ftp, …
- class bexchange.net.fetchers.copy_fetcher(backend, aid, arguments)[source]¶
Bases:
fetcherFetcher file(s) using copy
- class bexchange.net.fetchers.fetcher(backend, aid)[source]¶
Bases:
objectBase fetcher. All classes implementing this should provide ability to fetch files in some way.
- class bexchange.net.fetchers.fetcher_manager[source]¶
Bases:
objectCreates fetcher instances from a configuration entry
- class bexchange.net.fetchers.ftp_fetcher(backend, aid, arguments)[source]¶
Bases:
baseuri_patternmatching_fetcherFetcher file(s) using scp
- class bexchange.net.fetchers.scp_fetcher(backend, aid, arguments)[source]¶
Bases:
baseuri_patternmatching_fetcherFetcher file(s) using scp
- class bexchange.net.fetchers.sftp_fetcher(backend, aid, arguments)[source]¶
Bases:
baseuri_patternmatching_fetcherFetcher files using sftp
bexchange.net.publishers module¶
- class bexchange.net.publishers.pubQueue(qs)[source]¶
Bases:
objectWrapper around queue.Queue to be able to shutdown. This will be supported in python 3.13 but for now this will be enough.
- get(waittime=10)[source]¶
Returns an item from the queue. The wait time is the time in seconds the thread should wait in the condition until checking for any new item in the queue. This condition will be notified whenever put or shutdown is called. :param waittime: The time to wait in seconds inside the condition :return: Will always return an item :throws: pubQueueShutdown
- exception bexchange.net.publishers.pubQueueShutdown[source]¶
Bases:
Exceptionthrown to indicate that an entry already exists
- class bexchange.net.publishers.publisher(backend, name, active, origin, ifilter, connections, decorators)[source]¶
Bases:
objectBase class used by all publishers
- active()[source]¶
Returns if this publication is active or not :return: if this publication is active or not
- publish(file, meta)[source]¶
publishes a file
- Parameters:
file – The temp file instance
meta – The metadata
- Returns:
metadata extracted from the file
- class bexchange.net.publishers.publisher_manager[source]¶
Bases:
objectThe manager used for creating publishers from configuration
- classmethod create_publisher(name, clz, backend, active, origin, filter, connections, decorators, extra_arguments)[source]¶
Creates an instance of clz with specified arguments :param clz: class name specified as <module>.<classname> :param arguments: a list of arguments that should be used to initialize the class
- class bexchange.net.publishers.standard_publisher(backend, name, active, origin, ifilter, connections, decorators, extra_arguments)[source]¶
Bases:
publisherStandard publisher used for most situations. Provides two arguments. One is threads. The other is queue_size.
- consumer()[source]¶
The consumer called by the individual threads. Will grab one entry from the queue and pass it on to the connections.
- handle_consumer_file(tmpfile, meta)[source]¶
Will handle the file that the consumer retrieved from the queue :param self: self :param tmpfile: the tmp file :param meta: the meta data
bexchange.net.senders module¶
- class bexchange.net.senders.baseuri_sender(backend, aid, arguments)[source]¶
Bases:
senderBase class for basic file transmission protocols like sftp, ftp, …
- class bexchange.net.senders.copy_sender(backend, aid, arguments)[source]¶
Bases:
senderSends files by copying them
- class bexchange.net.senders.dex_sender(backend, aid, arguments)[source]¶
Bases:
senderLegacy DEX communication sending files to old nodes.
- class bexchange.net.senders.ftp_sender(backend, aid, arguments)[source]¶
Bases:
baseuri_senderPublishes files over ftp
- change_and_create_dir(ftp, path)[source]¶
Changes directory and creates specified directory. :param ftp: The ftp connection :param path: The path to create
- class bexchange.net.senders.noop_sender(backend, aid, arguments)[source]¶
Bases:
senderNo operation sender which just ignores sending the message and will return wanted value.
- class bexchange.net.senders.rest_sender(backend, aid, arguments)[source]¶
Bases:
senderSends a file to another node that is running bexchange. The rest sender uses the internal crypto library for signing messages which currently supports DSA & RSA keys. DSA uses DSS, RSA uses pkcs1_15.
- class bexchange.net.senders.scp_sender(backend, aid, arguments)[source]¶
Bases:
baseuri_senderPublishes files over scp
- class bexchange.net.senders.sender(backend, aid)[source]¶
Bases:
objectBase sender. All classes implementing this should send the specified file path to a recipient over a specific protocol.
- class bexchange.net.senders.sftp_sender(backend, aid, arguments)[source]¶
Bases:
baseuri_senderSends files over sftp
bexchange.net.sftpclient module¶
- class bexchange.net.sftpclient.sftpclient(host, port, username, password, timeout=30.0, banner_timeout=30)[source]¶
Bases:
objectImplementation of a sftpclient using paramiko
- chdir(dirname)[source]¶
Changes current directory on server :param dirname: The directory to change to
- get(filename, targetname)[source]¶
Fetches the file (filename) from the server and saves it as targetname. :param filename: Source filename to download :param targetname: The destination name to save as
- getfo(remotepath, fl)[source]¶
Copies the file (remotepath) from the server and writes to an open file. Typically used like: with NamedTemporaryFile() as fp: c.getfo(”….”, fp)
- Parameters:
remotepath – Source filename to download
fl – The destination file object
- isdir(path)[source]¶
Checks if the provided path is a directory or not
- Parameters:
path – Path name to check
- Returns:
if specified path is a dir or not
- isfile(path)[source]¶
- Parameters:
path – Path name to check
- Returns:
if specified path is a file or not
- listdir(dirname)[source]¶
Lists files and directories in the directory :param dirname: The directory to list :return a list of names
- makedirs(targetdir)[source]¶
Creates the directories if they don’t exist :param targetdir: The structure to create from current wd
- put(filename, targetname, confirm=True)[source]¶
Uploads the file (filename) to the server named targetname. :param filename: Source filename to upload :param targetname: The destination name