fhem.cfg.demo: add define -ignoreErr for RSS

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@7527 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-01-11 17:55:36 +00:00
parent f10d54307d
commit 3f342a8cc7
2 changed files with 19 additions and 13 deletions

View File

@ -324,7 +324,7 @@ attr Weather room Weather
#attr Weather.weblink alias Weather Forecast #attr Weather.weblink alias Weather Forecast
#attr Weather.weblink room Weather #attr Weather.weblink room Weather
define Display RSS jpg localhost ./demolog/layout define -ignoreErr Display RSS jpg localhost ./demolog/layout
attr Display room System attr Display room System
attr Display size 800x600 attr Display size 800x600
attr Display bg ./demolog/pictures attr Display bg ./demolog/pictures

30
fhem.pl
View File

@ -71,7 +71,7 @@ sub IsDisabled($);
sub IsDummy($); sub IsDummy($);
sub IsIgnored($); sub IsIgnored($);
sub IsIoDummy($); sub IsIoDummy($);
sub LoadModule($); sub LoadModule($;$);
sub Log($$); sub Log($$);
sub Log3($$$); sub Log3($$$);
sub OldTimestamp($); sub OldTimestamp($);
@ -139,7 +139,7 @@ sub CommandInform($$);
sub CommandList($$); sub CommandList($$);
sub CommandModify($$); sub CommandModify($$);
sub CommandQuit($$); sub CommandQuit($$);
sub CommandReload($$); sub CommandReload($$;$);
sub CommandRename($$); sub CommandRename($$);
sub CommandRereadCfg($$); sub CommandRereadCfg($$);
sub CommandSave($$); sub CommandSave($$);
@ -456,7 +456,7 @@ if(configDBUsed()) {
} else { } else {
my $ret = CommandInclude(undef, $attr{global}{configfile}); my $ret = CommandInclude(undef, $attr{global}{configfile});
$cfgRet .= "configfile: $ret\n" if($ret); $cfgRet .= "configfile: $ret" if($ret);
if($attr{global}{statefile} && -r $attr{global}{statefile}) { if($attr{global}{statefile} && -r $attr{global}{statefile}) {
$ret = CommandInclude(undef, $attr{global}{statefile}); $ret = CommandInclude(undef, $attr{global}{statefile});
@ -1522,15 +1522,15 @@ CommandGet($$)
##################################### #####################################
sub sub
LoadModule($) LoadModule($;$)
{ {
my ($m) = @_; my ($m, $ignoreErr) = @_;
if($modules{$m} && !$modules{$m}{LOADED}) { # autoload if($modules{$m} && !$modules{$m}{LOADED}) { # autoload
my $o = $modules{$m}{ORDER}; my $o = $modules{$m}{ORDER};
my $ret = CommandReload(undef, "${o}_$m"); my $ret = CommandReload(undef, "${o}_$m", $ignoreErr);
if($ret) { if($ret) {
Log 0, $ret; Log 0, $ret if(!$ignoreErr);
return "UNDEFINED"; return "UNDEFINED";
} }
@ -1553,6 +1553,12 @@ CommandDefine($$)
{ {
my ($cl, $def) = @_; my ($cl, $def) = @_;
my @a = split("[ \t][ \t]*", $def, 3); my @a = split("[ \t][ \t]*", $def, 3);
my $ignoreErr;
if($a[0] eq "-ignoreErr") { # RSS in fhem.cfg.demo, with no GD installed
$def =~ s/\s*-ignoreErr\s*//;
@a = split("[ \t][ \t]*", $def, 3);
$ignoreErr = 1;
}
my $name = $a[0]; my $name = $a[0];
return "Usage: define <name> <type> <type dependent arguments>" return "Usage: define <name> <type> <type dependent arguments>"
if(int(@a) < 2); if(int(@a) < 2);
@ -1570,7 +1576,7 @@ CommandDefine($$)
} }
} }
my $newm = LoadModule($m); my $newm = LoadModule($m, $ignoreErr);
return "Cannot load module $m" if($newm eq "UNDEFINED"); return "Cannot load module $m" if($newm eq "UNDEFINED");
$m = $newm; $m = $newm;
@ -1992,9 +1998,9 @@ CommandList($$)
##################################### #####################################
sub sub
CommandReload($$) CommandReload($$;$)
{ {
my ($cl, $param) = @_; my ($cl, $param, $ignoreErr) = @_;
my %hash; my %hash;
$param =~ s,/,,g; $param =~ s,/,,g;
$param =~ s,\.pm$,,g; $param =~ s,\.pm$,,g;
@ -2022,7 +2028,7 @@ CommandReload($$)
my $ret=do "$file"; my $ret=do "$file";
unlink($file) if($cfgDB eq 'X'); # delete temp file unlink($file) if($cfgDB eq 'X'); # delete temp file
if(!$ret) { if(!$ret) {
Log 1, "reload: Error:Modul $param deactivated:\n $@"; Log 1, "reload: Error:Modul $param deactivated:\n $@" if(!$ignoreErr);
return $@; return $@;
} }
@ -2238,7 +2244,7 @@ CommandAttr($$)
my $hash = $defs{$sdev}; my $hash = $defs{$sdev};
my $attrName = $a[1]; my $attrName = $a[1];
if(!defined($hash)) { if(!defined($hash)) {
push @rets, "Please define $sdev first"; push @rets, "Please define $sdev first" if($init_done);#define -ignoreErr
next; next;
} }