mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
98_version.pm: separation of version command from fhem.pl - first step (Forum: #47155)
git-svn-id: https://svn.fhem.de/fhem/trunk@10451 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ba54b39dbf
commit
1e0502907c
150
fhem/FHEM/98_version.pm
Executable file
150
fhem/FHEM/98_version.pm
Executable file
@ -0,0 +1,150 @@
|
||||
# $Id$
|
||||
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub version_Initialize($$) {
|
||||
|
||||
$cmds{version} = { Fn => "CommandVersion",
|
||||
Hlp=>"[filter],print SVN version of loaded modules"};
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
CommandVersion($$)
|
||||
{
|
||||
my ($cl, $param) = @_;
|
||||
|
||||
my @ret = ("# $cvsid") ;
|
||||
push @ret, cfgDB_svnId() if(configDBUsed());
|
||||
my $max = 7 ; # length("fhem.pl") = 7
|
||||
my $modpath = (exists($attr{global}{modpath}) ? $attr{global}{modpath} : "");
|
||||
foreach my $m (keys %INC)
|
||||
{
|
||||
next unless($INC{$m} =~ /^$modpath.FHEM/ or $INC{$m} =~ /^FHEM/); # configDB
|
||||
my $fn = $INC{$m};
|
||||
my $mod_name = ($fn=~ /[\/\\]([^\/\\]+)$/ ? $1 : $fn);
|
||||
next if($param && $mod_name !~ /$param/);
|
||||
next if(grep(/$mod_name/, @ret));
|
||||
Log 4, "Looking for SVN Id in module $mod_name";
|
||||
|
||||
if($max < length($mod_name)) {
|
||||
$max = length($mod_name)
|
||||
}
|
||||
my $line;
|
||||
|
||||
if(!open(FH, $fn)) {
|
||||
$line = "$fn: $!";
|
||||
if(configDBUsed()){
|
||||
Log 4, "Looking for module $m in configDB to find SVN Id";
|
||||
$line = cfgDB_Fileversion($fn,$line);
|
||||
}
|
||||
} else {
|
||||
($line) = grep(/#.*\$Id\:[^\$\n\r].+\$/, <FH>);
|
||||
}
|
||||
|
||||
$line = "No Id found for $mod_name" unless($line);
|
||||
push @ret, $line;
|
||||
}
|
||||
|
||||
@ret = map {/\$Id\: (\S+) (\S+) (.+?) \$/ ? sprintf("%-".$max."s %5d %s",$1,$2,$3) : $_}
|
||||
@ret;
|
||||
@ret = grep {(defined($param) ? $_ =~ /$param/ : 1)} @ret;
|
||||
@ret = sort {version_sortModules($a, $b)} @ret;
|
||||
return "no loaded modules found that match: $param" if($param && !@ret);
|
||||
return sprintf("%-".$max."s %s","File","Rev Last Change\n\n").
|
||||
join("\n", grep (($_ =~ /^fhem.pl|\d\d_/), @ret)).(!$param ? "\n\n":"").
|
||||
join("\n", grep (($_ !~ /^fhem.pl|\d\d_/), @ret));
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub version_sortModules($$)
|
||||
{
|
||||
my ($a, $b) = @_;
|
||||
|
||||
$a =~ s/^No Id found for //;
|
||||
$b =~ s/^No Id found for //;
|
||||
|
||||
my @a_vals = split(' ', $a);
|
||||
my @b_vals = split(' ', $b);
|
||||
|
||||
return -1 if($a_vals[0] eq "fhem.pl"); # fhem.pl always at top
|
||||
|
||||
$a_vals[0] =~ s/^\d\d_//;
|
||||
$b_vals[0] =~ s/^\d\d_//;
|
||||
|
||||
return uc($a_vals[0]) cmp uc($b_vals[0]);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
=begin html
|
||||
|
||||
<a name="version"></a>
|
||||
<h3>version</h3>
|
||||
<ul>
|
||||
<code>version [filter]</code>
|
||||
<br><br>
|
||||
List the version of fhem.pl and all loaded modules. The optional parameter
|
||||
can be used to filter the ouput.
|
||||
|
||||
<br><br>
|
||||
Example output of "<code>version</code>":
|
||||
<ul>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
90_at.pm 10048 2015-11-29 14:51:40Z rudolfkoenig<br>
|
||||
98_autocreate.pm 10165 2015-12-13 11:14:15Z rudolfkoenig<br>
|
||||
00_CUL.pm 10146 2015-12-10 10:17:42Z rudolfkoenig<br>
|
||||
10_CUL_HM.pm 10411 2016-01-08 15:18:17Z martinp876<br>
|
||||
</code>
|
||||
</ul>
|
||||
<br>
|
||||
Example output of "<code>version fhem</code>":
|
||||
<ul>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
=end html
|
||||
|
||||
=begin html_DE
|
||||
|
||||
<a name="version"></a>
|
||||
<h3>version</h3>
|
||||
<ul>
|
||||
<code>version [filter]</code>
|
||||
<br><br>
|
||||
Gibt die Versionsinformation von fhem.pl und aller geladenen Module aus. Mit
|
||||
der optionalen Parameter kann man die Ausgabe filtern.
|
||||
|
||||
<br><br>
|
||||
Beispiel der Ausgabe von "<code>version</code>":
|
||||
<ul>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
90_at.pm 10048 2015-11-29 14:51:40Z rudolfkoenig<br>
|
||||
98_autocreate.pm 10165 2015-12-13 11:14:15Z rudolfkoenig<br>
|
||||
00_CUL.pm 10146 2015-12-10 10:17:42Z rudolfkoenig<br>
|
||||
10_CUL_HM.pm 10411 2016-01-08 15:18:17Z martinp876<br>
|
||||
</code>
|
||||
</ul>
|
||||
<br>
|
||||
Beispiel der Ausgabe von "<code>version fhem</code>":
|
||||
<ul>
|
||||
<code><br>
|
||||
File Rev Last Change<br><br>
|
||||
fhem.pl 10397 2016-01-07 08:36:49Z rudolfkoenig<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
=end html_DE
|
||||
|
||||
=cut
|
@ -331,6 +331,7 @@ FHEM/98_statistics.pm tupol http://forum.fhem.de Unterstue
|
||||
FHEM/98_structure.pm rudolfkoenig http://forum.fhem.de Automatisierung
|
||||
FHEM/98_telnet.pm rudolfkoenig http://forum.fhem.de Automatisierung
|
||||
FHEM/98_update.pm rudolfkoenig http://forum.fhem.de Sonstiges
|
||||
FHEM/98_version.pm markusbloch http://forum.fhem.de Sonstiges
|
||||
FHEM/98_weblink.pm rudolfkoenig http://forum.fhem.de Frontends
|
||||
FHME/98_weekprofile.pm risiko http://forum.fhem.de Frontends
|
||||
FHEM/99_SUNRISE_EL.pm rudolfkoenig http://forum.fhem.de Automatisierung
|
||||
|
@ -1296,24 +1296,6 @@ The following local attributes are used by a wider range of devices:
|
||||
<br>
|
||||
</ul>
|
||||
|
||||
<a name="version"></a>
|
||||
<h3>version</h3>
|
||||
<ul>
|
||||
<code>version [filter]</code>
|
||||
<br><br>
|
||||
List the version of fhem.pl and all loaded modules. The optional parameter
|
||||
can be used to filter the ouput.
|
||||
|
||||
<br><br>
|
||||
Example output:
|
||||
<ul>
|
||||
<code>
|
||||
# $Id: fhem.pl 3405 2013-07-11 19:46:39Z rudolfkoenig $<br>
|
||||
# $Id: 00_CUL.pm 3237 2013-06-01 17:15:59Z rudolfkoenig $<br>
|
||||
# $Id: 10_CUL_HM.pm 3378 2013-07-02 16:57:27Z martinp876 $<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
<!-- commands end - diese Zeile nicht entfernen! -->
|
||||
|
||||
<a name="global"></a>
|
||||
|
@ -1376,25 +1376,6 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
blockiert. Das ist unerwünscht, und im FHEM-Log wird eine Warnung
|
||||
protokolliert.
|
||||
</ul>
|
||||
|
||||
<a name="version"></a>
|
||||
<h3>version</h3>
|
||||
<ul>
|
||||
<code>version [filter]</code>
|
||||
<br><br>
|
||||
Gibt die Versionsinformation von fhem.pl und aller geladenen Module aus. Mit
|
||||
der optionalen Parameter kann man die Ausgabe filtern.
|
||||
|
||||
<br><br>
|
||||
Beispiel der Ausgabe:
|
||||
<ul>
|
||||
<code>
|
||||
# $Id: fhem.pl 3405 2013-07-11 19:46:39Z rudolfkoenig $<br>
|
||||
# $Id: 00_CUL.pm 3237 2013-06-01 17:15:59Z rudolfkoenig $<br>
|
||||
# $Id: 10_CUL_HM.pm 3378 2013-07-02 16:57:27Z martinp876 $<br>
|
||||
</code>
|
||||
</ul>
|
||||
</ul>
|
||||
<!-- commands end - diese Zeile nicht entfernen! -->
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user