summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2007-12-30 02:03:37 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2007-12-30 02:03:37 +0000
commitac02a394dfb80ad95f93aaa5793388d5ae1c5932 (patch)
treea027df3585c7ea3f87b728c27d81f103b9793a13 /client/scireclient.pl
parentimplement debug() and modify all current code to use it (diff)
downloadscire-ac02a394dfb80ad95f93aaa5793388d5ae1c5932.tar.gz
scire-ac02a394dfb80ad95f93aaa5793388d5ae1c5932.tar.bz2
scire-ac02a394dfb80ad95f93aaa5793388d5ae1c5932.zip
modify all code using send_command() to pass output through parse_response()
svn path=/branches/new-fu/; revision=273
Diffstat (limited to 'client/scireclient.pl')
-rwxr-xr-xclient/scireclient.pl18
1 files changed, 8 insertions, 10 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl
index c4a8efb..785cfa7 100755
--- a/client/scireclient.pl
+++ b/client/scireclient.pl
@@ -170,7 +170,6 @@ sub read_config_file {
sub register_client {
my $mac = "00:11:22:33:44:55";
my $ip = "192.168.2.3";
-# my $response = send_command("REGISTER",$mac,$ip);
my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip));
die "Could not register client $mac w/ ip $ip. got $response" if (! defined $status or $status ne "OK");
debug("Client registered. Status is pending.\n");
@@ -185,9 +184,8 @@ sub identify_client {
# my $fingerprint = $key_obj->fingerprint();
my $fingerprint = "124567890";
- my $response = send_command("IDENTIFY", $fingerprint);
- $response =~ /^(OK|ERROR)(?: (.+))?$/;
- unless ($1 and ($1 eq "OK")) {
+ my ($status, $message) = parse_response(send_command("IDENTIFY", $fingerprint));
+ unless (defined $status && $status eq "OK") {
print "Could not identify to server: $response\n";
return 0;
}
@@ -197,9 +195,8 @@ sub identify_client {
sub get_jobs {
my @existing_jobs = @_;
- my $response = send_command("GET_JOBS", @existing_jobs);
- $response =~ /^(OK|ERROR)(?: (.+))?$/;
- unless ($1 and ($1 eq "OK")) {
+ my ($status, $message) = parse_response(send_command("GET_JOBS", @existing_jobs));
+ unless (defined $status && $status eq "OK") {
print "Could not get jobs list from server: $response\n";
return 0;
}
@@ -207,11 +204,12 @@ sub get_jobs {
$jobs =~ s/\s//g; #Remove all whitespace
my @jobs_list = split(/,/, $jobs);
foreach my $job (@jobs_list) {
- my $resp = send_command("GET_JOB",$job);
+ my ($status, $message) = parse_response(send_command("GET_JOB", $job));
open(JOBFILE, ">$conf{job_dir}/queue/${job}.job") or do {
print "Could not open $conf{job_dir}/queue/${job}.job for writing: $!";
next;
};
+ # XXX: Modify this to fetch a file instead
print JOBFILE parse_response($resp);
close(JOBFILE);
debug("Fetched job $job \n");
@@ -229,7 +227,7 @@ sub scan_jobs_dir {
foreach my $job_file (@failed_jobs) {
$job_file =~ /(\d+)\.job/;
my $jobid = $1;
- my $response = send_command("SET_JOB_STATUS $jobid 'Failed'");
+ my ($status, $message) = parse_response(send_command("SET_JOB_STATUS $jobid 'Failed'"));
open(FILE, $job_file) or die "Couldn't open job file $job_file: $!";
my $job_data = join("", <FILE>);
close(FILE);
@@ -239,7 +237,7 @@ sub scan_jobs_dir {
foreach my $job_file (@done_jobs) {
$job_file =~ /(\d+)\.job/;
my $jobid = $1;
- my $response = send_command("SET_JOB_STATUS $jobid 'Done'");
+ my ($status, $message) = parse_response(send_command("SET_JOB_STATUS $jobid 'Done'"));
}
return @existing_jobs;