[vhffs-dev] [2032] Removed system() from listengine_publicarchives |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2032
Author: gradator
Date: 2012-02-20 00:20:37 +0100 (Mon, 20 Feb 2012)
Log Message:
-----------
Removed system() from listengine_publicarchives
Modified Paths:
--------------
trunk/vhffs-robots/src/listengine_publicarchives.pl
Modified: trunk/vhffs-robots/src/listengine_publicarchives.pl
===================================================================
--- trunk/vhffs-robots/src/listengine_publicarchives.pl 2012-02-19 22:52:48 UTC (rev 2031)
+++ trunk/vhffs-robots/src/listengine_publicarchives.pl 2012-02-19 23:20:37 UTC (rev 2032)
@@ -1,5 +1,7 @@
#!%PERL% -w
+# TODO: Rework that....
+
use strict;
use utf8;
@@ -70,14 +72,14 @@
mkdir($outputlistdir, 0755) or die("Unable to create $outputlistdir directory: $!\n") unless(-d $outputlistdir);
# -- index : main page
- my $template = new Template({
- INCLUDE_PATH => $miscdir,
- });
+ my $template = new Template({
+ INCLUDE_PATH => $miscdir,
+ });
- my $vars = {
- list => $list
- };
- my $monthly_data = [];
+ my $vars = {
+ list => $list
+ };
+ my $monthly_data = [];
@years = readdir( LISTDIR );
foreach $year ( reverse sort @years )
@@ -86,10 +88,10 @@
$yearpath = $listdir."/".$year;
- unless( defined opendir( YEARDIR , $yearpath ) ) {
- warn "Unable to open $yearpath: $!\n";
- next;
- }
+ unless( defined opendir( YEARDIR , $yearpath ) ) {
+ warn "Unable to open $yearpath: $!\n";
+ next;
+ }
$outputyeardir = $outputlistdir."/".$year;
mkdir($outputyeardir, 0755) or die("Unable to create $outputyeardir directory: $!\n") unless(-d $outputyeardir);
@@ -104,13 +106,21 @@
$outputmonthdir = $outputyeardir."/".$month;
mkdir($outputmonthdir, 0755) or die("Unable to create $outputmonthdir directory: $!\n") unless(-d $outputmonthdir);
- system( 'mhonarc', '-add', '-quiet', '-rc', $configmhonarc, '-definevar', 'MAIN-TITLE='.$list->get_domain.'/'.$list->get_localpart, '-outdir', $outputmonthdir, glob("$monthpath/*/*") );
+ # TODO: as we need to parse folder recursively, remove the glob
+ my $childpid = open( my $output, 'mhonarc', '-add', '-quiet', '-rc', $configmhonarc, '-definevar', 'MAIN-TITLE='.$list->get_domain.'/'.$list->get_localpart, '-outdir', $outputmonthdir, glob($monthpath.'/*/*') );
+ if($childpid) {
+ # read process output and print
+ while(<$output>) { print $_; }
+ # wait for the child to finish
+ waitpid( $childpid, 0 );
+ }
+
# -- index : part
- my $month = {
- year => $year,
- month => $month
- };
+ my $month = {
+ year => $year,
+ month => $month
+ };
if( defined opendir( MONTHDIR , $monthpath ) ) {
@@ -140,18 +150,18 @@
}
my $totalsize = sprintf("%d", $mailsize/1024 );
- $month->{number} = $mailnb;
- $month->{size} = $totalsize.'KB';
+ $month->{number} = $mailnb;
+ $month->{size} = $totalsize.'KB';
}
- push @$monthly_data, $month;
+ push @$monthly_data, $month;
}
closedir ( YEARDIR );
}
- $vars->{monthly_data} = $monthly_data;
- $template->process( 'mhonarc.indexmain.tt', $vars, "$outputlistdir/index.html" );
+ $vars->{monthly_data} = $monthly_data;
+ $template->process( 'mhonarc.indexmain.tt', $vars, "$outputlistdir/index.html" );
closedir( LISTDIR );
}