Subversion Repositories computer_asset_manager_v1

Rev

Rev 74 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74 Rev 114
Line 81... Line 81...
81
   $targetDirectory = "$DATADIR/$targetDirectory";
81
   $targetDirectory = "$DATADIR/$targetDirectory";
82
   `mkdir -p '$targetDirectory'` unless -d $targetDirectory;
82
   `mkdir -p '$targetDirectory'` unless -d $targetDirectory;
83
   `mv '$file' '$targetDirectory'`;
83
   `mv '$file' '$targetDirectory'`;
84
}
84
}
85
 
85
 
-
 
86
sub validateFileType {
-
 
87
   my %fileTypeConversions = (
-
 
88
      'ISO-8859' => 'iconv -f ISO-8859-1 -t UTF-8'
-
 
89
      );
-
 
90
#   use File::Type;
-
 
91
   my $thisFile = shift;
-
 
92
#   my $ft = File::Type->new();
-
 
93
#   die $ft->checktype_filename($thisFile);
-
 
94
   my $filetype =  `file '$thisFile'`;
-
 
95
   chomp $filetype;
-
 
96
   $filetype =~ m/:\s+([a-z0-9-]+)/i;
-
 
97
   $filetype = $1;
-
 
98
   return 1 if $filetype eq 'ASCII' || $filetype eq 'UTF-8';
-
 
99
   if ( $fileTypeConversions{ $filetype } ) {
-
 
100
      my $command = "mv '$thisFile' /tmp/toConvert ; $fileTypeConversions{ $filetype } -o '$thisFile' /tmp/toConvert"; 
-
 
101
      print "$command\n";
-
 
102
      #return 1;
-
 
103
   } else {
-
 
104
      warn "Unknown file type $filetype\n";
-
 
105
   }
-
 
106
   return 0;
-
 
107
}   
-
 
108
 
86
# get our configuration set up first
109
# get our configuration set up first
87
 
110
 
88
my $config = &loadConfig( $confFileName, @searchPaths );
111
my $config = &loadConfig( $confFileName, @searchPaths );
89
die "Could not find configuration file $confFileName in " . join( ', ', @searchPaths) . "\n" unless $config;
112
die "Could not find configuration file $confFileName in " . join( ', ', @searchPaths) . "\n" unless $config;
90
 
113
 
Line 117... Line 140...
117
 
140
 
118
foreach my $thisFile ( sort @files ) {
141
foreach my $thisFile ( sort @files ) {
119
   my $exitCode;
142
   my $exitCode;
120
   my $tempResults;
143
   my $tempResults;
121
   
144
   
-
 
145
#   next unless &validateFileType( $thisFile );
-
 
146
#   die "Stopping on valid file $thisFile\n";
122
   if ( $PROCESS ) {
147
   if ( $PROCESS ) {
123
      $tempResults .=  `php $processMailScript <'$thisFile'`;
148
      $tempResults .=  `php $processMailScript <'$thisFile'`;
124
      if ( $? == -1 ) {
149
      if ( $? == -1 ) {
125
         $exitCode = -1;
150
         $exitCode = -1;
126
         die "Parsing failed: $!\n";
151
         die "Parsing failed: $!\n";