Skip to content

Commit

Permalink
0.0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-e committed May 1, 2019
2 parents 9f7279c + 668851c commit f74a674
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changes
=======

0.0.4 (2019-05-01)
------------------

* FEATURE: New flag ``-m``, explicitly excluding all operations from the log that do not have the potential to change the filesystem. Added for convenience.
* FIX: Terminating a notify session started in the background would not join all relevant threads properly. Terminating a notify session started in the foreground would cause an exception due to it attempting to join non-existing threads.
* Added Jupyter Notebook example to documentation.

0.0.3 (2019-05-01)
------------------

Expand Down
285 changes: 285 additions & 0 deletions docs/library_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"import pandas as pd\n",
"\n",
"import loggedfs # Python pass-through filesystem: pip install loggedfs"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"demo_filter = loggedfs.filter_pipeline_class(include_list = [loggedfs.filter_item_class([loggedfs.filter_field_class(\n",
" name = 'proc_cmd', value = re.compile('.*kate.*').match\n",
" )])]) # filter pipeline for filesystem actions coming from commands containing the string \"kate\" (the KDE text editor)\n",
"\n",
"demo_data, demo_err = [], [] # dump logging data here\n",
"\n",
"demo = loggedfs.loggedfs_notify(\n",
" 'demo_dir', # relative path to mountpoint\n",
" background = True, # log in background thread\n",
" log_filter = demo_filter, # apply filter pipeline\n",
" log_only_modify_operations = True, # only log operations that have the potential to modify the filesystem\n",
" log_buffers = True, # include read and write buffers into log\n",
" consumer_out_func = demo_data.append, # consume logging data\n",
" consumer_err_func = demo_err.append # consume potential errors\n",
" ) # MOUNT (and start logging)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"27"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"demo.terminate() # UMOUNT (and stop logging)\n",
"\n",
"assert isinstance(demo_data[-1], loggedfs.end_of_transmission)\n",
"demo_data = demo_data[:-1]\n",
"\n",
"len(demo_data)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>action</th>\n",
" <th>proc_pid</th>\n",
" <th>param_path</th>\n",
" <th>param_old_path</th>\n",
" <th>param_new_path</th>\n",
" <th>param_fip</th>\n",
" <th>param_buf_len</th>\n",
" <th>param_offset</th>\n",
" <th>param_mode</th>\n",
" <th>return</th>\n",
" <th>status</th>\n",
" </tr>\n",
" <tr>\n",
" <th>time</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1556736520813215826</th>\n",
" <td>mknod</td>\n",
" <td>30977</td>\n",
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>33188.0</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1556736520814149530</th>\n",
" <td>chmod</td>\n",
" <td>30977</td>\n",
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>33152.0</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1556736524870363873</th>\n",
" <td>mknod</td>\n",
" <td>30977</td>\n",
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>33152.0</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1556736524871304006</th>\n",
" <td>chmod</td>\n",
" <td>30977</td>\n",
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>33188.0</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1556736524872197836</th>\n",
" <td>rename</td>\n",
" <td>30977</td>\n",
" <td>NaN</td>\n",
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n",
" <td>/tmp/ernst/demo_dir/demo_file.txt</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1556736524872611868</th>\n",
" <td>unlink</td>\n",
" <td>30977</td>\n",
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" action proc_pid \\\n",
"time \n",
"1556736520813215826 mknod 30977 \n",
"1556736520814149530 chmod 30977 \n",
"1556736524870363873 mknod 30977 \n",
"1556736524871304006 chmod 30977 \n",
"1556736524872197836 rename 30977 \n",
"1556736524872611868 unlink 30977 \n",
"\n",
" param_path \\\n",
"time \n",
"1556736520813215826 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n",
"1556736520814149530 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n",
"1556736524870363873 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n",
"1556736524871304006 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n",
"1556736524872197836 NaN \n",
"1556736524872611868 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n",
"\n",
" param_old_path \\\n",
"time \n",
"1556736520813215826 NaN \n",
"1556736520814149530 NaN \n",
"1556736524870363873 NaN \n",
"1556736524871304006 NaN \n",
"1556736524872197836 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n",
"1556736524872611868 NaN \n",
"\n",
" param_new_path param_fip \\\n",
"time \n",
"1556736520813215826 NaN NaN \n",
"1556736520814149530 NaN NaN \n",
"1556736524870363873 NaN NaN \n",
"1556736524871304006 NaN NaN \n",
"1556736524872197836 /tmp/ernst/demo_dir/demo_file.txt NaN \n",
"1556736524872611868 NaN NaN \n",
"\n",
" param_buf_len param_offset param_mode return status \n",
"time \n",
"1556736520813215826 NaN NaN 33188.0 NaN True \n",
"1556736520814149530 NaN NaN 33152.0 NaN True \n",
"1556736524870363873 NaN NaN 33152.0 NaN True \n",
"1556736524871304006 NaN NaN 33188.0 NaN True \n",
"1556736524872197836 NaN NaN NaN NaN True \n",
"1556736524872611868 NaN NaN NaN NaN True "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_df = pd.DataFrame.from_records(demo_data, index = 'time')\n",
"\n",
"data_df[data_df['action'] != 'write'][['action', 'proc_pid', 'param_path', 'param_old_path', 'param_new_path', 'param_fip', 'param_buf_len', 'param_offset', 'param_mode', 'return', 'status']]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion docs/library_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Create a new directory, for instance in your current working directory, named ``
consumer_err_func = demo_err.append
)
You have just stated recording all filesystem events that involve a command containing the string ``kate``. Leave the Python shell and write some stuff into the ``demo_dir`` using ``Kate``, the KDE text editor. Once you are finished, go back to your Python shell and terminate the recording.
You have just started recording all filesystem events that involve a command containing the string ``kate``. Put the Python shell aside and write some stuff into the ``demo_dir`` using ``Kate``, the KDE text editor. Once you are finished, go back to your Python shell and terminate the recording.

