From f58857994d1c2ad892733b32f621016dc823a630 Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Tue, 13 Aug 2013 12:32:24 +0000 Subject: [PATCH] fixed: some minor bugs modified: commandref added: support for Windows based fhem-installtions git-svn-id: https://svn.fhem.de/fhem/trunk@3683 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/55_GDS.pm | 65 ++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/fhem/FHEM/55_GDS.pm b/fhem/FHEM/55_GDS.pm index 98dc41611..214cb6dd1 100644 --- a/fhem/FHEM/55_GDS.pm +++ b/fhem/FHEM/55_GDS.pm @@ -73,6 +73,8 @@ sub GDS_Initialize($) { "gdsAll:0,1 gdsDebug:0,1 gdsLong:0,1 gdsPolygon:0,1 ". $readingFnAttributes; + $tempDir = "c:\\temp\\" if($^O eq "MSWin32"); + fillMappingTables($hash); initDropdownLists($hash); createIndexFile($hash); @@ -107,12 +109,12 @@ sub GDS_Define($$$) { $hash->{helper}{URL} = "ftp-outgoing2.dwd.de"; $hash->{helper}{INTERVAL} = 3600; - Log3($name, 3, "GDS $name created"); + Log3($name, 3, "GDS $name: created"); + Log3($name, 3, "GDS $name: tempDir=".$tempDir); $dummy = "gds_web_".$name; CommandDefine(undef, $dummy." HTTPSRV ".$name." ".$tempDir." GDS ".$name." Files"); $attr{$dummy}{"directoryindex"} = $name.".html"; - fillMappingTables($hash); initDropdownLists($hash); createIndexFile($hash); @@ -282,14 +284,9 @@ sub GDS_Get($@) { } when("rereadcfg"){ - eval { - retrieveFile($hash,"conditions"); - $sList = getListStationsDropdown($hash); - }; - eval { - retrieveFile($hash,"alerts"); - ($aList, undef) = buildCAPList($hash); - }; + retrieveFile($hash,"conditions"); + retrieveFile($hash,"alerts"); + initDropdownLists($hash); break; } @@ -571,7 +568,8 @@ sub decodeCAPData($$){ readingsBeginUpdate($hash); readingsBulkUpdate($hash, "_copyright", "Quelle: Deutscher Wetterdienst"); - while(($k, $v) = each %readings) { readingsBulkUpdate($hash, $k, latin1ToUtf8($v)); } + while(($k, $v) = each %readings){ + readingsBulkUpdate($hash, $k, latin1ToUtf8($v)) if(defined($v)); } readingsEndUpdate($hash, 1); return; @@ -605,7 +603,8 @@ sub retrieveTextWarn($){ my ($line, @a); open WXDATA, $tempDir.$name."_warnings"; - while (chomp($line = )) { push @a, latin1ToUtf8($line); } + while (chomp($line = )) { + push @a, latin1ToUtf8($line); } close WXDATA; return join("", @a); } @@ -669,7 +668,8 @@ sub retrieveConditions($$@){ CommandDeleteReading(undef, "$name $prefix"."_.*"); readingsBeginUpdate($hash); - while(($k, $v) = each %cread) { readingsBulkUpdate($hash, $k, latin1ToUtf8($v)); } + while(($k, $v) = each %cread) { + readingsBulkUpdate($hash, $k, latin1ToUtf8($v)) if(defined($v)); } readingsEndUpdate($hash, 1); $hash->{STATE} = "active"; @@ -1015,18 +1015,24 @@ sub initDropdownLists($){ my($hash) = @_; my $name = $hash->{NAME}; - if ($name && -e $tempDir.$name."_conditions"){ - $sList = getListStationsDropdown($hash); - } else { - $sList = "please_use_rereadcfg_first"; - } + if ($name){ + if(-e $tempDir.$name."_conditions"){ + $sList = getListStationsDropdown($hash); + } else { + Log3($name, 3, "GDS $name: no datafile (conditions) found"); + $sList = "please_use_rereadcfg_first"; + } - if ($name && -e $tempDir.$name."_alerts"){ - ($aList, undef) = buildCAPList($hash); + if (-e $tempDir.$name."_alerts"){ + ($aList, undef) = buildCAPList($hash); + } else { + Log3($name, 3, "GDS $name: no datafile (alerts) found"); + $aList = "please_use_rereadcfg_first"; + } } else { $aList = "please_use_rereadcfg_first"; + $sList = $aList; } - return; } @@ -1067,6 +1073,9 @@ sub initDropdownLists($){ # use parameter #5 = 1 in RetrieveFile for ftp # added get caplist # +# 2013-08-13 fixed some minor bugs to prevent annoying console messages +# added support for fhem installtions running on windows-based systems +# #################################################################################################### # # Further informations @@ -1098,6 +1107,18 @@ sub initDropdownLists($){

GDS

    + + Prerequesits +
      + +
      + Module uses following additional Perl modules:

      + Net::FTP, List::MoreUtils, XML::Simple, Text::CSV

      + If not already installed in your environment, please install them using appropriate commands from your environment. + +
    +

    + Define
      @@ -1248,7 +1269,7 @@ sub initDropdownLists($){
      • Module uses following additional Perl modules:

        -
          Net::FTP, List::MoreUtils, XML::Simple, Text::CSV


        + Net::FTP, List::MoreUtils, XML::Simple, Text::CSV

        If not already installed in your environment, please install them using appropriate commands from your environment.


      • Have fun!