Access Watch
Access Watch is a Python script designed to retrieve and display file access information, such as last access time and file ownership details, on both Linux and Windows systems. The script utilizes OS-specific modules to gather this information, making it versatile and suitable for cross-platform environments.
Features
- Retrieve and display the last access time of a file.
- Display the file owner's user ID and group ID
- Convert user ID to username and group ID to group name.
- Cross-platform support: Works on both Linux and Windows.
LinuxAccessWatch
The LinuxAccessWatch class is designed to monitor and retrieve file information related to user access in a Linux environment. It provides methods to obtain metadata such as the last access time, owner UID, owner GID, owner username, and owner group name of a specified file or directory.
Methods
get_file_stats() -> None: Gathers file statistics including last access time, owner UID, and owner GID.get_owner_uid() -> Optional[int]: Retrieves the user ID (UID) of the file owner.get_owner_gid() -> Optional[int]: Retrieves the group ID (GID) of the file owner.uid_to_username() -> str: Converts the owner UID to a human-readable username.gid_to_groupname() -> str: Converts the owner GID to a human-readable group name.get_last_access_time() -> Optional[str]: Returns the last access time of the file in a human-readable format.get_username() -> str: Retrieves the username of the file owner.get_groupname() -> str: Retrieves the group name of the file owner.
Usage
from accesswatch.linux import LinuxAccessWatch
access_watch = LinuxAccessWatch("/path/to/file_or/directory")
last_access_time = access_watch.get_last_access_time()
# Sat Sep 21 10:48:05 2024
owner_uid = access_watch.get_owner_uid()
# id
owner_gid = access_watch.get_owner_gid()
# id
username = access_watch.get_username()
# username
groupname = access_watch.get_groupname()
# usergroup
WindowsAccessWatch
WindowsAccessWatch is a class designed to monitor and retrieve information about file access on Windows systems. It tracks the last access time of a file, retrieves the owner Security Identifier (SID), and converts this SID into a human-readable account name, domain name, and account type.
Methods
__init__(file_path): Initializes theWindowsAccessWatchobject with the file path and retrieves the owner SID.set_owner_sid(): Sets the owner SID for the specified file or directory.get_file_stats(): Retrieves the last access time and owner SID of the file.get_last_access_time(): Returns the last access time in a human-readable format.get_owner_sid(): Returns the owner SID of the file.get_owner_sid_string(): Returns the owner SID as a string in a human-readable format.sid_to_username_info(sid): Converts a given SID to a username, domain name, and account type.user_access_info(): Retrieves the account name, domain name, and account type for the file owner.
Usage
from accesswatch.windows import WindowsAccessWatch
access_watcher = WindowsAccessWatch("/path/to/file_or/directory")
last_access_time = access_watcher.get_last_access_time()
owner_sid = access_watcher.get_owner_sid_string()
account_name, domain_name, account_type = access_watcher.user_access_info()
Contributing
Contributions are welcome!
Github: https://github.com/mahdikhoshdel/accesswatch.git
Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
License
This project is licensed under the MIT License.
Metadata
Release files for accesswatch 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| accesswatch-1.0.3.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| accesswatch-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.3 kB
Release files / accesswatch-1.0.3.tar.gz
| Download URL | accesswatch-1.0.3.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b85f94cd8e6ad00ba23799ff9bd4ac64cec8f6328b4b6ad3e56020cfeea5f64
|
|
BLAKE2b-256 checksum How to use checksums |
beabb446bf910440d5f5b3125da0f9c4c68905b2489fd7e45c98951f470c468c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Release files / accesswatch-1.0.3-py3-none-any.whl
| Download URL | accesswatch-1.0.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8af90e6f12b643664d8f251a53dd1e23bd2cd0956c58bff4df00c0e02899558c
|
|
BLAKE2b-256 checksum How to use checksums |
1db14d1c6179e76d21445493da0d9d71c802df322bcd41884839e3bd00709b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|