From de9ee6a61ef871f60217f958cf4c8fadf15aaa27 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 12 Apr 2010 14:51:10 +0000 Subject: import functions return rdimport logs now diff --git a/rhimport b/rhimport index ce4463c..f431035 100755 --- a/rhimport +++ b/rhimport @@ -241,14 +241,15 @@ sub start_import_gui() $l_status->set_label("importiere von $file"); my $ret; + my $log; if($POOL) { my $cb_clear_carts = $guixml->get_widget('cb_clear_carts'); if($cb_clear_carts->get_active) { rhimport::clear_carts($dbh, $group, $to_cart, $gui_progress_cb); } - $ret = rhimport::import_playlist($file, $dropbox, $gui_progress_cb, $gui_error_cb); + ($ret, $log) = rhimport::import_playlist($file, $dropbox, $gui_progress_cb, $gui_error_cb); } else { - $ret = rhimport::import_single($file, $dropbox, $gui_progress_cb, $gui_error_cb); + ($ret, $log) = rhimport::import_single($file, $dropbox, $gui_progress_cb, $gui_error_cb); } if(!$ret) { @@ -388,14 +389,15 @@ if($group eq '') { } my $ret; +my $log; if($POOL) { if(!$KEEPCARTS) { rhimport::clear_carts($dbh, $group, $to_cart); } - $ret = rhimport::import_playlist($FILE, $DROPBOX, 0, $cl_error_cb); + ($ret, $log) = rhimport::import_playlist($FILE, $DROPBOX, 0, $cl_error_cb); } else { - $ret = rhimport::import_single($FILE, $DROPBOX, 0); + ($ret, $log) = rhimport::import_single($FILE, $DROPBOX, 0); } $dbh->disconnect(); diff --git a/rhimport.pm b/rhimport.pm index 9081b4c..d33640d 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -31,7 +31,7 @@ use File::Spec; my $ssh_host = "airplay"; my $ssh_user = "rhimport"; -my $ssh_key_file = "id_dsa"; +my $ssh_key_file = "id_dsa"; # "/etc/rhimport/import_key"; my $ssh_dir = "/programm/.rhimport"; my $rdimport_wrapper = "/usr/local/bin/dropbox_newfile.pl"; @@ -156,10 +156,13 @@ sub import_playlist my $cnt = 0; my $ret = 0; + my $log = ""; for my $entry ( @entries ) { $progress_cb->($cnt, $num_entries, $entry) if($progress_cb); - $ret = import_file($entry, $dropbox, $error_cb); + my $out; + ($ret, $out) = import_file($entry, $dropbox, $error_cb); + $log .= "\n--- $entry ---\n$out\n"; last if($ret == 0); $cnt++; @@ -171,7 +174,7 @@ sub import_playlist $progress_cb->($cnt, $num_entries, "Import abgebrochen!") if($progress_cb); } - return $ret; + return ($ret, $log); } sub import_single @@ -179,16 +182,17 @@ sub import_single my ($file, $dropbox, $progress_cb, $error_cb) = @_; print "Starting import from file $file to $dropbox\n"; $progress_cb->(0, 1, $file) if($progress_cb); - my $ret = import_file($file, $dropbox, $error_cb); + my ($ret, $out) = import_file($file, $dropbox, $error_cb); if($ret) { $progress_cb->(1, 1, "Import abgeschlossen!") if($progress_cb); } else { $progress_cb->(0, 1, "Import abgebrochen!") if($progress_cb); } - return $ret; + return ($ret, $out); } -sub scp_put_file { +sub scp_put_file +{ my ($file) = @_; my @cmd = ( 'scp', '-prqB' , '-i', $ssh_key_file, $file, "$ssh_user\@$ssh_host:$ssh_dir/" ); my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -203,7 +207,8 @@ sub scp_put_file { return $errstr; } -sub ssh_exec_command { +sub ssh_exec_command +{ my ($command) = @_; my @cmd = ( 'ssh' , '-i', $ssh_key_file, "$ssh_user\@$ssh_host" , $command ); my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -252,7 +257,7 @@ sub import_file } print "imported OK\n"; - return 1; + return (1, $out); } sub delete_file -- cgit v0.10.2