folderobserver


Namefolderobserver JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/folderobserver
Summarymonitors and collects temporary files that might be created during software execution or system processes
upload_time2023-05-17 21:08:05
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords temp observer files
VCS
bugtrack_url
requirements a_pandas_ex_df_to_string a_pandas_ex_set copytool get_file_type hackycfgparser kthread_sleep pandas remtmp subprocesskiller touchtouch tqdm uffspd
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # folderobserver

## pip install folderobserver

### Tested against Windows 10 / Python 3.10 / Anaconda

### observe_folders

The observe_folders function is useful for observing and analyzing folders, with various operations performed on the files within those folders. It offers several features that can be helpful in different scenarios.

One use case is to identify and retrieve temporary files. By specifying the folders to scan, you can monitor and collect temporary files that might be created during software execution or system processes. This can be particularly useful for analyzing and managing temporary data, ensuring efficient use of disk space, or identifying potential security risks associated with leftover temporary files.

Additionally, the function allows you to copy files from the observed folders to a destination folder. This can be helpful for creating backups or organizing files for further analysis or processing. You can choose to include additional information such as the file's last modified date or file permissions during the copying process.

Furthermore, the function supports the creation of flat copies of files. Flat copies involve extracting files from nested folder structures and placing them all in a single destination folder, using a specified separator to differentiate the original file paths. This feature can simplify file organization and facilitate bulk processing or analysis of files.

Moreover, the function provides the ability to guess the file types of downloaded files. By analyzing the file extension and content, it can make educated guesses about the file type. This can be useful when dealing with downloaded files that might have incorrect or missing file extensions, helping to identify the actual file type and enabling appropriate handling or processing.

Overall, the observe_folders function offers a flexible and customizable approach to observing folders, performing operations on files within those folders, and extracting valuable insights from the observed data. It can be adapted to various use cases, including managing temporary files, organizing files, and analyzing downloaded files.

Calling the function
The observe_folders function can be called in two different ways: through Python code and through the command-line interface (CLI).


### Calling the function in Python:


```python

# Stop capturing by pressing ctrl+c
from folderobserver import observe_folders

df = observe_folders(
    folders_to_scan=(r"C:\Users\hansc\AppData\Local\Temp",),
    destination=r"C:\observer",
    create_flatcopy=0,
    create_flatcopy_and_guess_img_type=0,
    flatcopy_sep="#",
    logfile=r"C:\observerlog.csv",
    clean_tmp_files_before=0,
    verbose=0,
    copy_date=0,
    copy_permission=0,
    overwrite=1,
    use_tqdm=1,
    sleep_between_scans=1,
    file_mb_limit=50,
    ignore_already_copied=1,
)
In this example, you import the observe_folders function from the folderobserver module. Then, you call the function with various parameters to configure its behavior. The function returns a DataFrame (df) containing the observed and processed data.
```


### Calling the function through the CLI:

