Francois Gouget : testbot/cgi: Add an API to set the page refresh interval.
Alexandre Julliard
julliard at winehq.org
Tue Mar 29 15:04:24 CDT 2022
Module: tools
Branch: master
Commit: ec4067265bf29f770ace4119572c04067ce6bc7d
URL: https://source.winehq.org/git/tools.git/?a=commit;h=ec4067265bf29f770ace4119572c04067ce6bc7d
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Mar 29 18:00:15 2022 +0200
testbot/cgi: Add an API to set the page refresh interval.
It can be called early, removing the need to override GeneratePage()
just for that purpose.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/ObjectModel/CGI/Page.pm | 19 +++++++++++++++++++
testbot/lib/WineTestBot/CGI/PageBase.pm | 15 ++++++++++++++-
testbot/web/Activity.pl | 8 ++++----
testbot/web/JobDetails.pl | 16 ++++------------
testbot/web/PatchesList.pl | 10 +---------
testbot/web/index.pl | 15 ++++-----------
6 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/Page.pm b/testbot/lib/ObjectModel/CGI/Page.pm
index 700268a..c5f8a33 100644
--- a/testbot/lib/ObjectModel/CGI/Page.pm
+++ b/testbot/lib/ObjectModel/CGI/Page.pm
@@ -141,6 +141,25 @@ sub escapeHTML($$)
return $self->{CGIObj}->escapeHTML($String);
}
+=pod
+=over 12
+
+=head1 C<SetRefreshInterval()>
+
+Sets the page refresh interval in seconds.
+
+This can be called at any point before GenerateHttpHeaders().
+
+=back
+=cut
+
+sub SetRefreshInterval($$)
+{
+ my ($self, $Seconds) = @_;
+
+ $self->{PageBase}->SetRefreshInterval($Seconds);
+}
+
#
# CGI parameters support
diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm
index 695dde3..e87e1d6 100644
--- a/testbot/lib/WineTestBot/CGI/PageBase.pm
+++ b/testbot/lib/WineTestBot/CGI/PageBase.pm
@@ -81,7 +81,8 @@ sub new($$$$@)
my ($Page, $Request, $RequiredRole) = @_;
my $self = {Request => $Request,
- Session => undef};
+ Session => undef,
+ Refresh => undef};
$self = bless $self, $class;
if (defined($RequiredRole) && $RequiredRole ne "")
@@ -111,6 +112,13 @@ sub CreatePageBase($$$@)
return WineTestBot::CGI::PageBase->new(@_);
}
+sub SetRefreshInterval($$)
+{
+ my ($self, $Seconds) = @_;
+
+ $self->{Refresh} = $Seconds;
+}
+
#
# Session management
@@ -363,6 +371,11 @@ sub GenerateHttpHeaders($)
# HTTP/1.0
$Request->headers_out->add("Pragma", "no-cache");
+ if ($self->{Refresh})
+ {
+ $self->{Request}->headers_out->add("Refresh", $self->{Refresh});
+ }
+
# Force char set
$Request->content_type("text/html; charset=UTF-8");
diff --git a/testbot/web/Activity.pl b/testbot/web/Activity.pl
index d98f50a..cbe3f87 100644
--- a/testbot/web/Activity.pl
+++ b/testbot/web/Activity.pl
@@ -56,6 +56,10 @@ sub _initialize($$$)
# either).
$self->SetParam("Hours", $HOURS_DEFAULT);
}
+ if ($self->GetParam("Hours") <= $HOURS_DEFAULT)
+ {
+ $self->SetRefreshInterval(60);
+ }
}
sub GetPageTitle($$)
@@ -69,10 +73,6 @@ sub GeneratePage($)
{
my ($self) = @_;
- if ($self->GetParam("Hours") <= $HOURS_DEFAULT)
- {
- $self->{Request}->headers_out->add("Refresh", "60");
- }
$self->SUPER::GeneratePage();
}
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 8d93957..5e302c0 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -57,6 +57,10 @@ sub _initialize($$$)
$self->{JobId} = $JobId;
$self->SUPER::_initialize($Request, $RequiredRole, CreateStepsTasks(undef, $self->{Job}));
+ if ($self->{Job}->Status =~ /^(?:queued|running)$/)
+ {
+ $self->SetRefreshInterval(30);
+ }
}
sub GetPageTitle($)
@@ -241,18 +245,6 @@ sub SortKeys($$$)
return \@SortedKeys;
}
-sub GeneratePage($)
-{
- my ($self) = @_;
-
- if ($self->{Job}->Status =~ /^(queued|running)$/)
- {
- $self->{Request}->headers_out->add("Refresh", "30");
- }
-
- $self->SUPER::GeneratePage();
-}
-
sub InitMoreInfo($)
{
my ($self) = @_;
diff --git a/testbot/web/PatchesList.pl b/testbot/web/PatchesList.pl
index 6728a28..04ca020 100644
--- a/testbot/web/PatchesList.pl
+++ b/testbot/web/PatchesList.pl
@@ -33,6 +33,7 @@ sub _initialize($$$)
my ($self, $Request, $RequiredRole) = @_;
$self->SUPER::_initialize($Request, $RequiredRole, CreatePatches());
+ $self->SetRefreshInterval(60);
}
sub SortKeys($$$)
@@ -65,15 +66,6 @@ sub GetActions($$)
return [];
}
-sub GeneratePage($)
-{
- my ($self) = @_;
-
- $self->{Request}->headers_out->add("Refresh", "60");
-
- $self->SUPER::GeneratePage();
-}
-
sub GenerateDataCell($$$$$)
{
my ($self, $CollectionBlock, $Item, $PropertyDescriptor, $DetailsPage) = @_;
diff --git a/testbot/web/index.pl b/testbot/web/index.pl
index 451258e..1f362fc 100644
--- a/testbot/web/index.pl
+++ b/testbot/web/index.pl
@@ -268,6 +268,10 @@ sub _initialize($$$)
# Replace with the default value so the cutoff can be calculated
$self->SetParam("Days", $DAYS_DEFAULT);
}
+ if (!$self->GetErrMessage() and $self->GetParam("Days") <= $DAYS_DEFAULT)
+ {
+ $self->SetRefreshInterval(60);
+ }
# The action is a no-op so unset it to not need to redefine OnAction()
$self->SetParam("Action", undef);
}
@@ -280,17 +284,6 @@ sub OutputDot($$)
"width='20' height='20' />";
}
-sub GeneratePage($)
-{
- my ($self) = @_;
-
- if (!$self->GetErrMessage() and $self->GetParam("Days") <= $DAYS_DEFAULT)
- {
- $self->{Request}->headers_out->add("Refresh", "60");
- }
- $self->SUPER::GeneratePage();
-}
-
sub GenerateBody($)
{
my ($self) = @_;
More information about the wine-cvs
mailing list