use IPC::System::Simple::capturex instead of system()
authorTom Clegg <tom@clinicalfuture.com>
Wed, 5 Jun 2013 20:46:52 +0000 (16:46 -0400)
committerTom Clegg <tom@clinicalfuture.com>
Wed, 5 Jun 2013 20:46:52 +0000 (16:46 -0400)
services/crunch/crunch-job

index ed2c059a11aaea0475dfa9032e7416a636249a75..72563e68adb0254eaf6f262ca8d2e076c8b1aa90 100755 (executable)
@@ -55,6 +55,7 @@ use Arvados;
 use Getopt::Long;
 use Warehouse;
 use Warehouse::Stream;
 use Getopt::Long;
 use Warehouse;
 use Warehouse::Stream;
+use IPC::System::Simple qw(capturex);
 
 $ENV{"TMPDIR"} ||= "/tmp";
 $ENV{"CRUNCH_TMP"} = $ENV{"TMPDIR"} . "/crunch-job";
 
 $ENV{"TMPDIR"} ||= "/tmp";
 $ENV{"CRUNCH_TMP"} = $ENV{"TMPDIR"} . "/crunch-job";
@@ -686,10 +687,16 @@ $Job->save;
 
 if ($Job->{'output'})
 {
 
 if ($Job->{'output'})
 {
-  $arv->{'collections'}->{'create'}->execute('collection' => {
-    'uuid' => $Job->{'output'},
-    'manifest_text' => system("whget", $Job->{'output'}),
-  });
+  eval {
+    my $manifest_text = capturex("whget", $Job->{'output'});
+    $arv->{'collections'}->{'create'}->execute('collection' => {
+      'uuid' => $Job->{'output'},
+      'manifest_text' => $manifest_text,
+    });
+  };
+  if ($@) {
+    Log (undef, "Failed to register output manifest: $@");
+  }
 }
 
 Log (undef, "finish");
 }
 
 Log (undef, "finish");