From 4c8c114b137aa40b4a9b75857922e7b671df9311 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Tue, 1 Jan 2008 03:08:59 +0000 Subject: fully implement get_jobs svn path=/branches/new-fu/; revision=305 --- server/scireserver.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'server') diff --git a/server/scireserver.pl b/server/scireserver.pl index fd2da34..d8e27c3 100755 --- a/server/scireserver.pl +++ b/server/scireserver.pl @@ -75,8 +75,8 @@ while(<>) { } if ($command eq "GET_JOBS") { - get_jobs(); - + my @jobs = get_jobs(); + print "OK " . join(",", @jobs) . "\n"; } elsif ($command eq "GET_JOB") { my $job = $args[0]; get_job($job); @@ -108,7 +108,6 @@ sub read_config_file { debug("Conf file $conf_file read."); } - #New clients must be registered so they can be given a key to use (perhaps for job file transfers?) for authentication. This must be allowed before identifying. sub register_client { my ($mac,$ip, $hostname) = @_; @@ -174,7 +173,6 @@ sub register_client { print "OK $digest\n"; } - #Identify the client by looking up the fingerprint in the database, and matching it up. sub identify_client { my $digest = shift; @@ -199,7 +197,6 @@ sub identify_client { } - sub get_jobs { my $query = <<'EndOfQuery'; SELECT jobs.jobid @@ -213,12 +210,14 @@ sub get_jobs { EndOfQuery debug("Query is $query"); - #$sth = $dbh->prepare($query); - #$sth->execute($client_id,$status_id); - #my $jobs_ref = $sth->fetchall_arrayref(); - #return $jobs_ref; - + $sth = $dbh->prepare($query); + $sth->execute($client_id,$status_id); + my $jobs_ref = $sth->fetchall_arrayref(); + # Don't ask me...ask the guys in #perl :P + my @jobs = map { @$_ } @$jobs_ref; + return @jobs; } + sub get_job { my $jobid = shift; #Validate your inputs! @@ -239,6 +238,7 @@ sub get_job { my $filename = "$conf{job_dir}/$client_id/queue/$jobid.job"; return "OK $filename\n"; } + sub set_job_status { my ($jobid,$status) = @_; #Validate your inputs! -- cgit v1.2.3-65-gdbad