Code Monkey home page Code Monkey logo

fingerprinter-py's Introduction

Fingerprinter (Python)

Take fingerprints (md5) of files in specified folder, recursively.

Optionally:

  • Compare with previous snapshots and report on any changes (i.e. added, changed, or deleted files).
  • Run a continuous watch, cycling every 600sec (configurable).

Quick Start

Clone the repo and run the file using all defaults. The current folder will be scanned and the output (json) file (output.json) will be saved in the .fingerprint-data folder:

$ git clone https://github.com/balain/fingerprinter-py.git
$ python fingerprinter.py
$ cat .fingerprint-data/output.json

Getting Started

Prerequisites

The things you need before installing the software:

  • Python3
  • venv (optional but recommended)

Installation

To run this program:

$ git clone https://github.com/balain/fingerprinter-py.git

Options

Using argparse

❯ python fingerprinter.py --help
usage: fingerprinter.py [-h] -p PATH [-o OUTPUT] [-d DATA_DIR] [-t] [-x EXCLUDE] [-w] [-wp WATCH_PERIOD] [-s SQLITE_FILENAME] [-v]

options:
  -h, --help            show this help message and exit
  -p PATH, --path PATH  Path to scan (default: ".")
  -o OUTPUT, --output OUTPUT
                        Output json file (not including extension; default: "output")
  -d DATA_DIR, --data-dir DATA_DIR
                        Data directory (where the json file is saved; default: ".fingerprint-data")
  -t, --timing          Capture execution time
  -x EXCLUDE, --exclude EXCLUDE
                        Folders to exclude (default: ['.git', '.venv', '.idea', 'bin', 'Include', 'include', 'Lib', 'lib', 'Scripts', 'scripts', 'output.json'])
  -w, --watch           Watch for changes and update output json
  -wp WATCH_PERIOD, --watch-period WATCH_PERIOD
                        How many seconds to wait between scans (default 600)
  -s SQLITE_FILENAME, --sqlite-filename SQLITE_FILENAME
                        Filename to save output to sqlite database (default: unset)
  -v, --verbose         Verbose output```

## Usage

A few examples of useful commands and/or tasks:

### Use defaults

Scan the current folder:

```bash
$ python fingerprinter.py

Using additional parameters

Scan the current folder, exclude .git folder(s), output to parent.json in the output-files folder (created if it doesn't already exist):

$ python fingerprinter.py -p .. -x git -o parent.json -d output-files

Sample Output

Run it again, saving it to ./junk/junk.json; Exclude gi, gii, and git files/folders.

The output shows two new files, no deleted files, and two changed files, including the python source file. It also shows the prior and latest timestamps (in the meta object).

❯ python fingerprinter.py -p . -o junk -d junk -x gi -x gii -x git
MD5 checksums saved to junk/junk.json
{'new': ['junk/junk-latest-diff.json', 'junk/junk-1723254528-diff.json'],
 'deleted': [],
 'changed': ['fingerprinter.py', 'junk/junk.json'],
 'meta': {'old': '2024-08-09T21:48:48', 'new': '2024-08-09T21:50:01'}}

Features

Implemented

  • Implement alternative (optional) sqlite storage

TODOs

  • Generate sample timings
  • Implement diff calculation with sqlite database
  • Optimize sqlite updates (e.g. batch/chunk if > some large threshold)

Other Similar or Related Projects

  • fingerprinter-rs: Rust port (uses sha256; fewer features but much (!) faster).
  • fingerprinter: Original Typescript version. No longer maintained.

License

MIT - https://mit-license.org

Copyright © 2024 John D. Lewis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fingerprinter-py's People

Contributors

balain avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.