mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 14:16:42 +00:00
02_RSS: tweaked warnings/logging
git-svn-id: https://svn.fhem.de/fhem/trunk@7200 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c6d8f0fdcb
commit
1938f8e007
@ -33,6 +33,9 @@ my @valid_halign = qw(left center right justified);
|
|||||||
# use vars qw(%FW_pos); # scroll position
|
# use vars qw(%FW_pos); # scroll position
|
||||||
# use vars qw($FW_cname); # Current connection name
|
# use vars qw($FW_cname); # Current connection name
|
||||||
|
|
||||||
|
# http://blogs.perl.org/users/mike_b/2013/06/a-little-nicer-way-to-use-smartmatch-on-perl-518.html
|
||||||
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
sub
|
sub
|
||||||
RSS_addExtension($$$) {
|
RSS_addExtension($$$) {
|
||||||
@ -42,7 +45,7 @@ RSS_addExtension($$$) {
|
|||||||
$data{FWEXT}{$url}{FUNC} = $func;
|
$data{FWEXT}{$url}{FUNC} = $func;
|
||||||
$data{FWEXT}{$url}{LINK} = $link;
|
$data{FWEXT}{$url}{LINK} = $link;
|
||||||
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
||||||
#$data{FWEXT}{$url}{FORKABLE} = 1;
|
$data{FWEXT}{$url}{FORKABLE} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
@ -59,6 +62,7 @@ RSS_Initialize($) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
sub
|
sub
|
||||||
RSS_readLayout($) {
|
RSS_readLayout($) {
|
||||||
@ -100,13 +104,13 @@ RSS_Define($$) {
|
|||||||
eval "use GD::Text::Align";
|
eval "use GD::Text::Align";
|
||||||
$hash->{fhem}{useTextAlign} = ($@ ? 0 : 1 );
|
$hash->{fhem}{useTextAlign} = ($@ ? 0 : 1 );
|
||||||
if(!($hash->{fhem}{useTextAlign})) {
|
if(!($hash->{fhem}{useTextAlign})) {
|
||||||
Log3 $hash, 1, "Cannot use text alignment: $@";
|
Log3 $hash, 2, "$name: Cannot use text alignment: $@";
|
||||||
}
|
}
|
||||||
|
|
||||||
eval "use GD::Text::Wrap";
|
eval "use GD::Text::Wrap";
|
||||||
$hash->{fhem}{useTextWrap} = ($@ ? 0 : 1 );
|
$hash->{fhem}{useTextWrap} = ($@ ? 0 : 1 );
|
||||||
if(!($hash->{fhem}{useTextWrap})) {
|
if(!($hash->{fhem}{useTextWrap})) {
|
||||||
Log3 $hash, 1, "Cannot use text wrapping: $@";
|
Log3 $hash, 2, "$name: Cannot use text wrapping: $@";
|
||||||
}
|
}
|
||||||
|
|
||||||
RSS_readLayout($hash);
|
RSS_readLayout($hash);
|
||||||
@ -506,6 +510,7 @@ RSS_evalLayout($$@) {
|
|||||||
|
|
||||||
#Debug "before command $line: x= " . $params{x} . ", y= " . $params{y};
|
#Debug "before command $line: x= " . $params{x} . ", y= " . $params{y};
|
||||||
|
|
||||||
|
eval {
|
||||||
if($cmd eq "rgb") {
|
if($cmd eq "rgb") {
|
||||||
$def= "\"$def\"" if(length($def) == 6 && $def =~ /[[:xdigit:]]{6}/);
|
$def= "\"$def\"" if(length($def) == 6 && $def =~ /[[:xdigit:]]{6}/);
|
||||||
$params{rgb}= AnalyzePerlCommand(undef, $def);
|
$params{rgb}= AnalyzePerlCommand(undef, $def);
|
||||||
@ -601,11 +606,16 @@ RSS_evalLayout($$@) {
|
|||||||
my $arg= AnalyzePerlCommand(undef, $arg);
|
my $arg= AnalyzePerlCommand(undef, $arg);
|
||||||
RSS_itemImg($S,$x,$y,$scale,$imgtype,$srctype,$arg,%params);
|
RSS_itemImg($S,$x,$y,$scale,$imgtype,$srctype,$arg,%params);
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 1, "$name: Illegal command $cmd in layout definition.";
|
Log3 $name, 2, "$name: Illegal command $cmd in layout definition.";
|
||||||
}
|
}
|
||||||
|
|
||||||
#Debug "after command $line: x= " . $params{x} . ", y= " . $params{y};
|
#Debug "after command $line: x= " . $params{x} . ", y= " . $params{y};
|
||||||
|
};
|
||||||
|
if($@) {
|
||||||
|
my $msg= "$name: Error from line \'$line\' in layout definition: $@";
|
||||||
|
chomp $msg;
|
||||||
|
Log3 $name, 2, $msg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +641,7 @@ RSS_returnIMG($$) {
|
|||||||
#
|
#
|
||||||
# create the image
|
# create the image
|
||||||
#
|
#
|
||||||
my $S;
|
our $S;
|
||||||
# let's create a blank image, we will need it in most cases.
|
# let's create a blank image, we will need it in most cases.
|
||||||
$S= GD::Image->newTrueColor($width,$height);
|
$S= GD::Image->newTrueColor($width,$height);
|
||||||
my $bgcolor = AttrVal($name,'bgcolor','000000'); #default bg color = black
|
my $bgcolor = AttrVal($name,'bgcolor','000000'); #default bg color = black
|
||||||
@ -641,7 +651,6 @@ RSS_returnIMG($$) {
|
|||||||
# wrap to make problems with GD non-lethal
|
# wrap to make problems with GD non-lethal
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
|
|
||||||
#
|
#
|
||||||
# set the background
|
# set the background
|
||||||
#
|
#
|
||||||
@ -701,11 +710,11 @@ RSS_returnIMG($$) {
|
|||||||
} else {
|
} else {
|
||||||
# size is as required
|
# size is as required
|
||||||
# kill the predefined image and take the original
|
# kill the predefined image and take the original
|
||||||
$S= undef;
|
undef $S;
|
||||||
$S= $bg;
|
$S= $bg;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$S= undef;
|
undef $S;
|
||||||
$reason= "Something was wrong with background image \"$bgfile\".";
|
$reason= "Something was wrong with background image \"$bgfile\".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -717,17 +726,24 @@ RSS_returnIMG($$) {
|
|||||||
if(defined($S)) {
|
if(defined($S)) {
|
||||||
RSS_evalLayout($S, $name, $defs{$name}{fhem}{layout});
|
RSS_evalLayout($S, $name, $defs{$name}{fhem}{layout});
|
||||||
} else {
|
} else {
|
||||||
Log3 undef, 2, "$name: Could not create image. $reason";
|
Log3 $name, 2, "$name: Could not create image. $reason";
|
||||||
$S= GD::Image->newTrueColor($width,$height); # return empty image
|
$S= GD::Image->newTrueColor($width,$height); # return empty image
|
||||||
}
|
}
|
||||||
$defs{$name}{STATE} = localtime();
|
$defs{$name}{STATE} = localtime();
|
||||||
}; warn $@ if $@;
|
|
||||||
|
|
||||||
|
}; #warn $@ if $@;
|
||||||
|
if($@) {
|
||||||
|
my $msg= $@;
|
||||||
|
chomp $msg;
|
||||||
|
Log3 $name, 2, $msg;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# return image
|
# return image
|
||||||
#
|
#
|
||||||
return ("image/jpeg; charset=utf-8", $S->jpeg) if $type eq 'jpg';
|
return ("image/jpeg; charset=utf-8", $S->jpeg) if($type eq 'jpg');
|
||||||
return ("image/png; charset=utf-8", $S->png) if $type eq 'png';
|
return ("image/png; charset=utf-8", $S->png) if($type eq 'png');
|
||||||
}
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user