summaryrefslogtreecommitdiffstats
path: root/themis
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2012-07-20 11:29:33 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2012-07-20 11:29:33 (GMT)
commit8f5599bca9b7dcf4114aea40c2eb8df2eda463a2 (patch)
treed04b2aa2aab7b1c3c9b4f2877f7da9aa5d2b7608 /themis
parent1a03d61f8303b533a0b41199913ff357d0ae0b4c (diff)
downloadthemis.ocrloader-8f5599bca9b7dcf4114aea40c2eb8df2eda463a2.zip
themis.ocrloader-8f5599bca9b7dcf4114aea40c2eb8df2eda463a2.tar.gz
themis.ocrloader-8f5599bca9b7dcf4114aea40c2eb8df2eda463a2.tar.bz2
add proper logging
Diffstat (limited to 'themis')
-rw-r--r--themis/ocrloader/ocrloader.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/themis/ocrloader/ocrloader.py b/themis/ocrloader/ocrloader.py
index 1003959..74bc0c4 100644
--- a/themis/ocrloader/ocrloader.py
+++ b/themis/ocrloader/ocrloader.py
@@ -2,6 +2,7 @@
import datetime
import os
+import logging
from Products.CMFCore.utils import getToolByName
from Products.Five.browser import BrowserView
@@ -11,6 +12,8 @@ import transaction
import themis.config.utils
+log = logging.getLogger('Plone')
+
class LoadFromOcr(BrowserView):
output_path = '/mnt/gedimport'
@@ -33,8 +36,13 @@ class LoadFromOcr(BrowserView):
for filename in filenames:
if not filename.lower().endswith('.pdf'):
continue
- print 'processing', filename
- code_cat, number, date, time = filename.split('_')
+ log.info('processing %s' % filename)
+ try:
+ code_cat, number, date, time = filename.split('_')
+ except ValueError:
+ # XXX: log
+ log.warning('unknown file name format (%s)' % filename)
+ continue
for doctype in ('incoming_mails', 'outgoing_mails',
'internal_documents', 'confidential_documents'):
@@ -45,7 +53,7 @@ class LoadFromOcr(BrowserView):
continue
break
else:
- # XXX: log?
+ log.warning('no suitable document type found for %s' % filename)
continue
folder = self.get_folder(doctype)
@@ -78,7 +86,7 @@ class LoadFromOcr(BrowserView):
ocr_date.strftime('%H-%M-%S')))
if hasattr(folder, ocr_id):
- # already imported (log?)
+ logging.warning('document id already exists (%s)' % filename)
continue
if category: