diff options
author | Preston Cody <codeman@gentoo.org> | 2008-01-02 02:03:43 +0000 |
---|---|---|
committer | Preston Cody <codeman@gentoo.org> | 2008-01-02 02:03:43 +0000 |
commit | f5f0de98906efb62a9376c0504f4320426b96d5a (patch) | |
tree | fdcb5d96a279d59c448cce4359e04d4a451cf4f4 | |
parent | add debug to response line (diff) | |
download | scire-f5f0de98906efb62a9376c0504f4320426b96d5a.tar.gz scire-f5f0de98906efb62a9376c0504f4320426b96d5a.tar.bz2 scire-f5f0de98906efb62a9376c0504f4320426b96d5a.zip |
fixed get_jobs.
coded get_job. but there seems to be a problem with it.
commented out most of it for now, still doesn't work.
svn path=/branches/new-fu/; revision=311
-rwxr-xr-x | server/scireserver.pl | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl index 9329f5c..8e49ee7 100755 --- a/server/scireserver.pl +++ b/server/scireserver.pl @@ -7,6 +7,8 @@ use warnings; use DBI; use Data::Dumper; use Digest::MD5 qw(md5 md5_hex ); +use File::Path; +use XML::Dumper; $| = 1; @@ -198,21 +200,23 @@ sub identify_client { } sub get_jobs { - my $status_id = shift; + + #FIXME expand jobs for $client_id + my $query = <<'EndOfQuery'; SELECT jobs.jobid - FROM jobs NATURAL JOIN jobs_clients NATURAL JOIN job_conditions NATURAL JOIN job_history + FROM jobs NATURAL JOIN jobs_clients NATURAL JOIN job_conditions WHERE jobs_clients.clientid = ? AND jobs.jobid = jobs_clients.jobid AND (job_conditions.deploy_time < now()) - AND (job_conditions.expiration_time > now()) - AND (SELECT statusid FROM job_history WHERE jobid=jobs.jobid ORDER BY eventtime DESC LIMIT 1)=? + AND ((job_conditions.expiration_time > now()) OR (job_conditions.expiration_time IS NULL)) ORDER BY jobs.priority,jobs.created EndOfQuery + #FIXME ADD JOB DEPENDENCIES TO THIS QUERY. debug("Query is $query"); - $sth = $dbh->prepare($query); - $sth->execute($client_id, $status_id); + my $sth = $dbh->prepare($query); + $sth->execute($client_id); my $jobs_ref = $sth->fetchall_arrayref(); # Don't ask me...ask the guys in #perl :P my @jobs = map { @$_ } @$jobs_ref; @@ -224,19 +228,31 @@ sub get_job { #Validate your inputs! my $query = 'SELECT * FROM jobs LEFT JOIN job_conditions on (jobs.jobid) WHERE jobs.jobid = ?'; debug("Query is $query"); - #my $sth = $dbh->prepare($query); - #$sth->execute($jobid); - #my $job = $sth->fetchrow_hashref(); - #my $scriptid = $job{'script'}; +# my $sth = $dbh->prepare($query); +# $sth->execute($jobid); +# my $job = $sth->fetchrow_hashref(); +# my $scriptid = $job->{'script'}; $query = 'SELECT * FROM scripts WHERE scriptid=?'; debug("Query is $query"); - #$sth = $dbh->prepare($query); - #$sth->execute($scriptid); - #$job{'script'} = $sth->fetchrow_hashref(); +# $sth = $dbh->prepare($query); +# $sth->execute($scriptid); +# $job->{'script'} = $sth->fetchrow_hashref(); +# debug(Dumper($job)); #Write the job w/ all data to a jobfile with the following path /JOBDIR/CLIENT_ID/queue/JOBID.job - my $filename = "$conf{job_dir}/$client_id/queue/$jobid.job"; + my $path = "$conf{job_dir}/$client_id/queue"; + my $filename = "$path/$jobid.job"; +# unless (-d $path) { +# print "WARNING! $path does not exist...creating\n"; +# mkpath( $path, {verbose => 1, mode => 0660}) +# or die("Couldn't make $path w/ perms 0660: $!"); +# } +# open(FH, ">$filename") or die("Couldn't open $filename: $!"); +# my $xml = pl2xml( $job ); +# print FH $xml."\n"; +# close(FH) or die("Couldn't close $filename : $!"); + debug("OK $filename\n"); return "OK $filename\n"; } |