Commit 5e6d00105fa83f2673cd407406b62b53d479ccd8

Authored by Paulo Graça
1 parent 9d00822b49
Exists in master

Fixing error messages and add red color for error messages

ingester/prepare.sh
... ... @@ -9,8 +9,10 @@ do
9 9 shift # past argument or value
10 10 done
11 11  
12   -mylogger() {
13   - echo "$(date +%F\ %H:%M:%S:%N): $@"
  12 +function mylogger() {
  13 + local ERROR_COLOR='\\e[91m'
  14 + local ARG=`echo $@|sed "s|\[ERROR\]|${ERROR_COLOR}\[ERROR\]|g"`
  15 + echo -e "\e[90m$(date +%F\ %H:%M:%S:%N):\e[0m ${ARG}\e[0m"
14 16 }
15 17  
16 18 file=$1
... ... @@ -27,7 +29,6 @@ SCRIPTPATH=`pwd`
27 29 popd > /dev/null
28 30  
29 31 mylogger "start extracting DOI from PDF - $file"
30   -
31 32 DOI=$(perl $SCRIPTPATH/scripts/extract_pdftext.pl $file)
32 33  
33 34 if [ -z "$DOI" ]; then
... ... @@ -68,7 +69,7 @@ perl $SCRIPTPATH/scripts/map_metadata.pl /tmp/$DOI_FILE.xml degois 1> item_$DOI_
68 69  
69 70 mylogger "copying file"
70 71 echo "$filename" > item_$DOI_FILE/contents
71   -yes | cp -rf $file item_$DOI_FILE/$filename
  72 +yes | cp -prf $file item_$DOI_FILE/$filename
72 73  
73 74  
74 75 mylogger "cleaning tempfiles"
... ...
ingester/scripts/extract_pdftext.pl
... ... @@ -42,6 +42,8 @@ if (open(my $fh, "-|","pdftotext -l 1 $filename -")) {
42 42  
43 43 #TODO: this is reading only the first element found
44 44 if (scalar @DOIS ne 0) {
45   - print STDERR "$DOIS[0] - matches the DOI pattern\n";
46 45 print "$DOIS[0]";
  46 +} else {
  47 + print STDERR "Didn't matched the DOI pattern\n";
  48 + exit;
47 49 }
... ...