.. code:: python
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


# Bump version HERE!
_version_ = '0.0.3'
_version_ = '0.0.4'


# List all versions of Python which are supported
Expand Down
13 changes: 10 additions & 3 deletions src/loggedfs/_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@
help = 'Run in library mode. DO NOT USE THIS FROM THE COMMAND LINE!',
hidden = True
)
@click.option(
'-m', '--only-modify-operations',
is_flag = True,
help = 'Exclude logging of all operations that can not cause changes in the filesystem. Convenience flag for accelerated logging.'
)
@click.argument(
'directory',
type = click.Path(exists = True, file_okay = False, dir_okay = True, resolve_path = True)
)
def cli_entry(f, p, c, s, l, json, buffers, lib, directory):
def cli_entry(f, p, c, s, l, json, buffers, lib, only_modify_operations, directory):
"""LoggedFS-python is a transparent fuse-filesystem which allows to log
every operation that happens in the backend filesystem. Logs can be written
to syslog, to a file, or to the standard output. LoggedFS-python allows to specify an XML
Expand All @@ -97,7 +102,7 @@ def cli_entry(f, p, c, s, l, json, buffers, lib, directory):

loggedfs_factory(
directory,
**__process_config__(c, l, s, f, p, json, buffers, lib)
**__process_config__(c, l, s, f, p, json, buffers, lib, only_modify_operations)
)


Expand All @@ -109,7 +114,8 @@ def __process_config__(
fuse_allowother,
log_json,
log_buffers,
lib_mode
lib_mode,
log_only_modify_operations
):

if config_fh is not None:
Expand All @@ -135,6 +141,7 @@ def __process_config__(
'log_file': log_file,
'log_filter': filter_obj,
'log_json': log_json,
'log_only_modify_operations': log_only_modify_operations,
'log_printprocessname': log_printprocessname,
'log_syslog': not log_syslog_off
}
1 change: 1 addition & 0 deletions src/loggedfs/_core/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
LOG_BUFFERS_DEFAULT = False
LOG_ENABLED_DEFAULT = True
LOG_JSON_DEFAULT = False
LOG_ONLYMODIFYOPERATIONS_DEFAULT = False
LOG_PRINTPROCESSNAME_DEFAULT = True
LOG_SYSLOG_DEFAULT = False
Loading

0 comments on commit f74a674

Please sign in to comment.