Benjamin Renard commited on 2012-04-20 15:39:28
Showing 1 changed files, with 9 additions and 17 deletions.
... | ... |
@@ -138,34 +138,26 @@ class MantisSMTPServer(smtpd.SMTPServer): |
138 | 138 |
self.start_ws() |
139 | 139 |
|
140 | 140 |
issue_id=msg.get_issue_id_from_subject() |
141 |
- |
|
141 |
+ try: |
|
142 | 142 |
note_id = self.ws.add_note_to_issue(issue_id,msg.get_text()) |
143 | 143 |
if note_id: |
144 | 144 |
logging.info('Note add to issue %s with id %s' % (issue_id,note_id)) |
145 |
+ self.add_attachment_to_issue(issue_id,msg) |
|
146 |
+ return issue_id |
|
147 |
+ else: |
|
148 |
+ logging.error('Error adding issue') |
|
145 | 149 |
|
150 |
+ def add_attachment_to_issue(self,issue_id,msg): |
|
146 | 151 |
for attachment in msg.get_attachments(): |
147 | 152 |
try: |
148 | 153 |
logging.info('Add attachment to issue %s : %s' % (issue_id,attachment['filename'])) |
149 | 154 |
self.ws.add_attachment_to_issue(issue_id,attachment) |
150 | 155 |
except MantisWS.MantisWSError, e: |
151 |
- if e.type == 'duplicate_attachment_filename': |
|
152 |
- logging.error('Duplicate filename %s in issue %s. Warning sender by mail.' % (attachment['filename'],issue_id)) |
|
153 |
- MantisMail.send( |
|
154 |
- self._options['mail_from'], |
|
155 |
- msg.mailfrom, |
|
156 |
- '[Mantis] Duplicate filename %s in issue %s' % (attachment['filename'],issue_id), |
|
157 |
- "Your file %s attach in your email '%s' can't be attached to Mantis issue %s because a file with the same name is currently attached to this issue." % (attachment['filename'],msg.subject(),issue_id), |
|
158 |
- smtp_host=self._options['smtp_host'], |
|
159 |
- smtp_port=self._options['smtp_port'] |
|
160 |
- ) |
|
156 |
+ logging.error('MantisWS error adding attachment %s to issue %s : %s.' % (attachment['filename'],issue_id, e)) |
|
161 | 157 |
|
162 |
- except: |
|
163 |
- logging.error('Error adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
|
164 |
-# |
|
158 |
+ except Exception, e: |
|
159 |
+ logging.error('Unknown error adding attachment %s to issue %s : %s. Warning sender by mail.' % (attachment['filename'],issue_id,e)) |
|
165 | 160 |
|
166 |
- return issue_id |
|
167 |
- else: |
|
168 |
- logging.error('Error during add issue') |
|
169 | 161 |
|
170 | 162 |
def save_msg(self,peer, mailfrom, rcpttos, data): |
171 | 163 |
if self._options['save_dir']: |
172 | 164 |