Index: /emailtotracscript/trunk/ChangeLog
===================================================================
--- /emailtotracscript/trunk/ChangeLog	(revision 86)
+++ /emailtotracscript/trunk/ChangeLog	(revision 87)
@@ -3,4 +3,14 @@
 	  the database connection.
 	  Fixed by: Walter de Jong en Bas van der Vlies
+
+	- Added enable_syslog option. If enabled log errors
+	  to syslog instead of stderr. If enabled no errors are
+	  send back to the user.
+	  Implemented by: Bas van der Vlies
+
+	- Fixed an error with updating tickets with attachments for trac 
+	  versions 0.9 and 0.10. Field "id" is not known when a existing
+	  ticket is fetched (Error = KeyError: 'id')
+	  Fixed By: See tickets #258 and #449 on trac-hacks
 
 2006-06-02
Index: /emailtotracscript/trunk/INSTALL
===================================================================
--- /emailtotracscript/trunk/INSTALL	(revision 86)
+++ /emailtotracscript/trunk/INSTALL	(revision 87)
@@ -22,4 +22,5 @@
  email_header: 1            # OPTIONAL, if set then show TO/CC fields in description
  trac_version: 0.8          # OPTIONAL, if set use this as trac version (D: 0.9)
+ enable_syslog: 1           # OPTIONAL, if set log errors to syslog
 
  [bas]                     # OPTIONAL project declaration, also set 
Index: /emailtotracscript/trunk/debian/changelog
===================================================================
--- /emailtotracscript/trunk/debian/changelog	(revision 86)
+++ /emailtotracscript/trunk/debian/changelog	(revision 87)
@@ -1,2 +1,14 @@
+email2trac (0.7.3-1) stable; urgency=low
+
+  * Enabled syslog option
+
+ -- root <root@subtrac.sara.nl>  Thu, 22 Jun 2006 12:45:37 +0200
+
+email2trac (0.7.2-0) stable; urgency=low
+
+  * Added new try/except statement and fixed LookupError
+
+ -- root <root@subtrac.sara.nl>  Thu, 22 Jun 2006 09:59:02 +0200
+
 email2trac (0.7.1-3) stable; urgency=low
 
Index: /emailtotracscript/trunk/email2trac.conf
===================================================================
--- /emailtotracscript/trunk/email2trac.conf	(revision 86)
+++ /emailtotracscript/trunk/email2trac.conf	(revision 87)
@@ -11,5 +11,7 @@
 email_header: 1
 trac_version: 0.9
+enable_syslog : 0
 alternate_notify_template :
+
 
 [bas]
Index: /emailtotracscript/trunk/email2trac.py.in
===================================================================
--- /emailtotracscript/trunk/email2trac.py.in	(revision 86)
+++ /emailtotracscript/trunk/email2trac.py.in	(revision 87)
@@ -54,5 +54,5 @@
 	spam_level   : 4               # OPTIONAL, if set check for SPAM mail 
 	reply_address: 1               # OPTIONAL, if set then fill in ticket CC field
-    umask        : 022             # OPTIONAL, if set then use this umask for creation of the attachments
+	umask        : 022             # OPTIONAL, if set then use this umask for creation of the attachments
 	mailto_link  : 1               # OPTIONAL, if set then [mailto:<>] in description 
 	mailto_cc    : basv@sara.nl    # OPTIONAL, use this address as CC in mailto line
@@ -187,8 +187,9 @@
 				try:
 					temp = unicode(text, format)
-				except UnicodeError:
+				except (UnicodeError,LookupError):
 					# This always works 
 					#
 					temp = unicode(text, 'iso-8859-15')
+					
 				temp =  temp.encode('utf-8')
 			else:
@@ -495,5 +496,5 @@
 				# UTF-8 encode body_text
 				#
-				charset = msg.get_content_charset('iso-8859-15')
+				charset = part.get_content_charset('iso-8859-15')
 				ubody_text = unicode(body_text, charset).encode('utf-8')
 
@@ -696,4 +697,5 @@
 	return project
 
+
 if __name__ == '__main__':
 	# Default config file
@@ -702,5 +704,6 @@
 	project = ''
 	component = ''
-	
+	ENABLE_SYSLOG = 0
+		
 	try:
 		opts, args = getopt.getopt(sys.argv[1:], 'chf:p:', ['component=','help', 'file=', 'project='])
@@ -709,5 +712,5 @@
 		print detail
 		sys.exit(1)
-
+	
 	project_name = None
 	for opt,value in opts:
@@ -721,5 +724,5 @@
 		elif opt in ['-p', '--project']:
 			project_name = value
-
+	
 	settings = ReadConfig(configfile, project_name)
 	if not settings.has_key('project'):
@@ -727,8 +730,8 @@
 		print 'No Trac project is defined in the email2trac config file.'
 		sys.exit(1)
-
+	
 	if component:
 		settings['component'] = component
-
+	
 	if settings.has_key('trac_version'):
 		version = float(settings['trac_version'])
@@ -736,33 +739,52 @@
 		version = trac_default_version
 
+	if settings.has_key('enable_syslog'):
+		ENABLE_SYSLOG =  float(settings['enable_syslog']) 
+			
 	#debug HvB
 	#print settings
-
-	if version == 0.8:
-		from trac.Environment import Environment
-		from trac.Ticket import Ticket
-		from trac.Notify import TicketNotifyEmail
-		from trac.Href import Href
-		from trac import util
-		import sqlite
-	elif version == 0.9:
-		from trac import attachment 
-		from trac.env import Environment
-		from trac.ticket import Ticket
-		from trac.web.href import Href
-		from trac import util
-		from trac.Notify import TicketNotifyEmail
-	elif version == 0.10:
-		from trac import attachment 
-		from trac.env import Environment
-		from trac.ticket import Ticket
-		from trac.web.href import Href
-		from trac import util
-		# see http://projects.edgewall.com/trac/changeset/2799
-		from trac.ticket.notification import TicketNotifyEmail
-
-	env = Environment(settings['project'], create=0)
-	tktparser = TicketEmailParser(env, settings, version)
-	tktparser.parse(sys.stdin)
+	
+	try:
+		if version == 0.8:
+			from trac.Environment import Environment
+			from trac.Ticket import Ticket
+			from trac.Notify import TicketNotifyEmail
+			from trac.Href import Href
+			from trac import util
+			import sqlite
+		elif version == 0.9:
+			from trac import attachment 
+			from trac.env import Environment
+			from trac.ticket import Ticket
+			from trac.web.href import Href
+			from trac import util
+			from trac.Notify import TicketNotifyEmail
+		elif version == 0.10:
+			from trac import attachment 
+			from trac.env import Environment
+			from trac.ticket import Ticket
+			from trac.web.href import Href
+			from trac import util
+			# see http://projects.edgewall.com/trac/changeset/2799
+			from trac.ticket.notification import TicketNotifyEmail
+	
+		env = Environment(settings['project'], create=0)
+		tktparser = TicketEmailParser(env, settings, version)
+		tktparser.parse(sys.stdin)
+
+	# Catch all errors ans log to SYSLOG if we have enabled this
+	# else stdout
+	#
+	except Exception, error:
+		import syslog, traceback
+
+		if ENABLE_SYSLOG:
+			syslog.openlog('email2trac', syslog.LOG_NOWAIT)
+			etype, evalue, etb = sys.exc_info()
+			for e in traceback.format_exception(etype, evalue, etb):
+				syslog.syslog(e)
+			syslog.closelog()
+		else:
+			traceback.print_exc()
 
 # EOB
