DirWatcher

By Fuzzyman

Help and About and Stuff








Intro To DirWatcher

DirWatcher is the GUI for the filestruct and FSDM tool and classes. It is a simple tool that helps you keep directories in different locations in sync. I have various directories - research projects, programming projects, reference material etc - that I keep at work and at home. If DirWatcher is installed on both machines, it can profile the directories at a point when you know they are both identical. After making changes DirWatcher can reprofile the directory and save any changes as a single zipfile. If you transfer that zipfile to the other location, DirWatcher can then make all the changes for you.The two directories you are 'syncing' don't even need to have the same name. Be careful though, when DirWatcher is making changes it will delete files and directories if that is what you've done - make sure you are certain you want it to make the changes and that you are getting it to make the changes in the right place !

The GUI is written using Tkinter which is the standard GUI toolkit for Python. The actual python source code for DirWatcher (without the filestruct module) is less than 20k.






Using DirWatcher


DirWatcher is very straightforward to use. When you run it it scans all the profiles saved in the project directory (normally a subdirectory called projects). It then presents you with a listbox showing you all the profiles and their basic details - project name, the folder profiled, the size of the directory and the date and time the profile was made. You have a row of options that you can apply to each profile. You select a profile by clicking on it or by using the cursor up or down. If you hit enter or double-click on a profile then the default action will be run - this is 'save changes'.

The basics of using DirWatcher are very simple. When you profile a directory it takes a snapshot of all the files and subdirectories in it. You can reprofile the directory again later and DirWatcher will save everything that has changed in a single file. You can also take one of these files and get DirWatcher to make all the changes in it into a directory. To profile a directory for the first time use the New Profile option. To save the changes in a directory since it's last profile, use the Save Changes option. To make the changes in a directory from a 'Save Changes' file, use the Make Changes option. See below for a full explanation of all the options.

By default the project directory is a subdirectory of the folder that DirWatcher is in called 'projects'. This is where DirWatcher stores and looks for the profile files it uses. If this location isn't convenient for you you can specify an alternative directory at the command line. e.g.
python dirwatcher.pyw "../projectfiles"
launches DirWatcher with the project directory set to "../projectfiles".






New Profile

This button creates a new profile for a directory. It asks you what directory you want it to profile. It then profiles the directory. This may take sometime if the directory has a lot of files in it. Exactly how long is largely dependant on disk access times.
Indexing an 873MByte directory, with 16647 files in 668 folders took me 31.25 seconds.
With psyco enabled it only took 20.14 seconds.
A repeat of the read (most of the disk information cached) took 7 seconds.

Having profiled the directory it will ask you for a name for the profile and then save it in the projects directory. You should see the profile appear in the list on the DirWatcher window.






Delete Profile


If you select this option, DirWatcher will ask you if you are really sure. If you sure then it will delete the file from the project directory and you'll see it disappear from the DirWacther window.






Rename Profile

This option allows you to change the name of the profile.






Show Details

This shows all the details for the selected profile. It shows all the information in the DirWatcher window plus the number of files and the number of directories in the directory.






Re-Profile

If things have changed since the last time you profiled the directory - but you only want to start recording changes from now - you can hit reprofile. This effectively has the same effect as deleting the profile and doing it again - but it's a bit simpler.






Save Changes

This option is one of the most important. It reprofiles the directory and records any changes. It then asks you where it should save the file it generates (which is an ordinary zip archive). It then saves all the changes and a description of them as a single zip file.






Make Changes

Make Change is the counterpart to Save Changes. It takes a zip file created by Save Changes and implements all the changes described in there - it makes the changes in the directory you have selected. WARNING - if you deleted files and directories then that is what Make Changes will do. Be certain that you want to apply all the changes in the zipfile.






Downloading

The Windows executable Version in a zip file (2.6MB) :
DirWatcher 1.0 EXE .zip

Full Python Source (32k) :
DirWatcher 1.0 py .zip

I haven't yet made a self-installing Windoze package. If anyone wants it I can build one.
If you are running the python source version, this program will benefit from the installation of the Psyco module. This comes included in the windows executable distribution.






How It Works

For a technical description see the filestruct and FSDM module. This is a Python module that will describe the contents of a file structure using a simple markup language called FSDM. It can also compare directories with FSDM structures and describe the changes. It could also be used to make an incremental archive (only the changes need be stored) or a version control system (file modifications can be stored and recorded). Also any application where you might want to describe a file structure.






MultiListBox

DirWatcher relies on a couple of modules to implmement the GUI. newaskstring is my own very slight modification to one of the dialogs in tkSimpleDialog (by Frederik Lundh). It allows you to pass in a default value to the askstring dialog.

The main part of the DirWatcher window is a large 'MultiListBox' a Tkinter widget. This is by Bob Hauck and the module contains the following license message.

#    Author:     Bob Hauck
#
#    Copyright 2001, Codem Systems Inc.,  All rights reserved.
#    Based on work by Brent Burley found at:
#    
#
#    Codem Systems, Inc.
#    7 Executive Park Drive, 
#    Merrimack, NH  03054
#
# License
# -------
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the author nor the names of any contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# Warranty
# --------
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE






Version 1.0.0
13th-June-2004
email : fuzzyman AT voidspace DOT org DOT uk


TODO/ISSUES

An option to change the projects directory.
Option to change the default action for a double click/enter. (default is savechanges).
Auto-reprofile on/off (on savechanges).
Auto-reprofile on/off (on makechanges).
Import profile (copy to projectdir basically) ?
Export profile (save to somewhere else) ?
Add warning levels
Keep the index position after performing an action.
After saving changes and making changes, optionally display what has been done.

Also see the TODO/ISSUES section of the filestruct module.


Change Log

13th June 2004    Version 1.0.0
A working GUI for the filestruct module - hurrah.







DirWatcher (and it's Python source code) is available for non-commercial use by anyone who might want it, without fee. No warranty as to it's correctness, fitness for purpose or anything else is made - use at your own risk :-)
The home page for this program - where it can be downloaded from and any news/updates can be found - is DirWatcher Home Page. Any python modules arising out of the project will be available at the Python-Utils Home Page. If you want to be kept up to date about changes and improvements to DirWatcher then send me an e-mail, alternatively if you have any questions or comments (or bug reports) feel free to contact me - Michael Foord.
(If you let me know of any places you use my scripts, I can include a link back to you as an example).
If you like this program, please consider donating to the Jesus Centre project.




Back To Top