- The callbacks returned by
Worker.work()
now have the following new attributes:func
: The function executedargs
: The positional argument givenkwargs
: The keyword arguments givenpoll
: A function which returns True if the function has completed execution and is ready to return a result
This class serves as an argparse
type checker useful for providing as a type argument
to argparse.ArgumentParser.add_argument
. FileType
checks that the user's provided
filepath is a valid file with one of the allowed extensions, then returns either
the absolute filepath or a file handle
This class serves as an argparse
type checker useful for providing as a type argument
to argparse.ArgumentParser.add_argument
. DirType
checks that the user's provided
filepath is a valid directory, then returns the absolute filepath
This class serves as an argparse
type checker useful for providing as a type argument
to argparse.ArgumentParser.add_argument
. FOFNType
checks that the provided argument
is a valid filepath which contains a list of files. Arguments to the constructor
of FOFNType
configure what is acceptable as a member of the FOFN and how to return
the files
- Fixed the progress bar not displaying properly when encrypting/decrypting multiple files at the same time
- Fixed exceptions not being raised until all other jobs had finished. Exceptions will now be raised immediately and shutdown the ProcessWorker
- Set the file argument to the
agutil.status_bar
constructor to default toNone
. During initialization, if file isNone
, it becomessys.stdout
. This allowsstatus_bar
to be affected by changes tosys.stdout
Feature Removal:
- The
maf2bed
utility and its associated code has been removed
Deprecation Notice:
agutil.io.QueuedSocket
is now deprecated in favor ofagutil.io.MPlexSocket
agutil.split_iterable
is now also available asagutil.clump
which was chosen as it more clearly describes the function.agutil.split_iterable
may be removed in a future release, but this is not yet planned- Added a function
agutil.splice
which takes a iterable of at least 2 dimensions (M rows by N columns) and returns an iterable for each column (N iterables of length M). agutil.byteSize
now supports yottabytes- Added
agutil.context_lock
method, which enforces a timeout when acquiring a native lock - New exceptions:
agutil.TimeoutExceeded
andagutil.LockTimeoutExceeded
This class has been added to manage a timeout over a set of operations. Specifically, to enforce that several blocking operations all complete within the given timeout. The enforcement is not automatic, but relies on checking the timeout when possible
- The class has been rewritten to integrate with the builtin
logging
module
- Added a
passthrough()
method which takes one argument and returns it unchanged while incrementing the bar by 1. - Added a file argument to the
status_bar()
constructor
- The
accept()
method now takes asocket_type
argument to determine which type of Socket in theagutil
socket class tree will be returned. The method also takes a variable number of keyword arguments which will be passed to the returned socket's constructor. The method defaults to returningagutil.io.Socket
instances
- Deprecation Notice:
agutil.io.QueuedSocket
is now deprecated in favor ofagutil.io.MPlexSocket
. The latter provides the same interface but in a lighter-weight and threadless manner. - The constructor no longer takes an
agutil.io.Socket
as argument, but instead takes an address and port, likeagutil.io.Socket
- Outgoing messages are no longer sent in a FIFO order. The socket will continuously rotate through all channels waiting to send messages, sending one message from each (in FIFO).
This class provides the same interface as agutil.io.QueuedSocket
but does so without
the use of background threads. It is meant to serve as a drop-in replacement, but
due to the significance of the change, it was written as a new class.
agutil.security.SecureSocket
now derives from this class
- Added
configure_cipher
, a utility method for generating aCipherHeader
based on settings provided as keyword arguments - Added
agutil.security.encryptFileObj
andagutil.security.decryptFileObj
methods. These methods take the same arguments asagutil.security.encryptFile
andagutil.security.decryptFile
methods except that they take file-like objects instead of filenames - Updated cipher used by
agutil-secure
.- To Encrypt/Decrypt files in the old format, use the new
-l\--legacy
flag.
- To Encrypt/Decrypt files in the old format, use the new
- Removed the
-f\--force
flag fromagutil-secure
- Changed the arguments for
agutil.security.encryptFile
,agutil.security.encryptFileObj
,agutil.security.decryptFile
, andagutil.security.decryptFileObj
- Added the following exceptions:
CipherError
HeaderError
HeaderLengthError
InvalidHeaderError
EncryptionError
Decryptionerror
- The constructor no longer takes an
agutil.io.Socket
as an argument, but instead takes an address and port, likeagutil.io.Socket
- This class now derives from
agutil.io.MPlexSocket
instead ofagutil.io.QueuedSocket
- Added sign argument to
sendRSA()
.sendRSA()
andrecvRSA()
now handle signature validation internally - SecureSocket now uses
agutil.security.EncryptionCipher
andagutil.security.EncryptionCipher
as backends forsendAES()
andrecvAES()
.
- This class has been overhauled to be more efficient, and mostly threadless.
- The retries argument of the
send()
function has been removed - Added a
confirm()
method to await confirmation from the remote socket that a task has been completed - Removed the timeout argument from
close()
andshutdown()
Added the EncryptionCipher
class, which is a configurable cipher that provides
the AES encryption backend for agutil-secure
and the agutil.security
module.
Added the DecryptionCipher
class, which is a configurable cipher that provides
the AES decryption backend for agutil-secure
and the agutil.security
module.
Added the CipherHeader
class, which stores the configuration of an EncryptionCipher
or DecryptionCipher
and can be used to produce the 16-byte cipher header representing the configuration
Added the Bitmask
class to allow reading and manipulating a single-byte bitmask
using pythons []
indexing API. This class uses an agutil.search_range
to perform
underlying bit manipulations and queries
The following change has been made to the agutil.parallel
module:
- The WORKERTYPE constants,
WORKERTYPE_THREAD
andWORKERTYPE_PROCESS
, have been updated to reference the actual worker classes,ThreadWorker
andProcessWorker
, instead of being enumerations for the types. The consequence is that the parallelization decorators and dispatchers can now be given any class which follows the worker interface (see changes to dispatchers below for details)
- The workertype argument to the constructor may now be any object which follows the
worker interface. It still defaults to a
ThreadWorker
- Added
Iterdispatcher.dispatch
as the preferred method for operating the dispatcher, but operates identically toIterDispatcher.run
- The workertype argument to the constructor may now be any object which follows the
worker interface. It still defaults to a
ThreadWorker
- Fixed
setup.py
to allow installation using pip >=10 and python <3.6
- Switched from using
PyCrypto
toPyCryptodomeX
. The former library is no longer maintained and the latter is nearly a drop-in replacement.
Deprecation Warning:
- The
maf2bed
utility, and its associated code, is now deprecated and will be removed in a future release
- Fixed
setup.py
to allow source builds on pip 10
The following change has been made to the agutil
module:
- Added
first()
function to return the first element of an iterable matching a given predicate
The following change has been made to the agutil.security
module:
- The padding scheme has been changed to be more cryptographically secure while maintaining compatibility with the old padding scheme
The following changes have been made to agutil.status_bar
:
- The value argument to
status_bar.update()
is now optional. If omitted, the status bar will be incremented by one - Added a
status_bar.iter()
class method. The goal of this function is to serve as a wrapper for iterables to add a status bar to any loop
The following changes have been made to agutil.parallel
:
-
parallelize
andparallelize2
must now be called when used as decoratorsExample:
@parallelize()
or@parallelize(12)
-
parallelize
andparallelize2
now take a workertype argument to set if parallelization will be thread or process based.agutil.parallel.WORKERTYPE_THREAD
: Use for thread-based parallelization (default)agutil.parallel.WORKERTYPE_PROCESS
: Use for process-based parallelization. Note: Processed-based parallelization has several limitations; see note below
-
agutil.parallel.Dispatcher
has been refactored and renamed toagutil.parallel.IterDispatcher
, but mostly follows the same syntax -
Added
agutil.parallel.DemandDispatcher
to be the dispatching backend foragutil.parallel.parallelize2
instead of relying on heavy logic within the function -
Added
agutil.parallel.ThreadWorker
to manage worker threads for thread-based parallelization -
Added
agutil.parallel.ProcessWorker
to manage worker processes for process-based parallelization
Process-based parallelization has several limitations due to the implementation
of the builtin pickle
module:
- You CANNOT use
paralellize
orparallelize2
as decorators. You must call them on a pre-defined function and assign the result to a function with a different name. - You CANNOT use
parallelize
orparallelize2
on a function created within another function's closure. You must call them on globally accessible functions
Example usage:
def foo(arg):
return arg + 1
bar = parallelize(workertype=WORKERTYPE_PROCESS)(foo)
Thread-based parallelization does not suffer these limitations and therefore
both parallelize
and parallelize2
can be used as decorators and on function-local
objects when using WORKERTYPE_THREAD (default)
- Fixed an issue with the packaged distribution
Added a new agutil.parallel
module which includes the following:
agutil.parallel.Dispatcher
, a class which produces generators to yield values returned by background threads executing tasks in parallel.agutil.parallel.parallelize
, a decorator function to wrap a function with anagutil.parallel.Dispatcher
and yield from the Dispatcher's resultsagutil.parallel.parallelize2
, a decorator function to dispatch calls on background threads and return a callback to get the value.
Note: Due to inherent issues with CPython, this system is not suited for CPU bound tasks. I/O bound tasks will, however, be able to benefit from thread-based parallelization.
Feature Removal:
tsvmanip
has been dropped fromagutil
The following changes have been made to the agutil
module:
- Added a
agutil.byteSize()
method to convert a number of bytes to a human-readable string - Added a new convenience method,
agutil.hashfile()
, to simplify hashing files - Added a new convenience method,
agutil.cmd()
, to simplify executing shell commands programatically. - Added two classes for simple shell interaction:
agutil.ShellReturnObject
andagutil.StdOutAdapter
, which hold shell command output and capture live output, respectively. These classes are designed to work together to supportagutil.cmd()
but may also be used independently
This class acts to record any data written to its file descriptor.
After constructing a new StdOutAdapter
instance, other programs may write to StdOutAdapter.writeFD
.
This class represents the results of executing a command from the shell using agutil.cmd()
.
The following change has been made to the agutil.status_bar
class:
- The show_percent parameter to the constructor now defaults to
True
The following change has been made to the agutil.security.SecureConnection
class:
savefile()
timeout now applies to each chunk of the file. The operation will block so long as the remote socket sends at least one chunk per timeout period.
The following changes have been made to the agutil-secure
console script:
- The multiple input files can now be provided. This allows
agutil-secure
to handle globs - Added a
--version
argument to print the current version and exit
The following change has been made to the maf2bed
console script:
- Added a
--version
argument to print the current version and exit
tsvmanip
and its associated code has been removed from the agutil.bio
package
The following changes have been made to agutil.security.SecureConnection
:
- Fixed the listener thread crashing when receiving commands rapidly
- Sped up reading messages with
SecureConnection.read()
. The function will immediately return if there is already a message waiting
The following change has been made to agutil.security.SecureSocket
:
- AES and RSA methods now reserve temporary channels for communications.
This change improves thread safety by making AES/RSA methods appear to be atomic
network operations (ie:
sendAES()
now sends exactly one message over the provided channel).
Deprecation Warning:
tsvmanip
is now considered deprecated and will be removed in2.0.0
The following changes have been made to the agutil-secure
console script:
- The password parameter is now optional. By default,
agutil-secure
will now prompt the user for a password (in a secure manner) if it is not provided. When prompting for a password, the characters typed will not display on screen (unless the secure method of password input is not available on your platform, in which case a warning will be displayed that passwords will be visible). Passwords can still be provided on the command line with -p <password> or --password <password>. Passwords provided as command line arguments will still be visible. - The output parameter is now optional. By default,
agutil-secure
will now perform operations in-place, overwriting the input file with the new data. Use -o <filename> or --output <filename> to save the output tofilename
agutil-secure
now validates files before decrypting. If the password is incorrect, decryption halts and returns a status code of1
. Must use -f parameter to decrypt files encrypted with previous versions ofagutil-secure
- Added -f/--force option to maintain compatibility with previous versions.
Use -f if decryption fails when decrypting files encrypted with old versions of
agutil-secure
- Added -v/--verbose option to display the progress of the current operation
The following change has been made to both agutil.security.encryptFile
and agutil.security.decryptFile
:
- Added a validate argument (defaults to
False
):- For
encryptFile
, if validate isTrue
, encrypt and prepend 16 known bytes to the beginning of the output file. - For
decryptFile
, if validate isTrue
, decrypt the first 16 bytes of the file and check against the expected value. If the bytes match the expectation, discard them and continue decryption as normal. If the bytes do not match, raise aKeyError
- For
Documentation errors fixed. Automated release system required new versions bumped to push changes to pypi
- Added a flush() method
security.SECURECONNECTION The following change has been made to the agutil.security.secureconnection api:
- Added a flush() method
The following changes have been made to the agutil.status_bar
api:
- Status bar now supports the context manager protocol. The bar is immediately initialized on entry, and automatically cleared on exit
- The
status_bar.clear()
method now defaults to erase=True - Fixed a bug which occurs when running a status bar in reverse, where trailing percent signs would be left as the display shortened
The following changes have been made to the SecureConnection
API:
- The timeout parameter for the
read()
,savefile()
,shutdown()
, andclose()
methods now default to -1. A value of -1 for the timeout uses the default timeout provided in the constructor.
The following change has been made to the SecureSocket
API:
- The constructor timeout parameter is now required to be None or a non-negative integer. A TypeError is raised otherwise.
-
The
agutil
module includes theLogger
class, which provides a simple interface for quick logging. Messages can be logged over specific channels, and each channel can be set to log to a file, stdout, neither, or both. The actualLogger
instance is meant to be the point of control for the log. Allagutil
classes which support logging will log messages through the lambda returned byLogger.bindToSender()
. -
Note:
agutil
also includesDummyLog
, a default log used in otheragutil
classes which does no actual logging or printing
The following change has been made to the agutil.status_bar
api:
- The transcript parameter has been removed from the constructor. The status_bar no longer supports logging a transcript of activity.
The following change has been made to the agutil.io.QueuedSocket
API:
- A logmethod parameter has been added to the constructor
The following change has been made to the agutil.security.SecureConnection
API:
- A logmethod parameter has been added to the constructor, and the verbose parameter has been removed
The following change has been made to the agutil.security.SecureSocket
API:
- A logmethod parameter has been added to the constructor, and the verbose parameter has been removed
The following change has been made to the agutil.security.SecureServer
API:
- A logmethod parameter has been added to the constructor, and the childverbose parameter has been removed
- The
agutil.security
module provides a command line interface for encrypting and decrypting files.
-
agutil.intToBytes(num, padding_length=0)
-
agutil.bytesToInt(num)
-
agutil.byte_xor(b1, b2)
-
agutil.split_iterable(seq, length)
- The
agutil.io
module includes the classQueuedSocket
which wraps a regularagutil.io.Socket
class. QueuedSocket
instances are designed to allow multiple threads to utilize the same socket by dividing data across multiple channels.- The
.send()
and.recv()
methods now take an (optional) additional channel argument compared to the methods on a regularagutil.io.Socket
instance (API below)..send()
and.recv()
will send and receive data across the specified channel.
The following change has been made to the agutil.io.Socket
API:
- Added a
gettimeout
method to get the timeout of the underlying socket
The following change has been made to the agutil.security.SecureSocket
API:
-
The previous
agutl.security.SecureSocket
class has been removed and replaced with a completely overhauled class. For a class similar to the oldSecureSocket
see:SecureConnection
. -
The
agutil.security
module includes theSecureSocket
class, which wraps over anagutil.io.Socket
instance. ASecureSocket
class allows for encrypted communications using RSA or AES encryption.
- The
agutil.security
module includes theSecureConnection
class which provides a high-level interface for sending and receiving secure messages and files. All tasks are run in background threads, each exchanging data over a different channel on the underlying SecureSocket, allowing for many simultaneous tasks to be run.
- The
agutil.security
module includes theSecureServer
class, which is similar to theagutil.io.SocketServer
class, but it returnsSecureConnection
instances instead ofSocket
instances.
- The
agutil.security
module includes two methods for file encryption and decryption:encryptFile()
anddecryptFile()
.
The following change has been made to the agutil.security.SecureSocket
api:
agutil.security.new()
can be used as an alias to construct a SecureSocket
- security.NEW (method) The agutil.security module includes the new() method, which is a wrapper for the SecureSocket constructor. new() can be used to construct both ends of a SecureSocket connection, without the need for two methods with different API's. new() is the preferred method for constructing a SecureSocket, and so the actual constructor will not be documented
Changes prior to 0.4.0b are not recorded