summaryrefslogtreecommitdiff
path: root/utils/rd-show
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rd-show')
-rwxr-xr-xutils/rd-show133
1 files changed, 69 insertions, 64 deletions
diff --git a/utils/rd-show b/utils/rd-show
index c2db583..c193f11 100755
--- a/utils/rd-show
+++ b/utils/rd-show
@@ -75,6 +75,67 @@ sub show
+sub add__check_arguments
+{
+ my ($name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
+
+ if($name !~ m/^[a-zA-Z0-9_]{1,10}$/) {
+ print STDERR "name '" . $name . "' contains illegal characters or is too long/short\n";
+ print STDERR " only a-z, A-Z, 0-9 and _ are allowed and the length must be between 1 and 10\n";
+ return 1;
+ }
+
+ if($num_carts <= 0) {
+ print STDERR "num-carts '" . $num_carts . "' must be > 0\n";
+ return 1;
+ }
+
+ if($rhythm !~ m/^[01]{4}$/ || $rhythm eq '0000') {
+ print STDERR "rhythm '" . $rhythm . "' contains illegal characters or is too long/short\n";
+ print STDERR " only 0 or 1 are allowed and, length must be exactly 4 and it must not be '0000'\n";
+ return 1;
+ }
+
+ if($dow < 1 || $dow > 7) {
+ print STDERR "dow '" . $dow . "' is out of range, must be between 1 and 7 (1=Monday, ..., 7=Sunday)\n";
+ return 1;
+ }
+
+ if($starttime !~ m/^[0-2][0-9][0-5][0-9]$/ || $starttime > 2359) {
+ print STDERR "starttime '" . $starttime . "' is not a valid time must be HHMM\n";
+ return 1;
+ }
+
+ if($len <= 0) {
+ print STDERR "len '" . $len . "' must be > 0\n";
+ return 1;
+ }
+
+ return 0;
+}
+
+sub add__get_show_carts
+{
+ my ($ctx, $groupname, $num_carts) = @_;
+
+ my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname);
+ unless(defined $result) {
+ print STDERR $status . ": " . $errorstring . "\n";
+ return undef;
+ }
+
+ my $low_cart = 0;
+ if($result) {
+ print " > using existing group '" . $groupname . "'\n";
+ $low_cart = add__get_free_group_carts($ctx, $groupname, $num_carts);
+ } else {
+ print " > '" . $groupname . "' does not exist - creating it .. ";
+ $low_cart = add__create_group($ctx, $groupname);
+ }
+
+ return $low_cart;
+}
+
sub add__create_group
{
my ($ctx, $groupname) = @_;
@@ -121,7 +182,7 @@ sub add__get_free_group_carts
return undef;
}
- my @dropboxes = RHRD::rddb::get_dropboxes($ctx, 'player', $groupname, 'S');
+ my @dropboxes = RHRD::rddb::get_dropboxes($ctx, $ctx->{'config'}{'shows'}{'defaultuser'}, $groupname, 'S');
if(!defined $dropboxes[0]) {
if(defined $dropboxes[1]) {
print STDERR "$dropboxes[1]: $dropboxes[2]";
@@ -146,74 +207,13 @@ sub add__get_free_group_carts
$low_cart += 1;
}
if(($low_cart + $num_carts -1) > $high_cart) {
- print STDERR "there are not enough carts free\n";
+ print STDERR "there are not enough free carts\n";
return undef;
}
return $low_cart;
}
-sub add__get_show_carts
-{
- my ($ctx, $groupname, $num_carts) = @_;
-
- my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname);
- unless(defined $result) {
- print STDERR $status . ": " . $errorstring . "\n";
- return undef;
- }
-
- my $low_cart = 0;
- if($result) {
- print " > using existing group '" . $groupname . "'\n";
- $low_cart = add__get_free_group_carts($ctx, $groupname, $num_carts);
- } else {
- print " > '" . $groupname . "' does not exist - creating it .. ";
- $low_cart = add__create_group($ctx, $groupname);
- }
-
- return $low_cart;
-}
-
-sub add__check_arguments
-{
- my ($name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
-
- if($name !~ m/^[a-zA-Z0-9_]{1,10}$/) {
- print STDERR "name '" . $name . "' contains illegal characters or is too long/short\n";
- print STDERR " only a-z, A-Z, 0-9 and _ are allowed and the length must be between 1 and 10\n";
- return 1;
- }
-
- if($num_carts <= 0) {
- print STDERR "num-carts '" . $num_carts . "' must be > 0\n";
- return 1;
- }
-
- if($rhythm !~ m/^[01]{4}$/ || $rhythm eq '0000') {
- print STDERR "rhythm '" . $rhythm . "' contains illegal characters or is too long/short\n";
- print STDERR " only 0 or 1 are allowed and, length must be exactly 4 and it must not be '0000'\n";
- return 1;
- }
-
- if($dow < 1 || $dow > 7) {
- print STDERR "dow '" . $dow . "' is out of range, must be between 1 and 7 (1=Monday, ..., 7=Sunday)\n";
- return 1;
- }
-
- if($starttime !~ m/^[0-2][0-9][0-5][0-9]$/ || $starttime > 2359) {
- print STDERR "starttime '" . $starttime . "' is not a valid time must be HHMM\n";
- return 1;
- }
-
- if($len <= 0) {
- print STDERR "len '" . $len . "' must be > 0\n";
- return 1;
- }
-
- return 0;
-}
-
sub add
{
my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
@@ -230,8 +230,13 @@ sub add
my $high_cart = $low_cart + $num_carts - 1;
print " * will be using carts: " . $low_cart . " - " . $high_cart . "\n";
+ my ($result, $status, $errorstring) = RHRD::rddb::create_show_log($ctx, $name, $low_cart, $high_cart);
+ unless(defined $result) {
+ print STDERR $status . ": " . $errorstring . "\n";
+ return 1;
+ }
+
# TODO:
- # create log named <name> and fill with $low_cart - $high_cart
# create macro cart referencing log -> show-id
# create dropbox for: groupname, show-id, $rhythm, $dow, $starttime, $len