equal
deleted
inserted
replaced
15 # Adds info form a file to a CSV |
15 # Adds info form a file to a CSV |
16 |
16 |
17 use strict; |
17 use strict; |
18 my $csvfile = shift @ARGV; |
18 my $csvfile = shift @ARGV; |
19 my $filelist = shift @ARGV; |
19 my $filelist = shift @ARGV; |
20 |
20 my $zipfile = shift @ARGV; |
21 |
21 |
22 if(! -e $csvfile) |
22 if(! -e $csvfile) |
23 { |
23 { |
24 die "cannot find $csvfile\n"; |
24 die "cannot find $csvfile\n"; |
25 } |
25 } |
27 |
27 |
28 if(!-e $filelist) |
28 if(!-e $filelist) |
29 { |
29 { |
30 die "Cannot find $filelist\n"; |
30 die "Cannot find $filelist\n"; |
31 } |
31 } |
|
32 my %ziptimes; |
|
33 if(defined $zipfile) |
|
34 { |
|
35 open(ZIP,"7z l $zipfile 2>&1|") or die "Error: Couldn't look in $zipfile\n"; |
|
36 # print "time,file\n"; |
|
37 while( my $line = <ZIP>) |
|
38 { |
|
39 if($line =~ m/^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s\S{5}\s+(\d+)\s+\d+\s+(.+)$/) #ignoring packed size... |
|
40 { |
|
41 my $name = $3; |
|
42 my $size = $2; |
|
43 my $time = $1; |
|
44 $name =~ s/\\/\//g; |
|
45 $name = lc($name); |
|
46 $ziptimes{$name} = $time; |
|
47 # print "$time,$name\n"; |
|
48 } |
|
49 } |
|
50 close ZIP; |
|
51 } |
32 my %files; |
52 my %files; |
|
53 |
33 open(FILES,"<$filelist") or die "Couldn't open $filelist\n"; |
54 open(FILES,"<$filelist") or die "Couldn't open $filelist\n"; |
34 while(my $line = <FILES>) |
55 while(my $line = <FILES>) |
35 { |
56 { |
36 $line =~ s/\\/\//g; |
57 $line =~ s/\\/\//g; |
37 |
58 |
42 |
63 |
43 $file = lc($file); |
64 $file = lc($file); |
44 if($files{$file}) |
65 if($files{$file}) |
45 { |
66 { |
46 |
67 |
47 $files{$file} = $files{$file}.",".$group; |
68 $files{$file} = $files{$file}." ".$group; #Stop polluting next column |
48 print "Multi:$file".$files{$file}."\n"; |
69 print "Multi:$file".$files{$file}."\n"; |
49 |
70 |
50 } |
71 } |
51 else |
72 else |
52 { |
73 { |
59 open(CSV,"<$csvfile") or die "Couldn't open $csvfile\n"; |
80 open(CSV,"<$csvfile") or die "Couldn't open $csvfile\n"; |
60 my $resultsfile = $csvfile."_results.csv"; |
81 my $resultsfile = $csvfile."_results.csv"; |
61 open(RESULTS,">$resultsfile") or die "Couldn't open write to $resultsfile\n"; |
82 open(RESULTS,">$resultsfile") or die "Couldn't open write to $resultsfile\n"; |
62 my $header = <CSV>; |
83 my $header = <CSV>; |
63 $header =~ s/\n//; |
84 $header =~ s/\n//; |
64 print RESULTS $header.",status\n"; |
85 print RESULTS $header.",status,time\n"; |
65 my @fields = split(',',$header); |
86 my @fields = split(',',$header); |
66 my $targetindex = 0; |
87 my $targetindex = 0; |
67 my $counter = 0; |
88 my $counter = 0; |
68 my $bldinfindex = 0; |
89 my $bldinfindex = 0; |
69 |
90 |
91 my $bldinf = $fields[$bldinfindex]; |
112 my $bldinf = $fields[$bldinfindex]; |
92 if(!defined $bldinffiles{$bldinf}) |
113 if(!defined $bldinffiles{$bldinf}) |
93 { |
114 { |
94 $bldinffiles{$bldinf} = 1; |
115 $bldinffiles{$bldinf} = 1; |
95 } |
116 } |
96 |
117 my $found = 0; |
97 if(defined $files{$target}) |
118 if(defined $files{$target}) |
98 { |
119 { |
|
120 $found = 1; |
99 $line = $line.$files{$target}; |
121 $line = $line.$files{$target}; |
100 if($files{$target} =~ m/fail/i) |
122 if($files{$target} =~ m/fail/i) |
101 { |
123 { |
102 if(!defined $failed{$bldinf}) |
124 if(!defined $failed{$bldinf}) |
103 { |
125 { |
104 $failed{$bldinf} = 1; |
126 $failed{$bldinf} = 1; |
105 } |
127 } |
106 } |
128 } |
107 } |
129 } |
|
130 if(defined $ziptimes{$target}) |
|
131 { |
|
132 if($found) |
|
133 { |
|
134 $line = $line.",".$ziptimes{$target}; |
|
135 } |
|
136 else |
|
137 { |
|
138 $line = $line.",,".$ziptimes{$target}; |
|
139 } |
|
140 } |
108 print RESULTS $line."\n"; |
141 print RESULTS $line."\n"; |
109 |
142 |
110 } |
143 } |
111 close RESULTS; |
144 close RESULTS; |
112 close CSV; |
145 close CSV; |