Просмотр исходного кода

Wrap the relevent portion of Run.pm into Transmission.pl

Zachary Kotlarek 14 лет назад
Родитель
Сommit
4e8e1a3556
2 измененных файлов с 20 добавлено и 96 удалено
  1. 0 95
      Run.pm
  2. 20 1
      transmission.pl

+ 0 - 95
Run.pm

@@ -1,95 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-
-#-----------------------------------------------------------------------------
-## @file Run.pm
-#  @brief A module for running perl scripts in threaded environment
-#  @see Run.pm
-
-## @class Run
-
-
-# Package
-package Run;
-
-# Globals
-my $DEBUG = 0;
-
-#----------------------------------------------------------------------
-## @fn runAndWar(@)
-#  @brief Run and warn
-#  @param args array
-#  @return 1 is successful, 0 if not
-sub runAndWarn(@) {
-	my (@args) = (@_);
-	if ($DEBUG) {
-		print STDERR "Run::runAndWarn()\n";
-	}
-
-	# Run
-	my $res = Run::run(@args);
-
-	# Die on any error
-	if ($res == -1) {
-		warn('Unable to execute program: ' . join(' ', @args) . ': ' . $! . "\n");
-		return 0;
-	} elsif ($res & 127) {
-		warn('Child exited on signal: ' . join(' ', @args) . ': ' . ($res & 127) . "\n");
-		return 0;
-	} elsif ($res != 0) {
-		warn('Child exited with non-zero value: ' . join(' ', @args) . ': ' . ($res >> 8) . "\n");
-		return 0;
-	}
-
-	# If we get here, all is well
-	return 1;
-}
-
-#----------------------------------------------------------------------
-## @fn runAndCheck(@)
-#  @brief Run and check
-#  @param args
-#  @return 1 if successful, 0 if not
-sub runAndCheck(@) {
-	my (@args) = (@_);
-	if ($DEBUG) {
-		print STDERR "Run::runAndCheck()\n";
-	}
-
-	# Run
-	my $res = Run::run(@args);
-
-	# Die on any error
-	if ($res == -1) {
-		die('Unable to execute program: ' . join(' ', @args) . ': ' . $! . "\n");
-	} elsif ($res & 127) {
-		die('Child exited on signal: ' . join(' ', @args) . ': ' . ($res & 127) . "\n");
-	} elsif ($res != 0) {
-		die('Child exited with non-zero value: ' . join(' ', @args) . ': ' . ($res >> 8) . "\n");
-	}
-
-	# If we get here, all is well
-	return 1;
-}
-
-#----------------------------------------------------------------------
-## @fn run(@)
-#  @brief Run
-#  @param args arry
-#  @return results
-sub run(@) {
-	my (@args) = (@_);
-	if ($DEBUG) {
-		print STDERR 'Run::run: ' . join(' ', @args) . "\n";
-	}
-
-	# Run
-	system { $args[0] } @args;
-
-	# Return the result
-	return $?;
-}
-
-# Packages must return true
-return 1;

+ 20 - 1
transmission.pl

@@ -9,7 +9,6 @@ use File::Temp qw/ :mktemp /;
 use File::Basename;
 use FindBin qw($Bin);
 use lib $Bin;
-use Run;
 use Fetch;
 
 # Prototypes
@@ -642,3 +641,23 @@ sub readDir($$) {
 	# Return the file list
 	return (@orderedFiles);
 }
+
+sub runAndCheck(@) {
+	my (@args) = (@_);
+
+	# Run
+	system { $args[0] } @args;
+	my $res = $?;
+
+	# Die on any error
+	if ($res == -1) {
+		die('Unable to execute program: ' . join(' ', @args) . ': ' . $! . "\n");
+	} elsif ($res & 127) {
+		die('Child exited on signal: ' . join(' ', @args) . ': ' . ($res & 127) . "\n");
+	} elsif ($res != 0) {
+		die('Child exited with non-zero value: ' . join(' ', @args) . ': ' . ($res >> 8) . "\n");
+	}
+
+	# If we get here, all is well
+	return 1;
+}