Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. class PartsDS(EmailProcessor):
  2. desc_template = '[Parts Request]\n\nAuthor:{auth}\nSubject: {subj}' + \
  3. '\n\nDescription: {desc}'
  4.  
  5. def __init__(self, config, crm_addr, running):
  6. super().__init__(config, crm_addr, running)
  7.  
  8. self.imap_server = config['partsds']['imap_server']
  9. self.imap_user = config['partsds']['imap_user']
  10. self.imap_password = config['partsds']['imap_password']
  11.  
  12. self.dest_acct = config['partsds']['destination_acct']
  13. self.mgr = config['partsds']['manager']
  14.  
  15. self.allowed_domains = [domain.strip() \
  16. for domain in config['partsds']['allowed_domains'].split(',')]
  17.  
  18. self._interval = int(config['partsds']['interval'])
  19.  
  20. def _process_message(self, msg):
  21. ticket = entities.Ticket()
  22.  
  23. desc = self.desc_template.format(auth = msg.get_from_addr(),
  24. subj = msg.subject,
  25. desc = msg.get_plaintext_body())
  26.  
  27. ticket.set_field('AccountRecID', self.dest_acct)
  28. ticket.set_field('Description', desc)
  29. ticket.set_field('EmpRecID', self.mgr)
  30.  
  31. logging.info('Created Parts ticket for UID %s', msg.uid)
  32. return ticket
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement