From 106ff954e1180b8aaf59d6eacd10d39800cb3ca1 Mon Sep 17 00:00:00 2001 From: marvin78 Date: Wed, 30 Jan 2019 10:11:33 +0000 Subject: [PATCH] 98_inotify: check for missing perl modules / better MID git-svn-id: https://svn.fhem.de/fhem/trunk@18456 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_inotify.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/98_inotify.pm b/fhem/FHEM/98_inotify.pm index baa816186..ee55d36a3 100644 --- a/fhem/FHEM/98_inotify.pm +++ b/fhem/FHEM/98_inotify.pm @@ -4,14 +4,17 @@ package main; use strict; use warnings; -use Data::Dumper; -use Linux::Inotify2; -use File::Find; + +my $missingModule = ""; + +eval "use Data::Dumper;1" or $missingModule .= "Data::Dumper "; +eval "use Linux::Inotify2;1" or $missingModule .= "Linux::Inotify2 "; +eval "use File::Find;1" or $missingModule .= "File::Find "; ####################### # Global variables -my $version = "0.5.5"; +my $version = "0.5.7"; our $inotify; our @watch; @@ -86,11 +89,17 @@ sub inotify_Define($$) { return $msg; } + return "Cannot define a inotify device. Perl module(s) $missingModule is/are missing." if ( $missingModule ); + $hash->{PATH}=$a[2]; $hash->{FILES}=$a[3]?$a[3]:undef; - $hash->{VERSION} = $version; - $hash->{MID} = 'da39a3ee5e6dfdss434436657657bdbfef95601890afd80709'; # + $hash->{VERSION} = $version; + + #$hash->{MID} = 'da39a3ee5e6dfdss434436657657bdbfef95601890afd80709'; # + my $mid = "inotify_".$a[2].$a[3]; + $mid =~ s/[^A-Za-z0-9\-_]//g; + $hash->{MID} = $mid; $hash->{NOTIFYDEV}= "global";