```python

In this example, you run the observe_folders function by executing a Python script through the CLI. The script (__init__.py) receives a configuration file (config.ini) as a command-line argument. The configuration file contains the parameters for the observe_folders function. The function reads the parameters from the configuration file and executes accordingly.

Both methods allow you to customize the behavior of the observe_folders function by providing different parameters such as the folders to scan, destination folder, flat copy options, logging options, and more. Adjust these parameters according to your specific requirements.

Configuration file example
Here's an example of a configuration file (config.ini) that can be used when calling the observe_folders function through the CLI:

# Stop capturing by pressing ctrl+c
.\python.exe "..\__init__.py" config.ini


[folders]
folders_to_scan: ('C:\Users\hansc\AppData\Local\Temp',)
destination: C:\observer
create_flatcopy: 1
create_flatcopy_and_guess_img_type: 1
flatcopy_sep: #
logfile: C:\observerlog.csv
clean_tmp_files_before: 1
verbose: 0
copy_date: 0
copy_permission: 0
overwrite: 1
use_tqdm: 1
sleep_between_scans: 1
file_mb_limit: 50
ignore_already_copied: 1


In this example, the configuration file (config.ini) is structured using INI format. It consists of sections enclosed in square brackets ([]), followed by key-value pairs. The folders section contains the following key-value pairs:

folders_to_scan: Specifies the folders to scan. In this example, it scans the folder C:\Users\hansc\AppData\Local\Temp.
destination: Specifies the destination folder for copied files. In this example, it is set to C:\observer.
create_flatcopy: Determines whether to create flat copies of the files. Set to 1 (True) in this example.
create_flatcopy_and_guess_img_type: Determines whether to create flat copies and guess image types. Set to 1 (True) in this example.
flatcopy_sep: Specifies the separator for flat copies. In this example, it is set to #.
logfile: Specifies the path to the log file. In this example, it is set to C:\observerlog.csv.
clean_tmp_files_before: Determines whether to clean temporary files before scanning. Set to 1 (True) in this example.
verbose: Determines whether to enable verbose output. Set to 0 (False) in this example.
copy_date: Determines whether to copy the last modified date of files. Set to 0 (False) in this example.
copy_permission: Determines whether to copy file permissions. Set to 0 (False) in this example.
overwrite: Determines whether to overwrite existing files. Set to 1 (True) in this example.
use_tqdm: Determines whether to use tqdm progress bar. Set to 1 (True) in this example.
sleep_between_scans: Specifies the sleep duration between scans (in seconds). In this example, it is set to 1.
file_mb_limit: Specifies the maximum file size limit in megabytes (MB). In this example, it is set to 50.

You can modify the values in the configuration file according to your specific requirements before executing the observe_folders function through the CLI.

Please note that the INI configuration file format is commonly used for storing configuration settings and can be easily edited using a text editor.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/folderobserver",
    "name": "folderobserver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "temp,observer,files",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/29/bd/361e706a36eff7c47ee0b73189f94b22546441402bb78d6dd0097140a70c/folderobserver-0.11.tar.gz",
    "platform": null,
    "description": "# folderobserver\r\n\r\n## pip install folderobserver\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n### observe_folders\r\n\r\nThe observe_folders function is useful for observing and analyzing folders, with various operations performed on the files within those folders. It offers several features that can be helpful in different scenarios.\r\n\r\nOne use case is to identify and retrieve temporary files. By specifying the folders to scan, you can monitor and collect temporary files that might be created during software execution or system processes. This can be particularly useful for analyzing and managing temporary data, ensuring efficient use of disk space, or identifying potential security risks associated with leftover temporary files.\r\n\r\nAdditionally, the function allows you to copy files from the observed folders to a destination folder. This can be helpful for creating backups or organizing files for further analysis or processing. You can choose to include additional information such as the file's last modified date or file permissions during the copying process.\r\n\r\nFurthermore, the function supports the creation of flat copies of files. Flat copies involve extracting files from nested folder structures and placing them all in a single destination folder, using a specified separator to differentiate the original file paths. This feature can simplify file organization and facilitate bulk processing or analysis of files.\r\n\r\nMoreover, the function provides the ability to guess the file types of downloaded files. By analyzing the file extension and content, it can make educated guesses about the file type. This can be useful when dealing with downloaded files that might have incorrect or missing file extensions, helping to identify the actual file type and enabling appropriate handling or processing.\r\n\r\nOverall, the observe_folders function offers a flexible and customizable approach to observing folders, performing operations on files within those folders, and extracting valuable insights from the observed data. It can be adapted to various use cases, including managing temporary files, organizing files, and analyzing downloaded files.\r\n\r\nCalling the function\r\nThe observe_folders function can be called in two different ways: through Python code and through the command-line interface (CLI).\r\n\r\n\r\n### Calling the function in Python:\r\n\r\n\r\n```python\r\n\r\n# Stop capturing by pressing ctrl+c\r\nfrom folderobserver import observe_folders\r\n\r\ndf = observe_folders(\r\n    folders_to_scan=(r\"C:\\Users\\hansc\\AppData\\Local\\Temp\",),\r\n    destination=r\"C:\\observer\",\r\n    create_flatcopy=0,\r\n    create_flatcopy_and_guess_img_type=0,\r\n    flatcopy_sep=\"#\",\r\n    logfile=r\"C:\\observerlog.csv\",\r\n    clean_tmp_files_before=0,\r\n    verbose=0,\r\n    copy_date=0,\r\n    copy_permission=0,\r\n    overwrite=1,\r\n    use_tqdm=1,\r\n    sleep_between_scans=1,\r\n    file_mb_limit=50,\r\n    ignore_already_copied=1,\r\n)\r\nIn this example, you import the observe_folders function from the folderobserver module. Then, you call the function with various parameters to configure its behavior. The function returns a DataFrame (df) containing the observed and processed data.\r\n```\r\n\r\n\r\n### Calling the function through the CLI:\r\n\r\n```python\r\n\r\nIn this example, you run the observe_folders function by executing a Python script through the CLI. The script (__init__.py) receives a configuration file (config.ini) as a command-line argument. The configuration file contains the parameters for the observe_folders function. The function reads the parameters from the configuration file and executes accordingly.\r\n\r\nBoth methods allow you to customize the behavior of the observe_folders function by providing different parameters such as the folders to scan, destination folder, flat copy options, logging options, and more. Adjust these parameters according to your specific requirements.\r\n\r\nConfiguration file example\r\nHere's an example of a configuration file (config.ini) that can be used when calling the observe_folders function through the CLI:\r\n\r\n# Stop capturing by pressing ctrl+c\r\n.\\python.exe \"..\\__init__.py\" config.ini\r\n\r\n\r\n[folders]\r\nfolders_to_scan: ('C:\\Users\\hansc\\AppData\\Local\\Temp',)\r\ndestination: C:\\observer\r\ncreate_flatcopy: 1\r\ncreate_flatcopy_and_guess_img_type: 1\r\nflatcopy_sep: #\r\nlogfile: C:\\observerlog.csv\r\nclean_tmp_files_before: 1\r\nverbose: 0\r\ncopy_date: 0\r\ncopy_permission: 0\r\noverwrite: 1\r\nuse_tqdm: 1\r\nsleep_between_scans: 1\r\nfile_mb_limit: 50\r\nignore_already_copied: 1\r\n\r\n\r\nIn this example, the configuration file (config.ini) is structured using INI format. It consists of sections enclosed in square brackets ([]), followed by key-value pairs. The folders section contains the following key-value pairs:\r\n\r\nfolders_to_scan: Specifies the folders to scan. In this example, it scans the folder C:\\Users\\hansc\\AppData\\Local\\Temp.\r\ndestination: Specifies the destination folder for copied files. In this example, it is set to C:\\observer.\r\ncreate_flatcopy: Determines whether to create flat copies of the files. Set to 1 (True) in this example.\r\ncreate_flatcopy_and_guess_img_type: Determines whether to create flat copies and guess image types. Set to 1 (True) in this example.\r\nflatcopy_sep: Specifies the separator for flat copies. In this example, it is set to #.\r\nlogfile: Specifies the path to the log file. In this example, it is set to C:\\observerlog.csv.\r\nclean_tmp_files_before: Determines whether to clean temporary files before scanning. Set to 1 (True) in this example.\r\nverbose: Determines whether to enable verbose output. Set to 0 (False) in this example.\r\ncopy_date: Determines whether to copy the last modified date of files. Set to 0 (False) in this example.\r\ncopy_permission: Determines whether to copy file permissions. Set to 0 (False) in this example.\r\noverwrite: Determines whether to overwrite existing files. Set to 1 (True) in this example.\r\nuse_tqdm: Determines whether to use tqdm progress bar. Set to 1 (True) in this example.\r\nsleep_between_scans: Specifies the sleep duration between scans (in seconds). In this example, it is set to 1.\r\nfile_mb_limit: Specifies the maximum file size limit in megabytes (MB). In this example, it is set to 50.\r\n\r\nYou can modify the values in the configuration file according to your specific requirements before executing the observe_folders function through the CLI.\r\n\r\nPlease note that the INI configuration file format is commonly used for storing configuration settings and can be easily edited using a text editor.\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "monitors and collects temporary files that might be created during software execution or system processes",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/folderobserver"
    },
    "split_keywords": [
        "temp",
        "observer",
        "files"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ac2be56a10d7e325683e30abb7c387b832b9f2243b7716556c3460ee6e35ef0",
                "md5": "19a134c1c100e7a2462db307a3ad19d0",
                "sha256": "b0b11568327cd93ad5c944477a1a4a798b6330681a2dac7886394138b3d0eb1c"
            },
            "downloads": -1,
            "filename": "folderobserver-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19a134c1c100e7a2462db307a3ad19d0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14596,
            "upload_time": "2023-05-17T21:08:03",
            "upload_time_iso_8601": "2023-05-17T21:08:03.167523Z",
            "url": "https://files.pythonhosted.org/packages/9a/c2/be56a10d7e325683e30abb7c387b832b9f2243b7716556c3460ee6e35ef0/folderobserver-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29bd361e706a36eff7c47ee0b73189f94b22546441402bb78d6dd0097140a70c",
                "md5": "a95c4222dae87f6239cf0383a45cf102",
                "sha256": "df8eda3daea1af37576a46817e697ffcd11567793a76e4e4bb6da4c20c6368d6"
            },
            "downloads": -1,
            "filename": "folderobserver-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "a95c4222dae87f6239cf0383a45cf102",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13024,
            "upload_time": "2023-05-17T21:08:05",
            "upload_time_iso_8601": "2023-05-17T21:08:05.825385Z",
            "url": "https://files.pythonhosted.org/packages/29/bd/361e706a36eff7c47ee0b73189f94b22546441402bb78d6dd0097140a70c/folderobserver-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-17 21:08:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "folderobserver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "a_pandas_ex_df_to_string",
            "specs": []
        },
        {
            "name": "a_pandas_ex_set",
            "specs": []
        },
        {
            "name": "copytool",
            "specs": []
        },
        {
            "name": "get_file_type",
            "specs": []
        },
        {
            "name": "hackycfgparser",
            "specs": []
        },
        {
            "name": "kthread_sleep",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "remtmp",
            "specs": []
        },
        {
            "name": "subprocesskiller",
            "specs": []
        },
        {
            "name": "touchtouch",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        },
        {
            "name": "uffspd",
            "specs": []
        }
    ],
    "lcname": "folderobserver"
}
        
Elapsed time: 0.29551s