Skip to main content

A tool that retrieves and displays file or directory access information In Linux and Windows

Project description

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 the WindowsAccessWatch object 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:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

accesswatch-1.0.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

accesswatch-1.0.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file accesswatch-1.0.3.tar.gz.

File metadata

  • Download URL: accesswatch-1.0.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for accesswatch-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3b85f94cd8e6ad00ba23799ff9bd4ac64cec8f6328b4b6ad3e56020cfeea5f64
MD5 322f1826847b548582df09f8206e8759
BLAKE2b-256 beabb446bf910440d5f5b3125da0f9c4c68905b2489fd7e45c98951f470c468c

See more details on using hashes here.

File details

Details for the file accesswatch-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: accesswatch-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for accesswatch-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8af90e6f12b643664d8f251a53dd1e23bd2cd0956c58bff4df00c0e02899558c
MD5 7ca2cba3f99d142546f6a72cf1f3192f
BLAKE2b-256 1db14d1c6179e76d21445493da0d9d71c802df322bcd41884839e3bd00709b22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page