Skip to content

Commit

Permalink
new version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Mar 14, 2024
1 parent 2452cbd commit dbb3715
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 69 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ ___

### What has been done for version 1.2.1:

- Fixed a regression allowing errors to be displayed in the Spooler.
- Integration of a fix to workaround the [issue #159988][91].

### What remains to be done for version 1.2.1:
Expand Down
1 change: 1 addition & 0 deletions README_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ ___

### Ce qui a été fait pour la version 1.2.1:

- Correction d'une régression permettant l'affichage des erreurs dans le Spooler.
- Intégration d'un correctif pour contourner le [dysfonctionnement #159988][91].

### Que reste-t-il à faire pour la version 1.2.1:
Expand Down
38 changes: 23 additions & 15 deletions source/eMailerOOo/resource/eMailer_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,16 @@
1011=Start sending {} emails...
1012=Sending {} out of {} email(s)
1013=No email to send...
1014=MailSpooler is closed
1014=MailSpooler disposed
1015=MailSpooler has been stopped

1020=Spooler._sendMails()
1021=Start sending email N\u00ba: {}
1022=Sending email N\u00ba: {} aborted!!!
1023=Error: While sending the email N\u00ba: {} the error: {} occurred with message: {}
1024=Error: While sending the email N\u00ba: {} the error: {} occurred with message: {} and trace:\n{}
1024=Error: While sending the email N\u00ba: {} the error: {} occurred with trace:\n{}
1025=End sending email N\u00ba: {}

1030=Spooler._getThreadMessage()
1031={} - Document merge N\u00ba: {} of: {}
1032=Subject
1033=Document
1034=Attachments
1035=Any

1040=Spooler._getMailServer()
1041=Email N\u00ba: {} cannot be send, Unable to connect with account: {} to server {} - Error: {}

Expand All @@ -162,19 +155,34 @@
1054=Error: While composing the email N\u00ba: {} the error occurred: {} with trace:\n{}
1055=End composing the email N\u00ba: {}

1500=Mailer._getDescriptors()
1501=Could not load data source: <{}> it does not exist!!!
1502=Could not load data source, file: <{}> is not an odb file!!!
1503=Could not load data source, file: <{}> does not exist!!!
1504=Could not load data source: <{}>, the table: <{}> does not exist!!!
1500=Mailer.__init__()
1501=Mailer helper initialized.

1510=Mailer._initMailer()
1511=Error: While composing the email N\u00ba: {}, the Document: {} dont exist...
1512=Error: While composing the email N\u00ba: {}, the IspDB Wizard for: {} has been canceled...

1520=Mailer._getMailAttachmentUrl()
1521=Error: While composing the email N\u00ba: {}, the attachment: {} dont exist...

1530=Mailer._getDescriptors()
1531=Could not load data source: <{}> it does not exist!!!
1532=Could not load data source, file: <{}> is not an odb file!!!
1533=Could not load data source, file: <{}> does not exist!!!
1534=Could not load data source: <{}>, the table: <{}> does not exist!!!

1540=Mailer._getMailUser()
1541=Error: While composing the email N\u00ba: {}, the IspDB Wizard for sender: {} has been canceled...

1550=Mailer._getThreadMessage()
1551={} - Document merge N\u00ba: {} of: {}
1552=Subject
1553=Document
1554=Attachments
1555=Any

1560=Mailer.dispose()
1561=Mailer helper disposed.

2000=MailMessage._getMessage()
2001=Unable to compose body of email: {}, body does not include a data flavor...
2002=Unable to attach file: {} to email: {}, attachment does not include a ReadableName...
Expand Down
38 changes: 23 additions & 15 deletions source/eMailerOOo/resource/eMailer_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,16 @@
1011=Debut d'envoi de {} courriel(s)...
1012=Envoi de {} courriel(s) sur {}
1013=Aucun courriel \u00e0 envoyer...
1014=MailSpooler c'est ferm\u00e9
1014=Arrêt du MailSpooler
1015=MailSpooler a \u00e9t\u00e9 arret\u00e9

1020=Spooler._sendMails()
1021=Debut d'envoi du courriel N\u00ba: {}
1022=L'envoi du courriel N\u00ba: {} a \u00e9t\u00e9 annul\u00e9!!!
1023=Erreur: Lors de l'envoi du courriel N\u00ba: {} l'erreur: {} a renvoy\u00e9 le message: {}
1024=Erreur: Lors de l'envoi du courriel N\u00ba: {} l'erreur: {} a renvoy\u00e9 le message: {} avec la trace:\n{}
1024=Erreur: Lors de l'envoi du courriel N\u00ba: {} l'erreur: {} a renvoy\u00e9 la trace:\n{}
1025=Fin d'envoi du courriel N\u00ba: {}
1030=Spooler._getThreadMessage()
1031={} - Publipostage N\u00ba: {} de: {}
1032=Objet
1033=Document
1034=Fichiers joints
1035=Aucun

1040=Spooler._getMailServer()
1041=Le courriel N\u00ba: {} ne peut \u00eatre envoy\u00e9, Impossible de se connecter avec le compte: {} au serveur {} - Erreur: {}
Expand All @@ -162,19 +155,34 @@
1054=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: {} il s'est produit l'erreur: {} avec la trace:\n{}
1055=Fin de la r\u00e9daction du courriel N\u00ba: {}

1500=Mailer._getDescriptors()
1501=Impossible de charger la source de donn\u00e9es: <{}> elle n'existe pas!!!
1502=Impossible de charger la source de donn\u00e9es, le fichier: <{}> n'est pas un fichier odb!!!
1503=Impossible de charger la source de donn\u00e9es, le fichier: <{}> n'existe pas!!!
1503=Impossible de charger la source de donn\u00e9es: <{}> la table: <{}> n'existe pas!!!
1500=Mailer.__init__()
1501=Initialisation du Mailer.

1510=Mailer._initMailer()
1511=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: {}, le Document: {} n'existe pas...
1512=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: {}, l'assistant de connexion IspDB pour l'exp\u00e9diteur: {} a \u00e9t\u00e9 annul\u00e9...
1520=Mailer._getMailAttachmentUrl()
1521=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: {}, le fichier joint: {} n'existe pas...

1530=Mailer._getDescriptors()
1531=Impossible de charger la source de donn\u00e9es: <{}> elle n'existe pas!!!
1532=Impossible de charger la source de donn\u00e9es, le fichier: <{}> n'est pas un fichier odb!!!
1533=Impossible de charger la source de donn\u00e9es, le fichier: <{}> n'existe pas!!!
1534=Impossible de charger la source de donn\u00e9es: <{}> la table: <{}> n'existe pas!!!

1540=Mailer._getMailUser()
1541=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: {}, l'assistant de connexion IspDB pour l'exp\u00e9diteur: {} a \u00e9t\u00e9 annul\u00e9...

1550=Mailer._getThreadMessage()
1551={} - Publipostage N\u00ba: {} de: {}
1552=Objet
1553=Document
1554=Fichiers joints
1555=Aucun

1560=Mailer.dispose()
1561=Arrêt du Mailer.

2000=MailMessage._getMessage()
2001=Impossible de r\u00e9diger le corps du courriel: {}, le corps du message n'inclut pas de type de donn\u00e9es...
2002=Impossible de joindre le fichier: {} au courriel: {}, la pi\u00e8ce jointe n'est pas nomm\u00e9e...
Expand Down
64 changes: 34 additions & 30 deletions source/eMailerOOo/service/pythonpath/emailer/spooler/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,15 @@ def __init__(self, ctx, source, database, logger, send=False):
self._replyto = ''
logo = '%s/%s' % (g_extension, g_logo)
self._logo = getResourceLocation(ctx, g_identifier, logo)
self._logger.logprb(INFO, 'Mailer', '__init__()', 1501)

@property
def _merge(self):
return self._metadata.get('Merge')

def dispose(self):
if self._server is not None:
self._server.disconnect()
if self._descriptor is not None:
self._descriptor['ActiveConnection'].close()
if self._url is not None:
self._url.dispose()
for url in self._urls:
url.dispose()
self._dispose()
self._logger.logprb(INFO, 'Mailer', 'dispose()', 1561)

def getMail(self, job):
recipient = self._database.getRecipient(job)
Expand All @@ -126,51 +121,62 @@ def sendMail(self, mail):
self._server.sendMailMessage(mail)

# Private Procedures call
def _dispose(self):
if self._server is not None:
self._server.disconnect()
if self._descriptor is not None:
self._descriptor['ActiveConnection'].close()
if self._url is not None:
self._url.dispose()
for url in self._urls:
url.dispose()

def _initMailer(self, job, recipient):
threadid = None
metadata = self._database.getMailer(recipient.BatchId)
merge = metadata.get('Merge')
document = metadata.get('Document')
self._checkUrl(document, job, 1511)
url = metadata.get('Document')
self._checkUrl(url, job, 1511)
self._urls = self._getMailAttachmentUrl(recipient.BatchId, job)
self._rowset, self._descriptor = self._getDescriptors(merge, metadata)
self._url, self._urls = self._getUrls(recipient, job, document, merge)
self._url = self._getMailUrl(recipient, url, merge)
if self._send:
sender = metadata.get('Sender')
user = self._getMailUser(job, sender)
self._server = self._getMailServer(user, SMTP)
if self._needThread(user, merge):
threadid = self._createThread(recipient.BatchId, user, document, sender, metadata)
threadid = self._createThread(recipient.BatchId, user, url, sender, metadata)
self._reply = user.useReplyTo()
self._replyto = user.getReplyToAddress()
self._batch = recipient.BatchId
self._metadata = metadata
self._threadid = threadid

def _createThread(self, batch, user, document, sender, metadata):
def _createThread(self, batch, user, url, sender, metadata):
threadid = None
server = self._getMailServer(user, IMAP)
folder = server.getSentFolder()
if server.hasFolder(folder):
subject = metadata.get('Subject')
message = self._getThreadMessage(batch, document, subject, metadata.get('Query'))
message = self._getThreadMessage(batch, url, subject, metadata.get('Query'))
body = self._transferable.getByString(message)
mail = getMailMessage(self._ctx, sender, sender, subject, body)
server.uploadMessage(folder, mail)
threadid = mail.MessageId
server.disconnect()
return threadid

def _getThreadMessage(self, batch, document, subject, query):
title = self._logger.resolveString(1031, g_extension, batch, query)
message = self._logger.resolveString(1032)
label = self._logger.resolveString(1033)
files = self._logger.resolveString(1034)
def _getThreadMessage(self, batch, url, subject, query):
title = self._logger.resolveString(1551, g_extension, batch, query)
message = self._logger.resolveString(1552)
label = self._logger.resolveString(1553)
files = self._logger.resolveString(1554)
if self._hasAttachments():
tag = '<a href="%s">%s</a>'
separator = '</li><li>'
attachments = '<ol><li>%s</li></ol>' % self._getAttachments(tag, separator)
else:
attachments = '<p>%s</p>' % self._logger.resolveString(1035)
attachments = '<p>%s</p>' % self._logger.resolveString(1555)
logo = getMessageImage(self._ctx, self._logo)
return '''\
<!DOCTYPE html>
Expand All @@ -189,13 +195,13 @@ def _getThreadMessage(self, batch, document, subject, query):
</body>
</html>
''' % (g_extension, logo, g_logourl, title, message, subject,
label, document, self._getDocumentTitle(),
label, url, self._getDocumentTitle(),
files, attachments)

def _getMailUser(self, job, sender):
user = getMailUser(self._ctx, sender)
if user is None:
msg = self._getErrorMessage(1512, job, sender)
msg = self._getErrorMessage(1541, job, sender)
raise MailSpoolerException(msg, self._source, ())
return user

Expand All @@ -209,7 +215,7 @@ def _getMailServer(self, user, mailtype):
def _isNewBatch(self, batch):
new = self._batch != batch
if new:
self.dispose()
self._dispose()
return new

def _needThread(self, user, merge):
Expand Down Expand Up @@ -273,12 +279,12 @@ def _getDescriptors(self, merge, metadata):
descriptor = None
if merge:
name = metadata.get('DataSource')
dbcontext, location = getDataBaseContext(self._ctx, self._source, name, self._getErrorMessage, 1501)
dbcontext, location = getDataBaseContext(self._ctx, self._source, name, self._getErrorMessage, 1531)
datasource = dbcontext.getByName(name)
connection = self._getDataSourceConnection(datasource)
table = metadata.get('Table')
if not connection.getTables().hasByName(table):
msg = self._getErrorMessage(1504, name, table)
msg = self._getErrorMessage(1534, name, table)
raise MailSpoolerException(msg, self._source, ())
rowset = self._getRowSet(connection, name, table)
descriptor = {'DataSourceName': name,
Expand Down Expand Up @@ -307,12 +313,10 @@ def _getRowSet(self, connection, name, table):
rowset.Command = table
return rowset

def _getUrls(self, recipient, job, document, merge):
uri = self._uf.parse(document)
def _getMailUrl(self, recipient, url, merge):
uri = self._uf.parse(url)
descriptor = self._getFilteredDescriptor(recipient.Filter, merge)
url = MailUrl(self._ctx, uri, merge, 'html', descriptor)
urls = self._getMailAttachmentUrl(recipient.BatchId, job)
return url, urls
return MailUrl(self._ctx, uri, merge, 'html', descriptor)

def _getFilteredDescriptor(self, filter, merge=True):
if merge:
Expand Down
12 changes: 3 additions & 9 deletions source/eMailerOOo/service/pythonpath/emailer/spooler/spooler.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def _run(self):
self._closed()

def _sendMails(self, jobs):
mailer = Mailer(self._ctx, self._source, self.DataSource.DataBase, self._logger, True)
count = 0
mailer = Mailer(self._ctx, self._source, self.DataSource.DataBase, self._logger, True)
for job in jobs:
self._logger.logprb(INFO, 'MailSpooler', '_sendMails()', 1021, job)
if self._stop.is_set():
Expand All @@ -215,17 +215,11 @@ def _sendMails(self, jobs):
self._logger.logprb(INFO, 'MailSpooler', '_sendMails()', 1022, job)
break
mailer.sendMail(mail)
except MailBaseException as e:
self._error(e)
self._logger.logprb(SEVERE, 'MailSpooler', '_sendMails()', 1023, job, type(e).__name__, e.Message)
continue
except UnoException as e:
self._error(MailBaseException(e.Message, e.Context, ()))
self._logger.logprb(SEVERE, 'MailSpooler', '_sendMails()', 1023, job, type(e).__name__, e.Message)
self._logger.logprb(SEVERE, 'MailSpooler', '_sendMails()', 1023, job, e.__class__.__name__, e.Message)
continue
except Exception as e:
self._error(MailBaseException(str(e), self._source, ()))
self._logger.logprb(SEVERE, 'MailSpooler', '_sendMails()', 1024, job, type(e).__name__, repr(e), traceback.format_exc())
self._logger.logprb(SEVERE, 'MailSpooler', '_sendMails()', 1024, job, e.__class__.__name__, traceback.format_exc())
continue
self.DataSource.DataBase.updateRecipient(1, mail.MessageId, job)
self._logger.logprb(INFO, 'MailSpooler', '_sendMails()', 1025, job)
Expand Down

0 comments on commit dbb3715

Please sign in to comment.