owtf.lib package¶
Submodules¶
owtf.lib.cli_options module¶
owtf.lib.cli_options¶
Main CLI processing machine
-
owtf.lib.cli_options.
parse_options
(cli_options, valid_groups, valid_types)[source]¶ Main arguments processing for the CLI
Parameters: - cli_options (dict) – CLI args Supplied by user
- valid_groups (list) – Plugin groups to chose from
- valid_types (list) – Plugin types to chose from
Returns: Return type:
owtf.lib.exceptions module¶
owtf.lib.exceptions¶
Declares the framework exceptions and HTTP errors
-
exception
owtf.lib.exceptions.
APIError
(status_code=500, log_message=None, *args, **kwargs)[source]¶ Bases:
tornado.web.HTTPError
Equivalent to
RequestHandler.HTTPError
except for in name
-
exception
owtf.lib.exceptions.
PluginsAlreadyLoaded
[source]¶ Bases:
owtf.lib.exceptions.PluginException
load_plugins() called twice.
-
exception
owtf.lib.exceptions.
PluginsDirectoryDoesNotExist
[source]¶ Bases:
owtf.lib.exceptions.PluginException
The specified plugin directory does not exist.
owtf.lib.filelock module¶
owtf.lib.filelock¶
Implementation of a simple cross-platform file locking mechanism. This is a modified version of code retrieved on 2013-01-01 from http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python. The original code was released under the BSD License, as is this modified version. Modifications in this version:
- Tweak docstrings for sphinx.
- Accept an absolute path for the protected file (instead of a file name relative to cwd).
- Allow timeout to be None.
- Fixed a bug that caused the original code to be NON-threadsafe when the same FileLock instance was shared by multiple threads in one process. (The original was safe for multiple processes, but not multiple threads in a single process. This version is safe for both cases.)
- Added
purge()
function.- Added
available()
function.- Expanded API to mimic
threading.Lock interface
: -__enter__
always callsacquire()
, and therefore blocks ifacquire()
was called previously. -__exit__
always callsrelease()
. It is therefore a bug to callrelease()
from within a context manager. - Addedlocked()
function. - Added blocking parameter toacquire()
method
# taken from https://github.com/ilastik/lazyflow/blob/master/lazyflow/utility/fileLock.py # original version from http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
-
class
owtf.lib.filelock.
FileLock
(protected_file_path, timeout=None, delay=1, lock_file_contents=None)[source]¶ Bases:
object
A file locking mechanism that has context-manager support so you can use it in a
with
statement. This should be relatively cross compatible as it doesn’t rely onmsvcrt
orfcntl
for the locking.-
acquire
(blocking=True)[source]¶ - Acquire the lock, if possible. If the lock is in use, and blocking is False, return False.
- Otherwise, check again every self.delay seconds until it either gets the lock or exceeds timeout number of seconds, in which case it raises an exception.
Parameters: blocking (bool) – File blocked or not Returns: True if lock is acquired, else False Return type: bool
-
available
()[source]¶ Returns True iff the file is currently available to be locked.
Returns: True if lockfile is available Return type: bool
-