parent
f99cbe5e9b
commit
fcdd936ec6
|
@ -17,9 +17,9 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
if (env.JOB_NAME == 'mail2redmine' && env.GIT_BRANCH == 'origin/main') {
|
||||
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder -d stretch mail2redmine'
|
||||
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder mail2redmine'
|
||||
} else if (env.GIT_BRANCH.startsWith('hotfix/')) {
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d stretch --branch ${env.GIT_BRANCH} --hotfix mail2redmine"
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder --branch ${env.GIT_BRANCH} --hotfix mail2redmine"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
7
|
|
@ -2,13 +2,18 @@ Source: mail2redmine
|
|||
Maintainer: Serghei Mihai <smihai@entrouvert.com>
|
||||
Section: python
|
||||
Priority: optional
|
||||
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7.4.3)
|
||||
Standards-Version: 3.9.1
|
||||
Build-Depends: debhelper-compat (= 12),
|
||||
python3-setuptools,
|
||||
python3-all,
|
||||
dh-python
|
||||
Standards-Version: 3.9.6
|
||||
|
||||
|
||||
Package: mail2redmine
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python:Depends}
|
||||
Depends: ${python:Depends},
|
||||
${misc:Depends},
|
||||
python3-setuptools
|
||||
Description: Converts incoming exim emails to tickets
|
||||
mail2redmine converts incoming email from Exim to Redmine tracker tickets by
|
||||
using mail subject and body as ticket title and description respectively.
|
||||
|
|
|
@ -4,7 +4,4 @@
|
|||
# Mon, 09 May 2016 17:42:19 +0200
|
||||
|
||||
%:
|
||||
dh $@ --with python2
|
||||
|
||||
|
||||
|
||||
dh $@ --with python3 --buildsystem=pybuild
|
||||
|
|
|
@ -27,17 +27,22 @@ class UnknownUser(Exception):
|
|||
pass
|
||||
|
||||
def parse_header(header_text):
|
||||
if isinstance(header_text, unicode):
|
||||
return header_text
|
||||
if not header_text:
|
||||
return ''
|
||||
default_charset = 'ascii'
|
||||
try:
|
||||
headers = email.Header.decode_header(header_text)
|
||||
except email.Errors.HeaderParseError:
|
||||
headers = email.header.decode_header(header_text)
|
||||
except email.errors.HeaderParseError:
|
||||
return header_text.encode(default_charset, 'replace').decode(default_charset)
|
||||
else:
|
||||
res = ''
|
||||
for i, (text, charset) in enumerate(headers):
|
||||
headers[i] = unicode(text, charset or default_charset, errors='replace')
|
||||
return u' '.join(headers)
|
||||
if isinstance(text, str):
|
||||
res += text
|
||||
else:
|
||||
res += text.decode(charset or default_charset, errors='replace')
|
||||
return res
|
||||
return ''
|
||||
|
||||
|
||||
def parse_attachment(data, blacklist=None):
|
||||
|
@ -54,6 +59,7 @@ def parse_attachment(data, blacklist=None):
|
|||
with tempfile.NamedTemporaryFile(delete=False) as attachment:
|
||||
attachment.write(file_data)
|
||||
attachment.flush()
|
||||
|
||||
attachment = {'path': attachment.name,
|
||||
'content_type': data.get_content_type(),
|
||||
'filename': parse_header(data.get_filename())}
|
||||
|
@ -96,8 +102,7 @@ def create_ticket(mail):
|
|||
if attachment:
|
||||
attachments.append(attachment)
|
||||
elif data.get_content_type() == "text/plain":
|
||||
body = data.get_payload(decode=True)
|
||||
body = unicode(body, data.get_content_charset('utf-8')).encode('utf-8')
|
||||
body = data.get_payload()
|
||||
|
||||
# get project tech manager
|
||||
tech_manager = None
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_parsing_subjects(dump):
|
|||
mail = mail2redmine.email.message_from_file(dump)
|
||||
subject = mail2redmine.parse_header(mail['Subject'])
|
||||
assert subject
|
||||
assert isinstance(subject, unicode)
|
||||
assert isinstance(subject, str)
|
||||
assert subject in (u'Pour paiement immédiat', u'Facture Infopole à régler',
|
||||
u'Тест на русском', u'test', u'Un ticket à tester',
|
||||
u'[Fwd: A nouveau du code reçu]',
|
||||
|
@ -28,7 +28,7 @@ def test_parsing_subjects(dump):
|
|||
@pytest.mark.parametrize('mail_dump', ('mail_dumps/3515ed61-bb12-4f41-ac25-81d468d2c80f.mail',
|
||||
'mail_dumps/711d5ffc-b153-46e1-ba21-30c6a1b45444.mail'))
|
||||
def test_parsing_attachments(mail_dump):
|
||||
mail = mail2redmine.email.message_from_file(file(mail_dump))
|
||||
mail = mail2redmine.email.message_from_file(open(mail_dump))
|
||||
attachments = []
|
||||
for data in mail.walk():
|
||||
attachment = mail2redmine.parse_attachment(data)
|
||||
|
@ -36,13 +36,13 @@ def test_parsing_attachments(mail_dump):
|
|||
assert 'path' in attachment
|
||||
assert 'content_type' in attachment
|
||||
assert 'filename' in attachment
|
||||
assert isinstance(attachment['filename'], unicode)
|
||||
assert isinstance(attachment['filename'], str)
|
||||
attachments.append(attachment)
|
||||
assert attachments
|
||||
|
||||
@pytest.mark.parametrize('message', ('mail_dumps/1461591292.25165_17.dor-lomin_2.mail',))
|
||||
def test_mail_with_two_attachments(message):
|
||||
mail = mail2redmine.email.message_from_file(file(message))
|
||||
mail = mail2redmine.email.message_from_file(open(message))
|
||||
attachments = []
|
||||
for data in mail.walk():
|
||||
attachment = mail2redmine.parse_attachment(data)
|
||||
|
@ -50,7 +50,7 @@ def test_mail_with_two_attachments(message):
|
|||
assert 'path' in attachment
|
||||
assert 'content_type' in attachment
|
||||
assert 'filename' in attachment
|
||||
assert isinstance(attachment['filename'], unicode)
|
||||
assert isinstance(attachment['filename'], str)
|
||||
assert attachment['filename'] in (u'201601-mise-a-jour-Publik.pdf',
|
||||
u'Capture d\'écran de 2014-12-23 17:03:40.png')
|
||||
attachments.append(attachment)
|
||||
|
@ -58,7 +58,7 @@ def test_mail_with_two_attachments(message):
|
|||
|
||||
@pytest.mark.parametrize('message', ('mail_dumps/1461591292.25165_17.dor-lomin_2.mail',))
|
||||
def test_mail_attachment_blacklist(message):
|
||||
mail = mail2redmine.email.message_from_file(file(message))
|
||||
mail = mail2redmine.email.message_from_file(open(message))
|
||||
attachments = []
|
||||
blacklist = {'sha1sums': ['ab7c57983551204500d67f8ec3dd54a01e81d75d']}
|
||||
for data in mail.walk():
|
||||
|
@ -67,7 +67,7 @@ def test_mail_attachment_blacklist(message):
|
|||
assert 'path' in attachment
|
||||
assert 'content_type' in attachment
|
||||
assert 'filename' in attachment
|
||||
assert isinstance(attachment['filename'], unicode)
|
||||
assert isinstance(attachment['filename'], str)
|
||||
assert attachment['filename'] == u'201601-mise-a-jour-Publik.pdf'
|
||||
attachments.append(attachment)
|
||||
assert len(attachments) == 1
|
||||
|
|
Loading…
Reference in New Issue