set output in double quots

This commit is contained in:
Marko Oldenburg 2020-11-09 08:00:08 +01:00
parent a07173e5a9
commit 2692c1bceb
2 changed files with 39 additions and 39 deletions

View File

@ -1,2 +1,2 @@
UPD 2020-11-06_14:06:34 6242 FHEM/98_backupToStorage.pm UPD 2020-11-06_14:06:34 6242 FHEM/98_backupToStorage.pm
UPD 2020-11-06_14:06:34 18956 lib/FHEM/backupToStorage.pm UPD 2020-11-09_07:59:46 19033 lib/FHEM/backupToStorage.pm

View File

@ -150,10 +150,10 @@ sub Define {
return $@ unless ( FHEM::Meta::SetInternals($hash) ); return $@ unless ( FHEM::Meta::SetInternals($hash) );
use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
return 'only one backupToStorage instance allowed' return qq{only one backupToStorage instance allowed}
if ( devspec2array('TYPE=backupToStorage') > 1 ) if ( devspec2array('TYPE=backupToStorage') > 1 )
; # es wird geprüft ob bereits eine Instanz unseres Modules existiert,wenn ja wird abgebrochen ; # es wird geprüft ob bereits eine Instanz unseres Modules existiert,wenn ja wird abgebrochen
return 'too few parameters: define <name> backupToStorage' return qq{too few parameters: define <name> backupToStorage}
if ( scalar( @{$aArg} ) != 2 ); if ( scalar( @{$aArg} ) != 2 );
my $name = shift @$aArg; my $name = shift @$aArg;
@ -161,7 +161,7 @@ sub Define {
$hash->{NOTIFYDEV} = 'global,' . $name; $hash->{NOTIFYDEV} = 'global,' . $name;
$hash->{STORAGETYPE} = AttrVal( $name, 'bTS_Type', 'Nextcloud' ); $hash->{STORAGETYPE} = AttrVal( $name, 'bTS_Type', 'Nextcloud' );
Log3( $name, 3, "backupToStorage ($name) - defined" ); Log3( $name, 3, qq{backupToStorage ("$name") - defined} );
return; return;
} }
@ -170,7 +170,7 @@ sub Undef {
my $hash = shift; my $hash = shift;
my $name = shift; my $name = shift;
Log3( $name, 3, "backupToStorage ($name) - delete device $name" ); Log3( $name, 3, qq{backupToStorage ("$name") - delete device $name} );
return; return;
} }
@ -223,12 +223,12 @@ sub Notify {
Log3( $name, 4, Log3( $name, 4,
"backupToStorage ($name) - Devname: " qq{backupToStorage ("$name") - Devname:
. $devname " $devname "
. " Name: " Name:
. $name " $name "
. " Notify: " Notify:
. Dumper $events); # mit Dumper Dumper $events}); # mit Dumper
PushToStorage($hash) PushToStorage($hash)
if ( ( grep m{^backup.done(.+)?$}xms, @{$events} ) if ( ( grep m{^backup.done(.+)?$}xms, @{$events} )
@ -294,27 +294,27 @@ sub Set {
my $name = shift @$aArg; my $name = shift @$aArg;
my $cmd = shift @$aArg my $cmd = shift @$aArg
// return qq{"set $name" needs at least one argument}; // return qq{set "$name" needs at least one argument};
if ( lc $cmd eq 'addpassword' ) { if ( lc $cmd eq 'addpassword' ) {
return "please set Attribut bTS_User first" return qq{please set Attribut bTS_User first}
if ( AttrVal( $name, 'bTS_User', 'none' ) eq 'none' ); if ( AttrVal( $name, 'bTS_User', 'none' ) eq 'none' );
return "usage: $cmd <password>" if ( scalar( @{$aArg} ) != 1 ); return qq{usage: "$cmd" <password>} if ( scalar( @{$aArg} ) != 1 );
StorePassword( $hash, $name, $aArg->[0] ); StorePassword( $hash, $name, $aArg->[0] );
} }
elsif ( lc $cmd eq 'deletepassword' ) { elsif ( lc $cmd eq 'deletepassword' ) {
return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); return qq{usage: $cmd} if ( scalar( @{$aArg} ) != 0 );
DeletePassword($hash); DeletePassword($hash);
} }
elsif ( lc $cmd eq 'active' ) { elsif ( lc $cmd eq 'active' ) {
return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); return qq{usage: $cmd} if ( scalar( @{$aArg} ) != 0 );
readingsSingleUpdate( $hash, 'state', 'ready', 1 ); readingsSingleUpdate( $hash, 'state', 'ready', 1 );
} }
elsif ( lc $cmd eq 'inactive' ) { elsif ( lc $cmd eq 'inactive' ) {
return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); return qq{usage: $cmd} if ( scalar( @{$aArg} ) != 0 );
readingsSingleUpdate( $hash, 'state', $cmd, 1 ); readingsSingleUpdate( $hash, 'state', $cmd, 1 );
} }
@ -326,7 +326,7 @@ sub Set {
: ' addpassword' : ' addpassword'
); );
return 'Unknown argument ' . $cmd . ', choose one of ' . $list; return qq{Unknown argument "$cmd", choose one of $list};
} }
return; return;
@ -349,10 +349,10 @@ sub Attr {
return return
'check disabledForIntervals Syntax HH:MM-HH:MM or HH:MM-HH:MM HH:MM-HH:MM ...' 'check disabledForIntervals Syntax HH:MM-HH:MM or HH:MM-HH:MM HH:MM-HH:MM ...'
if ( $attrVal !~ /^((\d{2}:\d{2})-(\d{2}:\d{2})\s?)+$/ ); if ( $attrVal !~ /^((\d{2}:\d{2})-(\d{2}:\d{2})\s?)+$/ );
Log3( $name, 3, "backupToStorage ($name) - disabledForIntervals" ); Log3( $name, 3, qq{backupToStorage ("$name") - disabledForIntervals} );
} }
elsif ( $attrName eq 'disable' ) { elsif ( $attrName eq 'disable' ) {
Log3( $name, 3, "backupToStorage ($name) - disabled" ); Log3( $name, 3, qq{backupToStorage ("$name") - disabled} );
} }
} }
@ -369,7 +369,7 @@ sub _CheckIsDisabledAfterSetAttr {
? 'disabled' ? 'disabled'
: 'ready' ); : 'ready' );
Log3( $name, 3, "backupToStorage ($name) - _CheckIsDisabledAfterSetAttr" ); Log3( $name, 3, qq{backupToStorage ("$name") - _CheckIsDisabledAfterSetAttr} );
readingsSingleUpdate($hash, 'state', $state, 1) readingsSingleUpdate($hash, 'state', $state, 1)
if ( ReadingsVal($name, 'state', 'ready' ) ne $state ); if ( ReadingsVal($name, 'state', 'ready' ) ne $state );
@ -392,12 +392,12 @@ sub PushToStorage {
my $name = $hash->{NAME}; my $name = $hash->{NAME};
Log3( $name, 4, "backupToStorage ($name) - push to storage function" ); Log3( $name, 4, qq{backupToStorage ("$name") - push to storage function} );
return return
if ( ReadingsAge($name,'fhemBackupFile',1) > 180 ); if ( ReadingsAge($name,'fhemBackupFile',1) > 180 );
Log3( $name, 4, "backupToStorage ($name) - after readings age return" ); Log3( $name, 4, qq{backupToStorage ("$name") - after readings age return} );
require "SubProcess.pm"; require "SubProcess.pm";
@ -426,7 +426,7 @@ sub PushToStorage {
if ( !defined($pid) ) { if ( !defined($pid) ) {
Log3( $name, 1, Log3( $name, 1,
"backupToStorage ($name) - Cannot execute command asynchronously" ); qq{backupToStorage ("$name") - Cannot execute command asynchronously} );
CleanSubprocess($hash); CleanSubprocess($hash);
readingsSingleUpdate( $hash, 'state', readingsSingleUpdate( $hash, 'state',
@ -435,7 +435,7 @@ sub PushToStorage {
} }
Log3( $name, 4, Log3( $name, 4,
"backupToStorage ($name) - execute command asynchronously (PID=$pid)" qq{backupToStorage ("$name") - execute command asynchronously (PID="$pid")}
); );
$hash->{".fhem"}{subprocess} = $subprocess; $hash->{".fhem"}{subprocess} = $subprocess;
@ -443,7 +443,7 @@ sub PushToStorage {
InternalTimer( gettimeofday() + 1, InternalTimer( gettimeofday() + 1,
"FHEM::backupToStorage::PollChild", $hash ); "FHEM::backupToStorage::PollChild", $hash );
Log3( $hash, 4, Log3( $hash, 4,
"backupToStorage ($name) - control passed back to main loop." ); qq{backupToStorage ("$name") - control passed back to main loop.} );
return; return;
} }
@ -459,20 +459,20 @@ sub PollChild {
if ( !defined($json) ) { if ( !defined($json) ) {
Log3( $name, 5, Log3( $name, 5,
"backupToStorage ($name) - still waiting (" qq{backupToStorage ($name) - still waiting (
. $subprocess->{lasterror} " $subprocess->{lasterror} "
. ")." ); ).} );
InternalTimer( gettimeofday() + 1, InternalTimer( gettimeofday() + 1,
"FHEM::backupToStorage::PollChild", $hash ); "FHEM::backupToStorage::PollChild", $hash );
return; return;
} }
else { else {
Log3( $name, 4, Log3( $name, 4,
"backupToStorage ($name) - got result from asynchronous parsing: " qq{backupToStorage ("$name") - got result from asynchronous parsing: "
. $json ); . $json} );
$subprocess->wait(); $subprocess->wait();
Log3( $name, 4, Log3( $name, 4,
"backupToStorage ($name) - asynchronous finished." ); qq{backupToStorage ("$name") - asynchronous finished.} );
CleanSubprocess($hash); CleanSubprocess($hash);
WriteReadings( $hash, $json ); WriteReadings( $hash, $json );
@ -558,7 +558,7 @@ sub CleanSubprocess {
my $name = $hash->{NAME}; my $name = $hash->{NAME};
delete( $hash->{".fhem"}{subprocess} ); delete( $hash->{".fhem"}{subprocess} );
Log3( $name, 4, "backupToStorage ($name) - clean Subprocess" ); Log3( $name, 4, qq{backupToStorage ("$name") - clean Subprocess} );
} }
sub StorePassword { sub StorePassword {
@ -586,9 +586,9 @@ sub StorePassword {
my $err = setKeyValue( $index, $enc_pwd ); my $err = setKeyValue( $index, $enc_pwd );
DoTrigger( $name, 'password add' ); DoTrigger( $name, 'password add' );
return "error while saving the password - $err" if ( defined($err) ); return qq{error while saving the password - $err} if ( defined($err) );
return "password successfully saved"; return qq{password successfully saved};
} }
sub ReadPassword { sub ReadPassword {
@ -599,14 +599,14 @@ sub ReadPassword {
my $key = getUniqueId() . $index; my $key = getUniqueId() . $index;
my ( $password, $err ); my ( $password, $err );
Log3( $name, 4, "backupToStorage ($name) - Read password from file" ); Log3( $name, 4, qq{backupToStorage ("$name") - Read password from file} );
( $err, $password ) = getKeyValue($index); ( $err, $password ) = getKeyValue($index);
if ( defined($err) ) { if ( defined($err) ) {
Log3( $name, 3, Log3( $name, 3,
"backupToStorage ($name) - unable to read password from file: $err" qq{backupToStorage ("$name") - unable to read password from file: $err}
); );
return undef; return undef;
} }
@ -629,7 +629,7 @@ sub ReadPassword {
return $dec_pwd; return $dec_pwd;
} }
else { else {
Log3( $name, 3, "backupToStorage ($name) - No password in file" ); Log3( $name, 3, qq{backupToStorage ("$name") - No password in file} );
return undef; return undef;
} }
@ -680,7 +680,7 @@ sub WriteReadings {
my $decode_json = eval { decode_json($json) }; my $decode_json = eval { decode_json($json) };
if ($@) { if ($@) {
Log3( $name, 2, "backupToStorage ($name) - JSON error: $@" ); Log3( $name, 2, qq{backupToStorage ("$name") - JSON error: $@} );
return; return;
} }