snapshot monitor tool:

* allow 2 hour time difference
* centralized fpc and lazarus version numbers

git-svn-id: trunk@11127 -
This commit is contained in:
vincents 2007-05-11 16:38:16 +00:00
parent 0312cb2ee4
commit 52d30339d8
6 changed files with 98 additions and 45 deletions

View File

@ -15,7 +15,6 @@
</VersionInfo> </VersionInfo>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>

View File

@ -14,7 +14,6 @@
</VersionInfo> </VersionInfo>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>

View File

@ -5,7 +5,7 @@ unit MonitorCfg;
interface interface
uses uses
contnrs, dom, xmlread; strutils, contnrs, dom, xmlread;
type type
TServerType = (stFtp, stHttp); TServerType = (stFtp, stHttp);
@ -13,21 +13,33 @@ type
TServer = class; TServer = class;
TFile = class; TFile = class;
TReplaceStringEvent = function (const value: string):string of object;
{ TMonitorConfig } { TMonitorConfig }
TMonitorConfig = class TMonitorConfig = class
private private
FFileName: string; FFileName: string;
FFPCDevelVersion: string;
FFPCFixesVersion: string;
FFPCReleaseVersion: string;
FLazVersion: string;
FServers: TFPObjectList; FServers: TFPObjectList;
function GetServer(index: integer): TServer; function GetServer(index: integer): TServer;
function GetServerCount: integer; function GetServerCount: integer;
procedure AddServer(const ServerNode: TDOMNode); procedure AddServer(const ServerNode: TDOMNode);
procedure ReadVersions(const VersionNode: TDOMNode);
function ServerReplaceString(const value: string): string;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Load(const AFileName: string); procedure Load(const AFileName: string);
procedure AddServer(AServer: TServer); procedure AddServer(AServer: TServer);
property FileName: string read FFileName write FFileName; property FileName: string read FFileName write FFileName;
property LazVersion: string read FLazVersion;
property FPCReleaseVersion: string read FFPCReleaseVersion;
property FPCFixesVersion: string read FFPCFixesVersion;
property FPCDevelVersion: string read FFPCDevelVersion;
property Servers[index: integer] : TServer read GetServer; property Servers[index: integer] : TServer read GetServer;
property ServerCount: integer read GetServerCount; property ServerCount: integer read GetServerCount;
end; end;
@ -38,6 +50,7 @@ type
private private
FFiles: TFPObjectList; FFiles: TFPObjectList;
FDescription: string; FDescription: string;
FOnReplaceString: TReplaceStringEvent;
FServerType: TServerType; FServerType: TServerType;
function GetFile(index: integer): TFile; function GetFile(index: integer): TFile;
function GetFileCount: integer; function GetFileCount: integer;
@ -50,6 +63,7 @@ type
property ServerType : TServerType read FServerType write FServerType; property ServerType : TServerType read FServerType write FServerType;
property Files[index: integer] : TFile read GetFile; property Files[index: integer] : TFile read GetFile;
property FileCount: integer read GetFileCount; property FileCount: integer read GetFileCount;
property OnReplaceString: TReplaceStringEvent read FOnReplaceString write FOnReplaceString;
end; end;
{ TFile } { TFile }
@ -66,6 +80,15 @@ type
implementation implementation
function GetAttributeValue(const ANode: TDomNode; const AName: string): string;
var
Attribute: TDOMNode;
begin
Attribute := ANode.Attributes.GetNamedItem(AName);
if assigned(Attribute) then
Result := Attribute.NodeValue;
end;
{ TServer } { TServer }
function TServer.GetFile(index: integer): TFile; function TServer.GetFile(index: integer): TFile;
@ -81,15 +104,11 @@ end;
procedure TServer.AddFile(const ServerNode: TDOMNode); procedure TServer.AddFile(const ServerNode: TDOMNode);
var var
NewFile: TFile; NewFile: TFile;
Attribute: TDOMNode;
begin begin
NewFile := TFile.Create; NewFile := TFile.Create;
Attribute := ServerNode.Attributes.GetNamedItem('Description'); NewFile.Description := OnReplaceString(GetAttributeValue(ServerNode, 'Description'));
if assigned(Attribute) then NewFile.Mask := OnReplaceString(GetAttributeValue(ServerNode, 'Mask'));
NewFile.Description := Attribute.NodeValue;
Attribute := ServerNode.Attributes.GetNamedItem('Mask');
if assigned(Attribute) then
NewFile.Mask := Attribute.NodeValue;
AddFile(NewFile); AddFile(NewFile);
end; end;
@ -134,6 +153,7 @@ var
Node: TDomNode; Node: TDomNode;
begin begin
Server := TServer.Create; Server := TServer.Create;
Server.OnReplaceString := @ServerReplaceString;
Attribute := ServerNode.Attributes.GetNamedItem('Name'); Attribute := ServerNode.Attributes.GetNamedItem('Name');
if assigned(Attribute) then if assigned(Attribute) then
Server.Description := Attribute.NodeValue; Server.Description := Attribute.NodeValue;
@ -152,6 +172,22 @@ begin
AddServer(Server); AddServer(Server);
end; end;
procedure TMonitorConfig.ReadVersions(const VersionNode: TDOMNode);
begin
FLazVersion := GetAttributeValue(VersionNode, 'Lazarus');
FFPCReleaseVersion := GetAttributeValue(VersionNode, 'FPC_Release');
FFPCFixesVersion := GetAttributeValue(VersionNode, 'FPC_Fixes');
FFPCDevelVersion := GetAttributeValue(VersionNode, 'FPC_Devel');
end;
function TMonitorConfig.ServerReplaceString(const value: string): string;
begin
Result := AnsiReplaceStr(Value, '$LAZVER', LazVersion);
Result := AnsiReplaceStr(Result, '$FPCRELEASEVER', FPCReleaseVersion);
Result := AnsiReplaceStr(Result, '$FPCFIXESVER', FPCFixesVersion);
Result := AnsiReplaceStr(Result, '$FPCDEVELVER', FPCDevelVersion);
end;
constructor TMonitorConfig.Create; constructor TMonitorConfig.Create;
begin begin
FServers := TFPObjectList.Create; FServers := TFPObjectList.Create;
@ -175,7 +211,9 @@ begin
Node := XmlDoc.DocumentElement.FirstChild; Node := XmlDoc.DocumentElement.FirstChild;
while Node<>nil do begin while Node<>nil do begin
if Node.NodeName='Server' then if Node.NodeName='Server' then
AddServer(Node); AddServer(Node)
else if Node.NodeName='Version' then
ReadVersions(Node);
Node := Node.NextSibling; Node := Node.NextSibling;
end; end;
finally finally

