Glasswall Python Wrapper
Project description
Glasswall Python Wrapper
A high level Python wrapper for interfacing with Glasswall libraries.
Getting Started
Install via pip:
pip install glasswall
Prerequisites
Examples
Loading a Glasswall Library
Currently the following libraries are supported:
- ArchiveManager
- Editor
- Rebuild
- SecurityTagging
- WordSearch
import glasswall
editor = glasswall.Editor(library_path=r"C:\azure\sdk.editor\2.173")
>>> 2021-03-15 12:27:42.337 glasswall INFO __init__ Loaded Glasswall Editor version 2.173 from C:\azure\sdk.editor\2.173\windows-drop-no-kill-switch\glasswall_core2.dll
library_path
can be a path to a directory or a path to a file. When a directory is specified all subdirectories are recursively searched for the library file with the latest creation time.
Logging
Logs are saved in the OS-specific temp directory and are also output to console with a default logging level of INFO. You can view the file path of the temp directory or the log file:
import glasswall
print(glasswall._TEMPDIR)
print(glasswall.config.logging.log_file_path)
>>> C:\Users\ANGUSR~1\AppData\Local\Temp\glasswall
>>> C:\Users\ANGUSR~1\AppData\Local\Temp\glasswall\logs\2021-03-15 122826.txt
The logging level can be modified, for a list of levels see: https://docs.python.org/3/library/logging.html#logging-levels
import logging
import glasswall
# Modify logging level for logs to the console
glasswall.config.logging.console.setLevel(logging.DEBUG)
# Modify logging level for logs to file
glasswall.config.logging.log.setLevel(logging.DEBUG)
Protecting a directory
If no content management policy is provided then the default sanitise
all policy is used.
import glasswall
editor = glasswall.Editor(library_path=r"C:\azure\sdk.editor\2.173")
editor.protect_directory(
input_directory=r"C:\test_files",
output_directory=r"C:\test_files_sanitised"
)
Protecting a directory with a customised content management policy
Using glasswall.content_management.policies.Editor
:
import glasswall
editor = glasswall.Editor(library_path=r"C:\azure\sdk.editor\2.173")
editor.protect_directory(
input_directory=r"C:\test_files",
output_directory=r"C:\test_files_sanitised",
content_management_policy=glasswall.content_management.policies.Editor(
config={
"pptConfig": {
"internal_hyperlinks": "allow",
"macros": "disallow",
},
"wordConfig": {
"internal_hyperlinks": "allow",
"macros": "disallow",
}
}
)
)
Using a custom .xml
file:
import glasswall
editor = glasswall.Editor(library_path=r"C:\azure\sdk.editor\2.173")
editor.protect_directory(
input_directory=r"C:\test_files",
output_directory=r"C:\test_files_sanitised",
content_management_policy=r"C:\configs\config.xml"
)
Built With
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for glasswall-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 768e2d603e614c6ec6d2fb8d2453e9ad08c2aa4a8fa29a699805203f128aad0f |
|
MD5 | 0c560b47954c8dc00eb4ae6f7a17513f |
|
BLAKE2b-256 | ac58ac1408e6549175fa1783e0554e80a90a9fedfc333e6a3f67385c70d827b1 |