Use the with-statement for accessing files

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Include timestamp in log messages

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Use 'from X import Y' instead of 'import X ; Y = X.Y'

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Refactor desktop notification

 * Move platform abstraction logic into a separate module `notify`
 * Define a common interface across desktop notification systems: INotify
 * Implement that interface for each supported desktop
 * In the main program only:
  - instantiate the different implementations
  - delegate notifications to the INotify interface

 * Additionally set an explicit timeout of 5 seconds on all notifications
  -> Way too much notifications are created for it to be reasonable to
     require the user to close them all.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Use the KeyboardInterrupt exception to handle SIGINT

I.e. no need to explicitly declare a signal handler if we can just catch
it as an exception.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Threading cleanup:

 * Remove ResettableTimer class, use threading.Timer instead.
 * Remove debug printing of 'tick #n' etc. it causes way too much complexity for little added value
 * Make the Linux notifier thread a daemon as well
  - to prevent hanging on it when terminating

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Move file-change-detection code into a separate module: 'filenotifier'

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Change the order of configuration file reading

If the ConfigParser read the .autosync file at last position, it will overwrite the existing config value read from the non-default config file, thus not making possible to scan another directory
Merge commit 'refs/merge-requests/20' of git://gitorious.org/dvcs-autosync/dvcs-autosync into merge-requests/20
Merge commit 'refs/merge-requests/18' of git://gitorious.org/dvcs-autosync/dvcs-autosync into merge-requests/18
Minor fixes to the last merge, add new modules to setup.py, and document changes
Update Debian package version.
Put colon between timestamp and level in logging format and add module search path for the new, private modules to be loaded under Linux from the standard installation path
Fix installation flaw by making a proper dvcsautosync module

I installed dvcsautosync via sudo python setup.py install and it
installed everything into /usr/local/.... However the dvcs-autosync
script hardcoded a /usr/share/SCRIPT path as additional python path,
so the invokation failed and bailed out.

The solution is to make a proper dvcsautosync module that is
installed into the python path. This way we can call a local dvcs-autosync
or one in /usr/local or whereever and it will work as long as python can
find the dvcsautosync package. It also has the advantage that we don't
need to specify each single file in setup.py that needs to be installed.

I left the autostart script in /usr/local/share/dvcs-autosync, as I did
not know a better place for it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Clean up imports

Hide the ugliness of the private jabberbot import in
dvcsautotsync.__init__.py. Cosolidate import statements at the top
of the file.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Untabify python files

dvcs-autosync contains an amazing mix of spaces and tabs. It's
ugly and at least python3 complains and fails to run. Replace all
tabs with spaces per python coding conventions.
No other changes are in this patch.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Deuglyify filenotifier code

Simply wrapping the whole code for the conditional platform
specific code in filenotifier was pretty ugly. Split all 3 OS
specific implementations into their own file and import only the
correct file. This reduces the indentation of the code by one and
makes things better to understand in my opinion (no need for me to
trawl through Windows specific code and to understand when which
code in that file will be available.

One issue though, dvcs-autosync failed when
pyinotify was not installed, but is that not optional? In that case,
where is the generic fallback code that we have? Or is this a hard
requirement now? Without pyinotify I get on master the error
"OS is not supported". On 'devel' I get simply a mysterious import
error that hides any mention of pyinotify. With this patch, you get
a nicer understandable error message, telling the user to install
python-inotify.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Use platform.node() for hostname detection

Rather than implementing OS-specific checks, make use of the
platform.node() function which works on both Windows and Linux.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Only use one desktop notifier backend

Put all the detectino logic into the desktopnotifier.py file and don't
bother in the main file. Also we don't need an array of up to three
notfier systems which to notify (we don't want three bubbles and there
is not likely to be three of them installed).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix Pynotify indention bug

If _icon could not be set, no notification was shown at all. This is
most likely an indention bug and should be fixed. It will now simply
supppress icons if we could not load one.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>