View File

@ -1,73 +1,79 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<CONFIG LazVersion="0.9.21"> <CONFIG>
<Version
Lazarus="0.9.23"
FPC_Release="2.0.4"
FPC_Fixes="2.1.5"
FPC_Devel="2.3.1"
/>
<Server Type="ftp" Name="Snapshot on scenergy"> <Server Type="ftp" Name="Snapshot on scenergy">
<File <File
Mask="lazarus-0.9.23-*-src.zip" Mask="lazarus-$LAZVER-*-src.zip"
Description="Lazarus source zip" Description="Lazarus source zip"
/> />
<File <File
Mask="lazarus-0.9.23-*-src.tar.bz2" Mask="lazarus-$LAZVER-*-src.tar.bz2"
Description="Lazarus source bzip2" Description="Lazarus source bzip2"
/> />
<File <File
Mask="Lazarus-0.9.23-fpc-2.0.4-*-win32.exe" Mask="Lazarus-$LAZVER-fpc-$FPCRELEASEVER-*-win32.exe"
Description="Lazarus win32 fpc 2.0.4" Description="Lazarus win32 with fpc fixes branch ($FPCRELEASEVER)"
/> />
<File <File
Mask="Lazarus-0.9.23-fpc-2.1.3-*-win32.exe" Mask="Lazarus-$LAZVER-fpc-$FPCFIXESVER-*-win32.exe"
Description="Lazarus win32 fpc 2.1.3" Description="Lazarus win32 with fpc fixes branch ($FPCFIXESVER)"
/> />
<File <File
Mask="Lazarus-0.9.23-fpc-2.1.3-*-win64.exe" Mask="Lazarus-$LAZVER-fpc-$FPCFIXESVER-*-win64.exe"
Description="Lazarus win64 fpc 2.1.3" Description="Lazarus win64 with fpc fixes branch ($FPCFIXESVER)"
/> />
<File <File
Mask="fpc-2.0.4-*-powerpc-macosx.dmg" Mask="fpc-$FPCRELEASEVER-*-powerpc-macosx.dmg"
Description="fpc 2.0.4 Mac OS X powerpc" Description="fpc $FPCRELEASEVER Mac OS X powerpc"
/> />
<File <File
Mask="fpcsrc-2.0.4-*-powerpc-macosx.dmg" Mask="fpcsrc-$FPCRELEASEVER-*-powerpc-macosx.dmg"
Description="fpc source 2.0.4 Mac OS X powerpc" Description="fpc source $FPCRELEASEVER Mac OS X powerpc"
/> />
<File <File
Mask="lazarus-0.9.23-*-powerpc-macosx.dmg" Mask="lazarus-$LAZVER-*-powerpc-macosx.dmg"
Description="lazarus Mac OS X powerpc" Description="lazarus Mac OS X powerpc"
/> />
<File <File
Mask="fpc-2.1.3-*-i386-macosx.dmg" Mask="fpc-$FPCFIXESVER-*-i386-macosx.dmg"
Description="fpc 2.1.3 Mac OS X i386" Description="fpc $FPCFIXESVER Mac OS X i386"
/> />
<File <File
Mask="fpcsrc-2.1.3-*-i386-macosx.dmg" Mask="fpcsrc-$FPCFIXESVER-*-i386-macosx.dmg"
Description="fpc source 2.1.3 Mac OS X i386" Description="fpc source $FPCFIXESVER Mac OS X i386"
/> />
<File <File
Mask="lazarus-0.9.23-*-i386-macosx.dmg" Mask="lazarus-$LAZVER-*-i386-macosx.dmg"
Description="lazarus Mac OS X i386" Description="lazarus Mac OS X i386"
/> />
<File <File
Mask="fpc-2.0.4-*.src.rpm" Mask="fpc-$FPCRELEASEVER-*.src.rpm"
Description="fpc 2.0.4 source rpm" Description="fpc $FPCRELEASEVER source rpm"
/> />
<File <File
Mask="fpc-2.0.4-*.i386.rpm" Mask="fpc-$FPCRELEASEVER-*.i386.rpm"
Description="fpc 2.0.4 i386 rpm" Description="fpc $FPCRELEASEVER i386 rpm"
/> />
<File <File
Mask="fpc-src-2.0.4-*.i386.rpm" Mask="fpc-src-$FPCRELEASEVER-*.i386.rpm"
Description="fpc source 2.0.4 i386 rpm" Description="fpc source $FPCRELEASEVER i386 rpm"
/> />
<File <File
Mask="lazarus-*.i386.rpm" Mask="lazarus-*.i386.rpm"
Description="lazarus i386 rpm" Description="lazarus i386 rpm"
/> />
<File <File
Mask="fpc-2.0.4-*.x86_64.rpm" Mask="fpc-$FPCRELEASEVER-*.x86_64.rpm"
Description="fpc 2.0.4 x86_64 rpm" Description="fpc $FPCRELEASEVER x86_64 rpm"
/> />
<File <File
Mask="fpc-src-2.0.4-*.x86_64.rpm" Mask="fpc-src-$FPCRELEASEVER-*.x86_64.rpm"
Description="fpc source 2.0.4 x86_64 rpm" Description="fpc source $FPCRELEASEVER x86_64 rpm"
/> />
<File <File
Mask="lazarus-*.x86_64.rpm" Mask="lazarus-*.x86_64.rpm"

