summaryrefslogtreecommitdiff
path: root/rhimport.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-04-12 13:58:20 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-04-12 13:58:20 (GMT)
commita1870821bb62b7a4379276798f11e43b33ce0d0e (patch)
tree8708e79739584b44ec49bd19cfdc721411295eaa /rhimport.pm
parent283dd3e8f08217e28170e47a79a4dc56a518ff69 (diff)
added error callback to command line
some cleanup git-svn-id: https://svn.helsinki.at/rhimport/trunk@37 7c65635b-ec39-4f67-a626-873dbafdd612
Diffstat (limited to 'rhimport.pm')
-rw-r--r--rhimport.pm20
1 files changed, 6 insertions, 14 deletions
diff --git a/rhimport.pm b/rhimport.pm
index f96f7b4..c970bcf 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -102,7 +102,7 @@ sub get_used_carts
sub clear_carts
{
- my ($dbh, $group, $to_cart, $error_cb) = @_;
+ my ($dbh, $group, $to_cart) = @_;
my ($low_cart, $high_cart) = ($to_cart, $to_cart);
if($to_cart == 0) {
@@ -155,9 +155,7 @@ sub import_playlist
my $cnt = 0;
my $ret = 0;
for my $entry ( @entries ) {
- if($progress_cb) {
- $progress_cb->($cnt, $num_entries, $entry);
- }
+ $progress_cb->($cnt, $num_entries, $entry) if($progress_cb);
$ret = import_file($entry, $dropbox, $error_cb);
last if($ret == 0);
@@ -165,9 +163,7 @@ sub import_playlist
$cnt++;
}
- if($progress_cb) {
- $progress_cb->($num_entries, $num_entries, "Import abgeschlossen!");
- }
+ $progress_cb->($num_entries, $num_entries, "Import abgeschlossen!") if($progress_cb);
return $ret;
}
@@ -176,14 +172,9 @@ sub import_single
{
my ($file, $dropbox, $progress_cb, $error_cb) = @_;
print "Starting import from file $file to $dropbox\n";
- if($progress_cb) {
- $progress_cb->(0, 1, $file);
- }
+ $progress_cb->(0, 1, $file) if($progress_cb);
my $ret = import_file($file, $dropbox, $error_cb);
-
- if($progress_cb) {
- $progress_cb->(1, 1, "Import abgeschlossen!");
- }
+ $progress_cb->(1, 1, "Import abgeschlossen!") if($progress_cb);
return $ret;
}
@@ -214,6 +205,7 @@ sub ssh_exec_command {
my $errstr = "";
if ( $? >> 8 ) {
$errstr = join('', <$error>);
+ $errstr = "unkown error" if($errstr eq "");
}
return ($out, $errstr);
}