Changeset 18587 for trunk/pstamp/scripts/dqueryparse.pl
- Timestamp:
- Jul 16, 2008, 3:27:19 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/dqueryparse.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/dqueryparse.pl
r18540 r18587 5 5 # Note: this file is currently only a placeholder which creates a fake response file 6 6 # and adds a completed job to the database 7 #8 # TODO: split off the actual generation of the response file into a standalone program9 7 # 10 8 … … 28 26 ); 29 27 30 my ($ uri, $out_dir, $mode, $req_id, $verbose, $save_temps);28 my ($req_file, $req_id, $out_dir, $product, $mode, $dbname, $verbose, $save_temps); 31 29 32 30 # … … 35 33 36 34 GetOptions( 37 'uri=s' => \$uri, 35 'file=s' => \$req_file, 36 'req_id=s' => \$req_id, 38 37 'out_dir=s' => \$out_dir, 38 'product=s' => \$product, 39 'mode=s' => \$mode, 40 'dbname=s' => \$dbname, 39 41 'verbose' => \$verbose, 40 'mode=s' => \$mode,41 'req_id=s' => \$req_id,42 42 'save-temps' => \$save_temps, 43 'verbose' => \$verbose,44 43 ) or pod2usage(2); 45 44 46 45 my $err = ""; 47 46 48 if (!$uri) { 49 $err .= "--uri is required\n"; 47 if (!$req_file) { 48 $err .= "--file is required\n"; 49 } 50 if (!$req_id) { 51 $err .= "--req_id is required\n"; 50 52 } 51 53 if (!$out_dir) { 52 54 $err .="--out_dir is required\n"; 53 55 } 56 if (!$product) { 57 $err .="--product is required\n"; 58 } 54 59 55 if (!$req_id) {56 $err .= "--req_id is required\n";57 }58 60 59 61 die $err if ($err); … … 62 64 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools =1); 63 65 my $fakedresponse = can_run('fakedresponse.pl') or (warn "Can't find fakedresponse.pl" and $missing_tools =1); 66 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools =1); 64 67 65 68 if ($missing_tools) { … … 68 71 } 69 72 73 # get the query id and check the extname and version from the header 74 my $fields_output; 75 { 76 my $command = "echo $req_file | $fields -x 0 EXTNAME EXTVER QUERY_ID"; 77 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 78 run(command => $command, verbose => $verbose); 79 80 # fields doesn't return zero when it succeeds 81 # unless ($success) { 82 # print STDERR @$stderr_buf; 83 # } 84 $fields_output = join "", @$stdout_buf; 85 } 86 my (undef, $extname, $extver, $req_name) = split " ", $fields_output; 87 88 die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table" 89 if $extname ne "MOPS_DETECTABILITY_QUERY"; 90 die "$req_file does not have a QUERY_ID" if ! $req_name; 91 die "$req_file is version $extver expecting 1" if $extver ne 1; 92 93 $out_dir .= "/$req_name"; 94 if (! -e $out_dir ) { 95 mkdir $out_dir or die "cannot create output directory $out_dir"; 96 } elsif (! -d $out_dir ) { 97 die "output fileset directory $out_dir exists but is not a directory"; 98 } 99 100 # 101 # we don't parse the file here, pass it to fakedresponse it will create a response for each 102 # row in the file 70 103 my $response_file = "$out_dir/response.fits"; 71 104 my $fault; 72 105 { 73 my $command = "$fakedresponse --input $ uri--output $response_file --workdir $out_dir";106 my $command = "$fakedresponse --input $req_file --output $response_file --workdir $out_dir"; 74 107 $command .= " --save-temps" if $save_temps; 75 108 $command .= " --verbose" if $verbose; … … 84 117 85 118 my $job_id; 119 my $result; 86 120 { 87 my $command = "$pstamptool -addjob -req_id $req_id -uri $uri -outputBase $out_dir -job_type detect_query"; 88 $command .= " -state stop -fault $fault"; 121 my $command = "$pstamptool -addjob -req_id $req_id -uri $req_file -outputBase $out_dir"; 122 $command .= " -job_type detect_query -state stop -fault $fault"; 123 $command .= " -rownum 1"; 124 $command .= " -dbname $dbname" if $dbname; 89 125 90 126 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 101 137 } 102 138 103 exit $result; 139 { 140 my $command = "$pstamptool -processedreq -req_id $req_id -name $req_name -outProduct $product"; 141 $command .= " -fault $result" if $result; 142 $command .= " -dbname $dbname" if $dbname; 104 143 105 106 107 108 sub fake_dquery_response { 109 my $line = shift; 110 my ($rownum, $ra1, $dec1, $ra2, $dec2, $mag) = split " ", $line; 111 112 # todo perhaps think more about these values 113 my $n = rand(16); 114 my $f = rand(1); 115 116 return ($rownum, $n, $f); 144 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 145 run(command => $command, verbose => $verbose); 146 unless ($success) { 147 die "$command failed"; 148 } 117 149 } 150 151 exit 0;
Note:
See TracChangeset
for help on using the changeset viewer.
