summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2017-01-11 15:51:39 (GMT)
committerChristian Pointner <equinox@helsinki.at>2017-01-11 15:57:11 (GMT)
commitf986b2d95200eed6f87b2171165e268fc27fad7c (patch)
tree479f7a2c5c4f33e061cc58c6b24d52267d7cda0f
parent6f1430c4bc4216d6c074656a8ac907bd653e9c91 (diff)
add show group sanity check
-rwxr-xr-xlib/RHRD/utils.pm2
-rwxr-xr-xutils/rhrd-sanity-check1
-rwxr-xr-xutils/rhrd-show34
3 files changed, 32 insertions, 5 deletions
diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm
index ad8e7b8..a4bef22 100755
--- a/lib/RHRD/utils.pm
+++ b/lib/RHRD/utils.pm
@@ -292,7 +292,7 @@ sub pv_execute_action
my $err_out = join('', <$error>);
my $read_out = join('', <$reader>);
if ( $? >> 8 ) {
- my $log = "\n\nPV: adding note returned non-zero value\n";
+ my $log = "\n\nPV: executing action returned non-zero value\n";
$log .= "STDERR:\n" . $err_out . "\n" unless $err_out eq '';
$log .= "STDOUT:\n" . $read_out . "\n" unless $read_out eq '';
return(1, $log);
diff --git a/utils/rhrd-sanity-check b/utils/rhrd-sanity-check
index 20179d1..cdfa0b4 100755
--- a/utils/rhrd-sanity-check
+++ b/utils/rhrd-sanity-check
@@ -271,6 +271,7 @@ sub check_groups
for my $group (@groups) {
next if($group eq $ctx->{'config'}{'specialgroups'}{'system'});
next if($group eq $ctx->{'config'}{'specialgroups'}{'shows'});
+ next if($group eq $ctx->{'config'}{'specialgroups'}{'multishows'});
next if($group eq $ctx->{'config'}{'specialgroups'}{'allshows'});
next if($group eq $ctx->{'config'}{'specialgroups'}{'allpools'});
next if($group eq $ctx->{'config'}{'specialgroups'}{'alljingles'});
diff --git a/utils/rhrd-show b/utils/rhrd-show
index 5ed0f4b..0d4ad58 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -163,6 +163,30 @@ sub add__check_arguments
return 0;
}
+sub add__check_showgroup
+{
+ my ($ctx, $groupname) = @_;
+
+ my ($low_cart, $high_cart, $errorstring) = RHRD::rddb::get_group_cart_range($ctx, $groupname);
+ unless(defined $low_cart) {
+ print STDERR "$errorstring\n";
+ return 1;
+ }
+
+ (my $shows_low_cart, my $shows_high_cart, $errorstring) = RHRD::rddb::get_shows_cart_range($ctx);
+ unless(defined $shows_low_cart) {
+ print STDERR "$errorstring\n";
+ return 1;
+ }
+
+ if($shows_low_cart > $low_cart || $shows_high_cart < $high_cart) {
+ print STDERR "group '" . $groupname . "' already exists but is not a show group\n";
+ return 1;
+ }
+
+ return 0;
+}
+
sub add
{
my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len, $type) = @_;
@@ -173,8 +197,6 @@ sub add
}
($dow, undef, undef) = RHRD::utils::cmdline_dow($dow);
- print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n";
-
my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname);
unless(defined $result) {
print STDERR $status . ": " . $errorstring . "\n";
@@ -183,10 +205,14 @@ sub add
my $low_cart = 0;
if($result) {
- print " * using existing group '" . $groupname . "'\n";
+ my $ret = add__check_showgroup($ctx, $groupname);
+ if($ret) {
+ return $ret;
+ }
+ print " * creating show: " . $title . " (" . $name . ") using existing group '" . $groupname . "'\n";
($low_cart, $status, $errorstring) = RHRD::rddb::get_next_free_show_group_carts($ctx, $groupname, $num_carts);
} else {
- print " * '" . $groupname . "' does not exist - creating it\n";
+ print " * creating show: " . $title . " (" . $name . ") using new group '" . $groupname . "'\n";
($low_cart, $status, $errorstring) = RHRD::rddb::create_show_group($ctx, $groupname);
}
unless(defined $low_cart) {