Wide Availability Peer-to-Peer File Sharing
Bytestag is a peer-to-peer (P2P) file sharing system that uses a distributed hash table (DHT) to achieve wide availability of files. Unlike the BitTorrent protocol, files are published entirely via DHT and do not require trackers or swarming. Each computer donates disk space and bandwidth for caching of published values.
This software is currently under development.
Quick and dirty platform specific base directories.
On Unix environments, XDG environment variables are used. On Windows, the environment variable %LOCALAPPDATA% is used for building paths. If neither, variables exist, the home directory variable is used. If the home variable does not exist. It uses the current directory and returns a directory in the style of .NAMESPACE.
var cache_dir: | A directory suitable for storing files that you don’t mind losing but wish to keep around for a while. One of the following:
|
---|---|
var data_dir: | A directory suitable for storing program code or plugins. One of the following:
|
var config_dir: | A directory suitable for storing program configurations. One of the following:
|
var runtime_dir: | |
A directory suitable for storing program runtime files such as Unix sockets, PID files, or named pipes. One of the following:
|
Client interfaces
Bases: threading.Thread
Client interface.
Warning : | this class is under development. |
---|
The SharedFilesKVPTable
The FnTaskSlot which holds StoreValueTask.
Event handling
Bases: builtins.object
An event ID.
This class’ comparison equality depends on the arguments given.
Bases: builtins.object
A reactor that demultiplexs events from other threads
Add an event to be dispatched
Parameters : |
|
---|
Bases: builtins.object
A mix in to provide an event_reactor property
Return the event reactor
Return type: | EventReactor |
---|
Bases: threading.Thread, bytestag.events.EventReactorMixin
Schedules events to be added to event reactors
Add an event to be scheduled at given time
Parameters : |
|
---|
Add an event to be scheduled once.
Parameters : |
|
---|
Bases: builtins.object
An event scheduler entry.
Bases: threading.Thread
Limit task execution
Executes function with given arguments.
This function blocks until the slot is not full.
Return type: | Task |
---|---|
Returns: | The Task that given fn returns. |
Bases: builtins.object
A callback manager.
Example usage:
>>> def my_function(some_arg):
... print(some_arg)
>>> observer = Observer()
>>> observer.register(my_function)
>>> observer('Observer activated!')
'Observer activated!'
Bases: builtins.object
An enhanced future.
Pass an instance of this task to concurrent.futures.Executor. Instead of using the future provided by the executor, use this instance.
Hook another task into this task.
This function should be called within the task so that stop will be propagated to the given task. Once the task finishes, it is automatically unhooked. As well, the task will update the progress.
Return the observer
The observer will callback when the task is finished.
Return type: | Observer |
---|
Bases: concurrent.futures.thread.ThreadPoolExecutor, bytestag.events.EventReactorMixin
Wraps a ThreadPoolExecutor that listens to a stop event
Keys
Bases: builtins.bytes
A fixed-width binary value that represents keys and node IDs
Compute the bucket number for two keys.
Parameters : |
|
---|---|
Return type: | int |
KeyBytes value testing
Bases: unittest.case.TestCase
Bases: unittest.case.TestCase
Networking
Bases: bytestag.network.DataPacket
A JSON data packet.
Variables: |
|
---|
Bases: bytestag.events.Task
Downloads data from a contact and returns a file object.
Bases: builtins.object
The keys used in the JSON data
Bases: bytestag.events.EventReactorMixin
Network controller
Cvariables : |
|
---|
Allow a transfer for download.
Parameters : |
|
---|---|
Return type: | |
Returns: | A future that returns a file object that may have been interrupted. The progress is the number of bytes downloaded. |
The function called when a data packet arrives.
Parameters : |
|
---|
This function is called for packets that are not replies. Implementors of this class should override this method.
Send the dict to address
Parameters : |
|
---|---|
Return type: | None, SendPacketTask |
Returns: | Returns a SendPacketTask if timeout is given. The result is either DataPacket or None. |
Send dict that is a response to a incoming data packet
Parameters : |
|
---|
Use this function to reply to packets that expect a response. This function automatically adds sequence IDs the reply packet.
Transfer data to another client.
Parameters : |
|
---|---|
See : | |
Return type: |
Transfer data to another client.
Parameters : |
|
---|---|
Return type: | |
Returns: | A future that returns an int that is the number of bytes sent. |
Bases: builtins.object
Manages the matching of sequence IDs to prevent forged UDP replies
Store the data packet reply to be retrieved be woken thread
Add an entry that expects a reply
Parameters : |
|
---|
Get the stored data packet
Return type: | DataPacket, None |
---|
Bases: bytestag.events.Task
Send a data packet and return the response.
The result returned is either None or DataPacket.
Bases: socketserver.BaseRequestHandler
UDP request handler for the UDP server
Bases: bytestag.events.EventReactorMixin, threading.Thread, socketserver.UDPServer
UDP server
Bases: bytestag.events.Task
Returns the number of bytes sent.
Bases: unittest.case.TestCase
Bases: unittest.case.TestCase
Specialized queues
Bases: builtins.object
A queue that spools onto disk when needed.
The core functionality is similar to queue.Queue.
Storage management and implementations of KVPTables
Bases: builtins.object
Types of CollectionInfo file types
Bases: bytestag.tables.KVPRecord
The record associated with DatabaseKVPTable.
Bases: bytestag.tables.KVPTable, bytestag.storage.SQLite3Mixin
A KVPTable stored as a SQLite database
Bases: bytestag.tables.KVPRecord
The record associated with MemoryKVPTable
Bases: bytestag.tables.KVPTable
A quick and dirty implementation of KVPTable
Note
This class is generally used for unit tests.
Bases: builtins.Exception
This error is raised when the table does support storing values.
Bases: builtins.object
A SQLite 3 mixin class to provide connection management
Bases: bytestag.tables.KVPRecord
The record associated with SharedFilesKVPTable.
This record describes a single file on the filesystem.
See : | SharedFileRecord |
---|
Bases: bytestag.events.Task
A task that hashes and populates a shared files table.
Variables: | progress – a tuple (str, int) describing the filename and bytes read. |
---|
Bases: bytestag.tables.KVPTable, bytestag.storage.SQLite3Mixin
Provides a KVPTable interface to shared files split into pieces.
Hash the directories and populate the table with file info.
Return type: | SharedFilesHashTask |
---|
A list directories to be shared.
Modify the list at your will, but be sure to sure to call hash_directories() as file monitoring is not yet supported.
Bases: bytestag.tables.KVPRecord
The record associated with SharedFilesKVPTable.
This record describes a single file on the filesystem.
See : | SharedFileHashRecord |
---|
Converts a byte offset to a file segment number.
Return type: | int |
---|
Bases: unittest.case.TestCase, bytestag.storage_test.TableMixin
Bases: unittest.case.TestCase
Bases: unittest.case.TestCase, bytestag.storage_test.TableMixin
Bases: unittest.case.TestCase, bytestag.storage_test.TableMixin
It should hash the files in each directory
Key-value pair management
Bases: bytestag.tables.KVPTable
Combines several KVPTable
Bases: bytestag.tables.KVPID
The components of a key.
Variables: |
---|
Bases: builtins.object
Information about a key-value pair
Bases: builtins.object
A base class for key-value tables.
This table supports Python idioms for add and removing values:
table[kvpid] = b'123'
kvpid in table
del table[kvpid]
Return the indicies associated with the key.
Return type: | list |
---|---|
Returns: | a list of indices KeyBytes |