diff --git a/CHANGED b/CHANGED index 2b8cb40cf..31fc5e67e 100644 --- a/CHANGED +++ b/CHANGED @@ -1,3 +1,7 @@ +- SVN + - feature: optional second parameter to fhem() to make it silent + - feature: autoloading commands, XmlList/etc renamed from 99 to 98. + - 2012-10-28 (5.3) - feature: added functions trim, ltrim, rtrim, UntoggleDirect, UntoggleIndirect - feature: added functions FB_mail, FB_WLANswitch diff --git a/FHEM/99_CULflash.pm b/FHEM/98_CULflash.pm similarity index 100% rename from FHEM/99_CULflash.pm rename to FHEM/98_CULflash.pm diff --git a/FHEM/99_JsonList.pm b/FHEM/98_JsonList.pm similarity index 100% rename from FHEM/99_JsonList.pm rename to FHEM/98_JsonList.pm diff --git a/FHEM/98_autocreate.pm b/FHEM/98_autocreate.pm index 862b43e9d..00b244f2e 100644 --- a/FHEM/98_autocreate.pm +++ b/FHEM/98_autocreate.pm @@ -383,7 +383,7 @@ CommandUsb($$) $msg = "$culType: flash it with: CULflash none $culType"; Log 4, $msg; $ret .= $msg . "\n"; if(!$scan) { - CommandCULflash(undef, "none $culType"); + AnalyzeCommand(undef, "culflash none $culType"); # Enable autoload sleep(4); # Leave time for linux to load th drivers } } diff --git a/FHEM/99_backup.pm b/FHEM/98_backup.pm similarity index 100% rename from FHEM/99_backup.pm rename to FHEM/98_backup.pm diff --git a/FHEM/99_update.pm b/FHEM/98_update.pm similarity index 99% rename from FHEM/99_update.pm rename to FHEM/98_update.pm index 768591c89..b547c3f3b 100644 --- a/FHEM/99_update.pm +++ b/FHEM/98_update.pm @@ -171,7 +171,7 @@ update_DoUpdate(@) my $doBackup = (!defined($attr{global}{backup_before_update}) ? 1 : $attr{global}{backup_before_update}); if ($doBackup) { - my $cmdret = AnalyzeCommandChain(undef, "backup"); + my $cmdret = AnalyzeCommand(undef, "backup"); if ($cmdret !~ m/backup done.*/) { Log 1, "update Backup: The operation was canceled. Please check manually!"; $ret .= "Something went wrong during backup:\n$cmdret\n"; diff --git a/contrib/fhemupdate.control.fhem b/contrib/fhemupdate.control.fhem index 0e2b6ca16..c33d37bb3 100644 --- a/contrib/fhemupdate.control.fhem +++ b/contrib/fhemupdate.control.fhem @@ -1,4 +1,14 @@ -MOV FHEM/release.pm FHEM/FhemUtils +DIR unused +DIR www/images/default +DIR www/gplot +DIR www/pgm2 +DIR docs +MOV FHEM/release.* unused +MOV FHEM/99_updatefhem.* unused +MOV FHEM/99_CULflash.* unused +MOV FHEM/99_JsonList.* unused +MOV FHEM/99_backup.* unused +MOV FHEM/99_update.* unused MOV FHEM/*.jpg www/images/default MOV FHEM/*.png www/images/default MOV FHEM/*.gplot www/gplot @@ -10,4 +20,3 @@ MOV www/pgm2/*.gplot www/gplot MOV www/pgm2/*.jpg www/images/default MOV www/pgm2/*.png www/images/default MOV www/pgm2/*.html docs -MOV FHEM/99_updatefhem.pm UNUSED diff --git a/contrib/fhemupdate.pl b/contrib/fhemupdate.pl index 4c73cf640..c47c92f53 100755 --- a/contrib/fhemupdate.pl +++ b/contrib/fhemupdate.pl @@ -1,5 +1,8 @@ #!/usr/bin/perl +############################### +# This is quite a big mess here. + use IO::File; # Server-Side script to check out the fhem SVN repository, and upload the @@ -16,18 +19,13 @@ my $homedir="/home/rudi/fhemupdate"; chdir("$homedir/culfw"); system("svn update ."); + chdir("$homedir/fhem"); -system("mkdir -p UPLOAD"); +system("mkdir -p fhemupdate"); system("svn update ."); die "SVN failed, exiting\n" if($?); -my $ndiff = `diff fhem.pl fhem.pl.txt | wc -l`; -if($ndiff != 4) { # more than the standard stuff is different - print "Modifying fhem.pl: >$ndiff<\n"; - system('perl -p -e "s/=DATE=/"`date +"%Y-%m-%d"`"/;'. - 's/=VERS=/"`grep ^VERS= Makefile | '. - 'sed -e s/VERS=//`"+SVN/" fhem.pl > fhem.pl.txt'); -} +`cp fhem.pl fhem.pl.txt`; ################################# @@ -36,7 +34,11 @@ my @filelist = ( "./fhem.pl.txt", "FHEM/.*.pm", "FHEM/FhemUtils/.*.pm", - "webfrontend/pgm2/.*", + "www/gplot/.*.gplot", + "www/images/dark/.*.png", + "www/images/default/.*.png", + "www/images/smallscreen/.*.png", + "www/pgm2/.*\.(js|css|svg)", "docs/commandref.html", "docs/faq.html", "docs/HOWTO.html", @@ -67,7 +69,7 @@ foreach my $fspec (@filelist) { } my %oldtime; -if(open FH, "UPLOAD/filetimes.txt") { +if(open FH, "fhemupdate/filetimes.txt") { while(my $l = ) { chomp($l); my ($ts, $fs, $file) = split(" ", $l, 3); @@ -77,12 +79,8 @@ if(open FH, "UPLOAD/filetimes.txt") { close(FH); } -chdir("$homedir/fhem/UPLOAD"); +chdir("$homedir/fhem/fhemupdate"); open FH, ">filetimes.txt" || die "Can't open filetimes.txt: $!\n"; -open FTP, ">script.txt" || die "Can't open script.txt: $!\n"; -print FTP "cd fhem/fhemupdate\n"; -print FTP "put filetimes.txt\n"; -print FTP "pas\n"; # Without passive only 28 files can be transferred my $cnt; foreach my $f (sort keys %filetime) { my $fn = $f; @@ -91,134 +89,140 @@ foreach my $f (sort keys %filetime) { my $newfname = $f; if(!$oldtime{$f} || $oldtime{$f} ne $filetime{$f}) { - print FTP "put $f\n"; system("cp ../$filedir{$f}/$f $f"); $cnt++; } } close FH; -close FTP; - -if($cnt) { - print "FTP Upload needed for $cnt files\n"; - system("ftp -e fhem.de < script.txt"); -} - NEWSTYLE: -################################# -# new Style -chdir("$homedir/fhem"); -my $uploaddir2="UPLOAD2"; -system("mkdir -p $uploaddir2"); +for(my $loop = 0; $loop < 2; $loop++) { + ################################# + # new Style + chdir("$homedir/fhem"); + my $uploaddir2= ($loop ? "fhemupdate4" : "fhemupdate2"); + system("mkdir -p $uploaddir2"); -my %filelist2 = ( - "./fhem.pl.txt" => { type=>",fhem,pgm2,", dir=>"." }, - "./CHANGED" => { type=>",fhem,pgm2,", dir=>"." }, - "FHEM/.*.pm" => { type=>",fhem,pgm2,", dir=>"FHEM" }, - "FHEM/FhemUtils/.*.pm" => { type=>",fhem,pgm2,", dir=>"FHEM/FhemUtils"}, - "../culfw/Devices/CUL/.*.hex" => { type=>",fhem,pgm2,", dir=>"FHEM"}, - "webfrontend/pgm2/.*.pm\$" => { type=>",pgm2,", dir=>"FHEM"}, - "webfrontend/pgm2/.*" => { type=>",pgm2,", dir=>"www/pgm2"}, - "docs/commandref.html" => { type=>",pgm2,", dir=>"www/pgm2"}, - "docs/faq.html" => { type=>",pgm2,", dir=>"www/pgm2"}, - "docs/HOWTO.html" => { type=>",pgm2,", dir=>"www/pgm2"}, - "docs/fhem.*.png" => { type=>",pgm2,", dir=>"www/pgm2"}, - "docs/.*.jpg" => { type=>",pgm2,", dir=>"www/pgm2"}, -); + my %filelist2 = ( + "./fhem.pl.txt" => { type=>",fhem,", dir=>"." }, + "./CHANGED" => { type=>",fhem,", dir=>"." }, + "FHEM/.*.pm" => { type=>",fhem,", dir=>"FHEM" }, + "FHEM/FhemUtils/.*.pm" => { type=>",fhem,", dir=>"FHEM/FhemUtils"}, + "../culfw/Devices/CUL/.*.hex" => { type=>",fhem,", dir=>"FHEM", + dir3=>"FHEM", }, + "www/pgm2/.*" => { type=>"fhem,", dir=>"www/pgm2"}, + "www/gplot/.*.gplot" => { type=>"fhem,", dir=>"www/pgm2"}, + "www/images/dark/.*.png" => { type=>"fhem,", dir=>"www/pgm2"}, + "www/images/default/.*" => { type=>"fhem,", dir=>"www/pgm2"}, + "www/images/smallscreen/.*" => { type=>"fhem,", dir=>"www/pgm2"}, + "docs/commandref.html" => { type=>"fhem,", dir=>"www/pgm2"}, + "docs/faq.html" => { type=>"fhem,", dir=>"www/pgm2"}, + "docs/HOWTO.html" => { type=>"fhem,", dir=>"www/pgm2"}, + "docs/fhem.*.png" => { type=>"fhem,", dir=>"www/pgm2"}, + "docs/.*.jpg" => { type=>"fhem,", dir=>"www/pgm2"}, + ); -# Can't make negative regexp to work, so do it with extra logic -my %skiplist2 = ( - "www/pgm2" => ".pm\$", -); + # Can't make negative regexp to work, so do it with extra logic + my %skiplist2 = ( + # "www/pgm2" => ".pm\$", + ); -# Read in the file timestamps -my %filetime2; -my %filesize2; -my %filedir2; -my %filetype2; -chdir("$homedir/fhem"); -foreach my $fspec (keys %filelist2) { - $fspec =~ m,^(.+)/([^/]+)$,; - my ($dir,$pattern) = ($1, $2); - my $tdir = $filelist2{$fspec}{dir}; - opendir DH, $dir || die("Can't open $dir: $!\n"); - foreach my $file (grep { /$pattern/ && -f "$dir/$_" } readdir(DH)) { - next if($skiplist2{$tdir} && $file =~ m/$skiplist2{$tdir}/); - my @st = stat("$dir/$file"); - my @mt = localtime($st[9]); - $filetime2{"$tdir/$file"} = sprintf "%04d-%02d-%02d_%02d:%02d:%02d", - $mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0]; - $filesize2{"$tdir/$file"} = $st[7]; - $filedir2{"$tdir/$file"} = $dir; - $filetype2{"$tdir/$file"} = $filelist2{$fspec}{type}; - } - closedir(DH); -} - -chdir("$homedir/fhem/$uploaddir2"); -my %oldtime; -if(open FH, "filetimes.txt") { - while(my $l = ) { - chomp($l); - my ($ts, $fs, $file) = split(" ", $l, 3); - $oldtime{"$file.txt"} = $ts if($file =~ m/fhem.pl/); - $oldtime{$file} = $ts; - } - close(FH); -} - -open FTP, ">script.txt" || die "Can't open script.txt: $!\n"; -print FTP "cd fhem/fhemupdate2\n"; -print FTP "pas\n"; # Without passive only 28 files can be transferred - -open FH, ">filetimes.txt" || die "Can't open filetimes.txt: $!\n"; -print FTP "put filetimes.txt\n"; - -my %controls = (fhem=>0, pgm2=>0); -foreach my $k (keys %controls) { - my $fname = "controls_$k.txt"; - $controls{$k} = new IO::File ">$fname" || die "Can't open $fname: $!\n"; - print FTP "put $fname\n"; -} - -my $cnt; -foreach my $f (sort keys %filetime2) { - my $fn = $f; - $fn =~ s/.txt$// if($fn =~ m/.pl.txt$/); - print FH "$filetime2{$f} $filesize2{$f} $fn\n"; - foreach my $k (keys %controls) { - my $fh = $controls{$k}; - print $fh "UPD $filetime2{$f} $filesize2{$f} $fn\n" - if(",$filetype2{$f}," =~ m/,$k,/); - } - my $newfname = $f; - if(!$oldtime{$f} || $oldtime{$f} ne $filetime2{$f}) { - $f =~ m,^(.*)/([^/]*)$,; - my ($tdir, $file) = ($1, $2); - system("mkdir -p $tdir") unless(-d $tdir); - print FTP "put $tdir/$file $tdir/$file\n"; - system("cp ../$filedir2{$f}/$file $tdir/$file"); - $cnt++; - } -} -close FH; -close FTP; - -foreach my $k (keys %controls) { - if(open(ADD, "../contrib/fhemupdate.control.$k")) { - while(my $l = ) { - my $fh = $controls{$k}; - print $fh $l; + # Read in the file timestamps + my %filetime2; + my %filesize2; + my %filedir2; + my %filetype2; + foreach my $fspec (keys %filelist2) { + $fspec =~ m,^(.+)/([^/]+)$,; + my ($dir,$pattern) = ($1, $2); + my $tdir = $filelist2{$fspec}{$loop ? "dir3" : "dir"}; + $tdir = $dir if(!$tdir); + opendir DH, $dir || die("Can't open $dir: $!\n"); + foreach my $file (grep { /$pattern/ && -f "$dir/$_" } readdir(DH)) { + next if($skiplist2{$tdir} && $file =~ m/$skiplist2{$tdir}/); + my @st = stat("$dir/$file"); + my @mt = localtime($st[9]); + $filetime2{"$tdir/$file"} = sprintf "%04d-%02d-%02d_%02d:%02d:%02d", + $mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0]; + $filesize2{"$tdir/$file"} = $st[7]; + $filedir2{"$tdir/$file"} = $dir; + $filetype2{"$tdir/$file"} = $filelist2{$fspec}{type}; } - close ADD; + closedir(DH); + } + + chdir("$homedir/fhem/$uploaddir2"); + my %oldtime; + if(open FH, "filetimes.txt") { + while(my $l = ) { + chomp($l); + my ($ts, $fs, $file) = split(" ", $l, 3); + $oldtime{"$file.txt"} = $ts if($file =~ m/fhem.pl/); + $oldtime{$file} = $ts; + } + close(FH); + } + + open FH, ">filetimes.txt" || die "Can't open filetimes.txt: $!\n"; + + my %controls = (fhem=>0); + foreach my $k (keys %controls) { + my $fname = "controls_$k.txt"; + $controls{$k} = new IO::File ">$fname" || die "Can't open $fname: $!\n"; + if(open(ADD, "../../fhemupdate.control.$k")) { + while(my $l = ) { + my $fh = $controls{$k}; + print $fh $l; + } + close ADD; + } + } + + my $cnt; + foreach my $f (sort keys %filetime2) { + my $fn = $f; + $fn =~ s/.txt$// if($fn =~ m/.pl.txt$/); + print FH "$filetime2{$f} $filesize2{$f} $fn\n"; + foreach my $k (keys %controls) { + my $fh = $controls{$k}; + print $fh "UPD $filetime2{$f} $filesize2{$f} $fn\n" + } + my $newfname = $f; + if(!$oldtime{$f} || $oldtime{$f} ne $filetime2{$f}) { + $f =~ m,^(.*)/([^/]*)$,; + my ($tdir, $file) = ($1, $2); + system("mkdir -p $tdir") unless(-d $tdir); + system("cp ../$filedir2{$f}/$file $tdir/$file"); + $cnt++; + } + } + close FH; + + foreach my $k (keys %controls) { + close $controls{$k}; } - close $controls{$k}; } -if($cnt) { - print "FTP Upload needed for $cnt files\n"; - system("ftp -e fhem.de < script.txt"); +$ENV{RSYNC_RSH}="ssh"; +chdir("$homedir/fhem"); + +if(0) { + my $fname="controls_fhem.txt"; + `cp fhemupdate4/$fname fhemupdate`; + `cp fhemupdate4/$fname fhemupdate2/FHEM`; + `rm fhemupdate2/$fname`; + my @st = stat("fhemupdate4/$fname"); + my @mt = localtime($st[9]); + my $ftime = sprintf "%04d-%02d-%02d_%02d:%02d:%02d", + $mt[5]+1900, $mt[4]+1, $mt[3], $mt[2], $mt[1], $mt[0]; + my $fsize = $st[7]; + system("echo $ftime $fsize $fname >> fhemupdate/filetimes.txt"); + system("echo $ftime $fsize FHEM/$fname >> fhemupdate2/filetimes.txt"); } + +my $rsyncopts="-a --delete --compress --verbose"; +system("rsync $rsyncopts fhemupdate fhem.de:fhem"); +system("rsync $rsyncopts fhemupdate2 fhem.de:fhem"); +system("rsync $rsyncopts fhemupdate4/. fhem.de:fhem/fhemupdate4/svn"); diff --git a/docs/commandref.html b/docs/commandref.html index dfe2287d1..4891bf865 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -12684,6 +12684,10 @@ isday { fhem "set light on" }
define n1 notify piri:on { fhem "set light on" } + Note: if this function returns a value, it will also be logged into the + global fhem log. Use 1 as a second argument to disable this logging, this + makes sense when obtainig some values via fhem "get...". +

  • Notify can be used to store macros for manual execution. Use the