diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-08-03 18:50:45 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-08-03 18:50:45 (GMT) |
commit | ef88162d260c31071679afce1149e0b488509f4d (patch) | |
tree | 27273418709a0181f5cc7b1758c3c32af5a2b657 | |
parent | e928b1b583db65c28a8c59f1311cdbb459532549 (diff) |
use new rhrdlibs pv_execute_action function for add_note
-rw-r--r-- | rhautoimport.pm | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/rhautoimport.pm b/rhautoimport.pm index 0f9f197..1af005f 100644 --- a/rhautoimport.pm +++ b/rhautoimport.pm @@ -28,8 +28,6 @@ package rhautoimport; use File::Basename; use File::Temp; use File::Slurp; -use IPC::Open3; -use IO::Handle; use LWP::Simple; use XML::Feed; use RHRD::rddb; @@ -269,33 +267,11 @@ sub import_uri sub pv_add_note { - my ( $title, $text, $id, $date, $type, $index ) = @_; - my @script = ('python', '/srv/pv/pv/manage.py', 'addnote', $id, $date, $type); - push(@script , $index) unless (!defined $index); - - my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); - $writer->autoflush(1); - local $SIG{CHLD} = 'DEFAULT'; - my $pid = open3($writer, $reader, $error, @script); - binmode($reader, ":utf8"); - binmode($writer, ":utf8"); - binmode($error, ":utf8"); - print $writer $title . "\n" . $text; - close $writer; - waitpid $pid, 0; - my $err_out = join('', <$error>); - my $read_out = join('', <$reader>); - if ( $? >> 8 ) { - my $log = "\n\nPV: adding note returned non-zero value\n"; - $log .= "STDERR:\n" . $err_out . "\n" unless $err_out eq ''; - $log .= "STDOUT:\n" . $read_out . "\n" unless $read_out eq ''; - return(1, $log); - } else { - my $log = ''; - $log .= $read_out . "\n" unless $read_out eq ''; - $log .= $err_out . "\n" unless $err_out eq ''; - return(0, $log); - } + my ($title, $text, $id, $date, $type, $index) = @_; + my @args = ($id, $date, $type); + push(@args , $index) if defined($index); + + return RHRD::utils::pv_execute_action('addnote', $title . "\n" . $text, @args); } 1; |