Skip to main content

The mdfmonitor can monitoring the file modification.

Project description

mdfmonitor - Monitor the file moification
#####################################

The **mdfmonitor** is Python module about monitoring files modification using timestamp and body.

The **mdfmonitor** contains:

+ **FileModificationMonitor**
+ **URLModificationMonitor**

FileModificationMonitor
=================

This FileModificationMonitor (call this *monitor* from now) can monitor to a **file** or files modification.

Monitor has the repository of file's **timestamp** data and **body** data.
And monitor appends each data, then monitor **compare** new data to old data.
If new data **differ** to old data, monitor **regard** this difference to **modification**.
Then monitor create instance of FileModificationObject, yield this.

How to Use
------------

It's simple.

1. Import this module.
2. Create `FileModificationMonitor` class's instance.
3. Append file or files to instance using add_file method.
4. using Python for sentence, You can write anything under for sentence.

::

#!/usr/bin/python

import os
from mdfmonitor import FileModificationMonitor

files = os.listdir(".") # >>> ['sample.txt', 'sample.py']

# create Watcher instnce
monitor = FileModificationMonitor()

# append file to mdfmonitor instance
monitor.add_file("sample.txt")

# or
# append files to mdfmonitor instance
monitor.add_files(os.listdir("."))

for mdf in monitor.monitor():

print mdf.file.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_mtime
print "New timestamp: %s" % mdf.new_mtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff


URLModificationMonitor
=================

This URLModificationMonitor (call this *monitor* from now) can monitor to **body of url** or urls modification.

This monitor's structure **almost same** to FileModificationMonitor.
Both monitor just difference is to time data what compare.
FileModificationMonitor gets a file **timestamp**, URLModificationMonitor gets the `Date` header's **date** of server.


How to Use
-------------

It's simple too.

1. Import this module.
2. Create `URLModificationMonitor` class's instance.
3. Append url string or url string's list to instance using add_url method.
4. using Python for sentence, You can write anything under for sentence.

::

#!/usr/bin/python

import os
from mdfmonitor import URLModificationMonitor

files = os.listdir(".") # >>> ['sample.txt', 'sample.py']

# create Watcher instnce
monitor = URLModificationMonitor()

# append file to mdfmonitor instance
monitor.add_url("http://sampe.com/path/")

for mdf in monitor.monitor():

print mdf.url.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_dtime
print "New timestamp: %s" % mdf.new_dtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff

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

mdfmonitor-0.1.2b.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

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