View File

@ -121,7 +121,7 @@ begin
FtpFile := TFtpFile(MatchingFiles.Objects[0]); FtpFile := TFtpFile(MatchingFiles.Objects[0]);
AssertTrue( AssertTrue(
FtpFile.FileName +' is too old: ' + DateTimeToStr(FtpFile.FileDate), FtpFile.FileName +' is too old: ' + DateTimeToStr(FtpFile.FileDate),
(Now - FtpFile.FileDate) < 1.0); (Now - FtpFile.FileDate) < (26/24));
end; end;
procedure InitFromXml; procedure InitFromXml;

View File

@ -9,6 +9,8 @@ uses
type type
{ TTestMonitorCfg }
TTestMonitorCfg= class(TTestCase) TTestMonitorCfg= class(TTestCase)
private private
FMonitorCfg: TMonitorConfig; FMonitorCfg: TMonitorConfig;
@ -17,6 +19,7 @@ type
procedure TearDown; override; procedure TearDown; override;
published published
procedure Test; procedure Test;
procedure TestVersion;
end; end;
implementation implementation
@ -25,17 +28,25 @@ procedure TTestMonitorCfg.Test;
var var
Server : TServer; Server : TServer;
begin begin
FMonitorCfg.Load('monitorconfig.xml');
AssertEquals('Wrong number of servers', 1, FMonitorCfg.ServerCount); AssertEquals('Wrong number of servers', 1, FMonitorCfg.ServerCount);
Server := FMonitorCfg.Servers[0]; Server := FMonitorCfg.Servers[0];
AssertEquals(ord(stFtp), ord(Server.ServerType)); AssertEquals(ord(stFtp), ord(Server.ServerType));
AssertEquals('Snapshot on scenergy', Server.Description); AssertEquals('Snapshot on scenergy', Server.Description);
AssertEquals('Wrong number of files', 7, Server.FileCount); AssertEquals('Wrong number of files', 18, Server.FileCount);
end;
procedure TTestMonitorCfg.TestVersion;
begin
AssertEquals('Wrong Lazarus Version', '0.9.23', FMonitorCfg.LazVersion);
AssertEquals('Wrong FPC Release Version', '2.0.4', FMonitorCfg.FPCReleaseVersion);
AssertEquals('Wrong FPC Fixes Version', '2.1.5', FMonitorCfg.FPCFixesVersion);
AssertEquals('Wrong FPC Devel Version', '2.3.1', FMonitorCfg.FPCDevelVersion);
end; end;
procedure TTestMonitorCfg.SetUp; procedure TTestMonitorCfg.SetUp;
begin begin
FMonitorCfg := TMonitorConfig.Create; FMonitorCfg := TMonitorConfig.Create;
FMonitorCfg.Load('monitorconfig.xml');
end; end;
procedure TTestMonitorCfg.TearDown; procedure TTestMonitorCfg.TearDown;
@ -45,6 +56,6 @@ end;
initialization initialization
//RegisterTest(TTestMonitorCfg); RegisterTest(TTestMonitorCfg);
end. end.