summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2007-12-30 01:59:45 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2007-12-30 01:59:45 +0000
commit25bf8fee994306ca7661487297244799c3e98152 (patch)
tree4642e5e775fee023c713cca4b1b5044264d9b716 /client
parentimplement parse_response() (diff)
downloadscire-25bf8fee994306ca7661487297244799c3e98152.tar.gz
scire-25bf8fee994306ca7661487297244799c3e98152.tar.bz2
scire-25bf8fee994306ca7661487297244799c3e98152.zip
implement debug() and modify all current code to use it
svn path=/branches/new-fu/; revision=272
Diffstat (limited to 'client')
-rwxr-xr-xclient/scireclient.pl20
1 files changed, 14 insertions, 6 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl
index 8b5ff0c..c4a8efb 100755
--- a/client/scireclient.pl
+++ b/client/scireclient.pl
@@ -95,7 +95,7 @@ sub send_command {
$tosend .= " \"${arg}\"";
}
}
- print "Sending: ${tosend}\n" if $conf{debug};
+ debug("Sending: ${tosend}\n");
print SERVER_STDIN "${tosend}\n";
#FIXME WE NEED A TIMEOUT HERE OF SOME SORT!!
#if the server doesn't give you a newline this just hangs!
@@ -170,9 +170,10 @@ 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);
- die "Could not register client $mac w/ ip $ip. got $response" unless ($response =~ /OK/);
- print "Client registered. Status is pending.\n";
+# 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");
}
sub identify_client {
@@ -190,7 +191,7 @@ sub identify_client {
print "Could not identify to server: $response\n";
return 0;
}
- print "Client identified\n" if $conf{debug};
+ debug("Client identified\n");
return 1;
}
@@ -213,7 +214,7 @@ sub get_jobs {
};
print JOBFILE parse_response($resp);
close(JOBFILE);
- print "Fetched job $job \n" if $conf{debug};
+ debug("Fetched job $job \n");
}
#This function doesn't actually need to do anything with the list of jobs, the executor handles that part.
}
@@ -243,3 +244,10 @@ sub scan_jobs_dir {
return @existing_jobs;
}
+
+sub debug {
+ my $msg = shift;
+ if($conf{debug}) {
+ print STDERR $msg;
+ }
+}