def pystart(cmd, param=None): try: import agn agn.require('2.0.0') except: self.error(listaErros["semCodAgn"][1], listaErros["semCodAgn"][0]) args = [cmd] if param: args += param.split() args.insert(0, agn.pythonbin) return os.spawnv(os.P_NOWAIT, args[0], args)
def pystart (cmd, param = None): try: import agn agn.require ('2.0.0') except: self.error (listaErros["semCodAgn"][1], listaErros["semCodAgn"][0]) args = [cmd] if param: args += param.split () args.insert (0, agn.pythonbin) return os.spawnv (os.P_NOWAIT, args[0], args)
#!/usr/bin/env python import agn import re import os agn.require('2.3.0') agn.loglevel = agn.LV_INFO agn.lock() agn.log(agn.LV_INFO, 'main', 'Starting up') db = agn.DBaseID() if db is None: agn.die(s='Failed to setup database interface') db.log = lambda a: agn.log(agn.LV_DEBUG, 'db', a) curs = db.cursor() if curs is None: agn.die(s='Failed to get database cursor') emails = set() for record in curs.query("select param from mailing_mt_tbl"): m = re.search('from=".*<(.*)>', record[0]) if not m.group(1) is None: emails.add(m.group(1)) mailloop = "select concat('ext_', b.rid, '@', a.mailloop_domain) from ' + 'company_tbl a inner join " mailloop += "mailloop_tbl b on a.company_id = b.company_id where ' + 'forward_enable = 0 and "
* the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, signal, re import agn agn.require('2.0.4') agn.loglevel = agn.LV_INFO # delay = 30 # class Update: #{{{ def __init__(self, path, name): self.path = path self.name = name self.base = os.path.basename(self.path) if self.path.find(os.sep) != -1: d = os.path.dirname(self.path) else: d = None
* the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import os, signal, time, sre import agn agn.require("2.0.0") agn.loglevel = agn.LV_INFO # syslog = "/var/log/maillog" savefile = agn.base + os.sep + "var" + os.sep + "run" + os.sep + "slrtscan.save" bouncelog = agn.base + os.sep + "var" + os.sep + "spool" + os.sep + "log" + os.sep + "extbounce.log" accountlog = agn.base + os.sep + "var" + os.sep + "spool" + os.sep + "log" + os.sep + "account.log" isstat = sre.compile("sendmail\\[[0-9]+\\]: *([0-9A-F]{6}[0-9A-Z]{3}[0-9A-F]{7,8}):.*stat=(.*)$") iscreat = sre.compile("mail creation: *([0-9A-Z;-]+)") # parser = sre.compile( "^([a-z]{3} +[0-9]+ [0-9]{2}:[0-9]{2}:[0-9]{2}) +([^ ]+) +sendmail\\[[0-9]+\\]: *[0-9A-F]{6}([0-9A-Z]{3})[0-9A-F]{7,8}:(.*)$", sre.IGNORECASE, )
* the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import os, time, signal import shutil import agn agn.require('2.2.5') agn.loglevel = agn.LV_INFO if agn.iswin: import subprocess # class Block: def __init__(self, path): self.path = path self.dir = os.path.dirname(self.path) self.fname = os.path.basename(self.path) elem = self.fname.split('=') self.ts = elem[1] cinfo = elem[2].split('-') self.companyID = int(cinfo[0])
********************************************************************************** AGNITAS plugin service Generic, small, simple plugin infrastructure. """ # import os, re, xmlrpclib import ConfigParser, imp, marshal import agn # # Versioning #{{{ changelog = [ ('1.0.0', '2011-08-30', 'Initial version', '*****@*****.**'), ] version = (changelog[-1][0], '2014-06-05 08:24:34 CEST', 'ud') agn.require('2.10.0') def require(checkversion): agn.__require(checkversion, version, 'aps') #}}} # # class APIDescription {{{ # class APIDescription(object): def __init__(self, description=None): self.description = description self.methods = None
* The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import os, signal, time, errno, socket import email.Message, email.Header, email.Charset import StringIO, codecs import agn agn.require('2.0.0') agn.loglevel = agn.LV_INFO # if not agn.iswin: try: import smenable except ImportError: smenable = None else: smenable = None # delay = 180 configFilename = agn.base + os.sep + 'var' + os.sep + 'spool' + os.sep + 'bav' + os.sep + 'bav.conf' localFilename = agn.base + os.sep + 'conf' + os.sep + 'bav' + os.sep + 'bav.conf-local'
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, signal, re import agn agn.require ('2.0.4') agn.loglevel = agn.LV_INFO # delay = 30 # class Update: #{{{ def __init__ (self, path, name): self.path = path self.name = name self.base = os.path.basename (self.path) if self.path.find (os.sep) != -1: d = os.path.dirname (self.path) else: d = None n = self.base.rfind ('.') if n != -1:
def iniciaServico(self): try: homedrive = os.environ['HOMEDRIVE'] except KeyError: homedrive = 'C:' self.home = homedrive + os.path.sep + 'OpenEMM' if not os.path.isdir (self.home): guess = None for disk in 'CDEFGHIJKLMNOPQRSTUVWXYZ': temp = disk + ':' + os.path.sep + 'OpenEMM' if os.path.isdir (temp): guess = temp break if guess is None: self.error (listaErros["semPasta"][1] % self.home, listaErros["semPasta"][0]) self.home = guess self.show ('Pasta do OpenEMM: %s.' % self.home) checkprop (self,self.home) checkpaths (self,self.home) checkserverxml (self.home) os.environ['HOME'] = self.home binhome = self.home + os.path.sep + 'bin' addpath (binhome) schome = binhome + os.path.sep + 'scripts' os.environ['PYTHONPATH'] = schome if not schome in sys.path: sys.path.append (schome) os.environ['LC_ALL'] = 'C' os.environ['LANG'] = 'en_US.ISO8859_1' os.environ['NLS_LANG'] = 'american_america.UTF8' try: import agn agn.require ('2.0.0') except: self.error (listaErros["semCodAgn"][1], listaErros["semCodAgn"][0]) # # Check for working database if not 'DBase' in dir (agn): self.error (listaErros["semBD"][1], listaErros["semBD"][0]) # # add python to path addpath (agn.pythonpath) # # find jdk jdkkey = r'SOFTWARE\JavaSoft\Java Development Kit' version = agn.winregFind (jdkkey, 'CurrentVersion') if version is None: self.error (listaErros["semJDK"][1], listaErros["semJDK"][0]) javahome = agn.winregFind (jdkkey + '\\' + version, 'JavaHome') addpath (javahome + os.path.sep + 'bin') os.environ['JAVA_HOME'] = javahome os.environ['JAVA_OPTIONS'] = '-Xms256m -Xmx512m -XX:MaxPermSize=256m -Xss256k' # # find tomcat if self.tomcathome is None: for fname in sorted ([_f for _f in os.listdir (homedrive + os.path.sep) if _f.startswith ('apache-tomcat-')]): self.tomcathome = os.path.sep.join ([homedrive, fname]) if self.tomcathome is None: self.error (listaErros["semTomcat"][1], listaErros["semTomcat"][0]) addpath (self.tomcathome + os.path.sep + 'bin') os.environ['CATALINA_HOME'] = self.tomcathome os.environ['CATALINA_BASE'] = self.home # # find mysql mysqlhome = None for version in ['5.0', '5.1']: mskey = r'SOFTWARE\MySQL AB\MySQL Server %s' % version mysqlhome = agn.winregFind (mskey, 'Location') if not mysqlhome is None: break if mysqlhome is None: bkey = r'SOFTWARE\MySQL AB' try: for mskey in sorted ([_r for _r in agn.winregList (bkey) if type (_r) in types.StringTypes]): if 'server' in mskey.lower (): mysqlhome = agn.winregFind ('%s\\%s' % (bkey, mskey), 'Location') except TypeError: self.warning('Servidor MySQL nao encontrado usando reg.key %s. Isto so e um problema, se voce NAO utiliza banco de dados remoto.' % bkey) if not mysqlhome is None: addpath (mysqlhome + os.path.sep + 'bin') # # db = agn.DBase () if not db: self.error (listaErros["erroConfBD"][1], listaErros["erroConfBD"][0]) i = db.cursor () if not i: self.error (listaErros["erroConexaoBD"][1], listaErros["erroConexaoBD"][0]) i.close () db.close () # # remove potential stale files sessions = os.path.sep.join ([self.home, 'webapps', 'openemm', 'WEB-INF', 'sessions']) fnames = [agn.winstopfile] if os.path.isdir (sessions): for fname in os.listdir (sessions): fnames.append (sessions + os.path.sep + fname) for fname in fnames: try: os.unlink (fname) # show ('Removed stale file %s.\n' % fname) except (WindowsError, OSError): pass # # change to home directory os.chdir (self.home) # # Iniciando p_upd = pystart (schome + os.path.sep + 'update.py', 'account bounce') if p_upd == -1: self.error (listaErros["erroIniUpdate"][1], listaErros["erroIniUpdate"][0]) p_dst = pystart (schome + os.path.sep + 'pickdist.py') if p_dst == -1: self.error (listaErros["erroIniPickdist"][1], listaErros["erroIniPickdist"][0]) p_bav = pystart (schome + os.path.sep + 'bav-update.py') if p_bav == -1: self.error (listaErros["erroIniBavupdate"][1], listaErros["erroIniBavupdate"][0]) p_sem = pystart (schome + os.path.sep + 'semu.py') if p_sem == -1: self.error (listaErros["erroIniSemu"][1], listaErros["erroIniSemu"][0]) p_con = tomcatstart (self, 'openemm') if p_con == -1: self.error (listaErros["erroIniTomcat"][1], listaErros["erroIniTomcat"][0]) return agn.winstopfile
* the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, gzip, re, codecs import agn agn.loglevel = agn.LV_DEBUG agn.require ('2.2.3') # class Mailing (agn.struct): #{{{ meta = agn.mkpath (agn.base, 'var', 'spool', 'META') archive = agn.mkpath (agn.base, 'var', 'spool', 'ARCHIVE') def __init__ (self, statusID, statusField, mailingID, companyID, check): #{{{ self.statusID = statusID self.statusField = statusField self.mailingID = mailingID self.companyID = companyID self.check = check self.seen = None self.pattern = None self.tempFile = agn.mkpath (self.meta, '.recover-%d.temp' % self.statusID) self.recoverFile = agn.mkpath (self.meta, 'recover-%d.list' % self.statusID) self.count = 0
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, signal, re import agn agn.require('2.9.9') agn.loglevel = agn.LV_INFO # delay = 30 parallel = True # class Update: #{{{ def __init__(self, path, name): self.path = path self.name = name self.base = os.path.basename(self.path) if self.path.find(os.sep) != -1: d = os.path.dirname(self.path) else:
* the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import os, time, signal import shutil, subprocess import agn agn.require ('2.2.5') agn.loglevel = agn.LV_INFO # class Block: def __init__ (self, path): self.path = path self.dir = os.path.dirname (self.path) self.fname = os.path.basename (self.path) elem = self.fname.split ('=') self.ts = elem[1] cinfo = elem[2].split ('-') self.companyID = int (cinfo[0]) self.mailingID = int (elem[3]) self.blockID = elem[4] try: self.blocknr = int (self.blockID)
********************************************************************************** AGNITAS plugin service Generic, small, simple plugin infrastructure. """ # import os, re, xmlrpclib import ConfigParser, imp, marshal import agn # # Versioning #{{{ changelog = [ ('1.0.0', '2011-08-30', 'Initial version', '*****@*****.**'), ] version = (changelog[-1][0], '2014-06-05 08:24:34 CEST', 'ud') agn.require ('2.10.0') def require (checkversion): agn.__require (checkversion, version, 'aps') #}}} # # class APIDescription {{{ # class APIDescription (object): def __init__ (self, description = None): self.description = description self.methods = None def reset (self): self.methods = None def register (self, method):
def iniciaServico(self): try: homedrive = os.environ['HOMEDRIVE'] except KeyError: homedrive = 'C:' self.home = homedrive + os.path.sep + 'OpenEMM' if not os.path.isdir(self.home): guess = None for disk in 'CDEFGHIJKLMNOPQRSTUVWXYZ': temp = disk + ':' + os.path.sep + 'OpenEMM' if os.path.isdir(temp): guess = temp break if guess is None: self.error(listaErros["semPasta"][1] % self.home, listaErros["semPasta"][0]) self.home = guess self.show('Pasta do OpenEMM: %s.' % self.home) checkprop(self, self.home) checkpaths(self, self.home) checkserverxml(self.home) os.environ['HOME'] = self.home binhome = self.home + os.path.sep + 'bin' addpath(binhome) schome = binhome + os.path.sep + 'scripts' os.environ['PYTHONPATH'] = schome if not schome in sys.path: sys.path.append(schome) os.environ['LC_ALL'] = 'C' os.environ['LANG'] = 'en_US.ISO8859_1' os.environ['NLS_LANG'] = 'american_america.UTF8' try: import agn agn.require('2.0.0') except: self.error(listaErros["semCodAgn"][1], listaErros["semCodAgn"][0]) # # Check for working database if not 'DBase' in dir(agn): self.error(listaErros["semBD"][1], listaErros["semBD"][0]) # # add python to path addpath(agn.pythonpath) # # find jdk jdkkey = r'SOFTWARE\JavaSoft\Java Development Kit' version = agn.winregFind(jdkkey, 'CurrentVersion') if version is None: self.error(listaErros["semJDK"][1], listaErros["semJDK"][0]) javahome = agn.winregFind(jdkkey + '\\' + version, 'JavaHome') addpath(javahome + os.path.sep + 'bin') os.environ['JAVA_HOME'] = javahome os.environ[ 'JAVA_OPTIONS'] = '-Xms256m -Xmx512m -XX:MaxPermSize=256m -Xss256k' # # find tomcat if self.tomcathome is None: for fname in sorted([ _f for _f in os.listdir(homedrive + os.path.sep) if _f.startswith('apache-tomcat-') ]): self.tomcathome = os.path.sep.join([homedrive, fname]) if self.tomcathome is None: self.error(listaErros["semTomcat"][1], listaErros["semTomcat"][0]) addpath(self.tomcathome + os.path.sep + 'bin') os.environ['CATALINA_HOME'] = self.tomcathome os.environ['CATALINA_BASE'] = self.home # # find mysql mysqlhome = None for version in ['5.0', '5.1']: mskey = r'SOFTWARE\MySQL AB\MySQL Server %s' % version mysqlhome = agn.winregFind(mskey, 'Location') if not mysqlhome is None: break if mysqlhome is None: bkey = r'SOFTWARE\MySQL AB' try: for mskey in sorted([ _r for _r in agn.winregList(bkey) if type(_r) in types.StringTypes ]): if 'server' in mskey.lower(): mysqlhome = agn.winregFind('%s\\%s' % (bkey, mskey), 'Location') except TypeError: self.warning( 'Servidor MySQL nao encontrado usando reg.key %s. Isto so e um problema, se voce NAO utiliza banco de dados remoto.' % bkey) if not mysqlhome is None: addpath(mysqlhome + os.path.sep + 'bin') # # db = agn.DBase() if not db: self.error(listaErros["erroConfBD"][1], listaErros["erroConfBD"][0]) i = db.cursor() if not i: self.error(listaErros["erroConexaoBD"][1], listaErros["erroConexaoBD"][0]) i.close() db.close() # # remove potential stale files sessions = os.path.sep.join( [self.home, 'webapps', 'openemm', 'WEB-INF', 'sessions']) fnames = [agn.winstopfile] if os.path.isdir(sessions): for fname in os.listdir(sessions): fnames.append(sessions + os.path.sep + fname) for fname in fnames: try: os.unlink(fname) # show ('Removed stale file %s.\n' % fname) except (WindowsError, OSError): pass # # change to home directory os.chdir(self.home) # # Iniciando p_upd = pystart(schome + os.path.sep + 'update.py', 'account bounce') if p_upd == -1: self.error(listaErros["erroIniUpdate"][1], listaErros["erroIniUpdate"][0]) p_dst = pystart(schome + os.path.sep + 'pickdist.py') if p_dst == -1: self.error(listaErros["erroIniPickdist"][1], listaErros["erroIniPickdist"][0]) p_bav = pystart(schome + os.path.sep + 'bav-update.py') if p_bav == -1: self.error(listaErros["erroIniBavupdate"][1], listaErros["erroIniBavupdate"][0]) p_sem = pystart(schome + os.path.sep + 'semu.py') if p_sem == -1: self.error(listaErros["erroIniSemu"][1], listaErros["erroIniSemu"][0]) p_con = tomcatstart(self, 'openemm') if p_con == -1: self.error(listaErros["erroIniTomcat"][1], listaErros["erroIniTomcat"][0]) return agn.winstopfile
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import time import agn agn.require ('2.3.0') agn.loglevel = agn.LV_INFO # agn.lock () agn.log (agn.LV_INFO, 'main', 'Starting up') db = agn.DBaseID () if db is None: agn.die (s = 'Failed to setup database interface') db.log = lambda a: agn.log (agn.LV_DEBUG, 'db', a) curs = db.cursor () if curs is None: agn.die (s = 'Failed to get database cursor') mailtrackTable = 'bounce_collect_tbl' # # # 1.) Kill old softbounces
* * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import os, time, signal import shutil import agn agn.require("2.2.5") agn.loglevel = agn.LV_INFO if agn.iswin: import subprocess # class Block: def __init__(self, path): self.path = path self.dir = os.path.dirname(self.path) self.fname = os.path.basename(self.path) elem = self.fname.split("=") self.ts = elem[1] cinfo = elem[2].split("-") self.companyID = int(cinfo[0]) self.mailingID = int(elem[3]) self.blockID = elem[4]
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, signal, re import agn agn.require ('2.9.9') agn.loglevel = agn.LV_INFO # delay = 30 parallel = True # class Update: #{{{ def __init__ (self, path, name): self.path = path self.name = name self.base = os.path.basename (self.path) if self.path.find (os.sep) != -1: d = os.path.dirname (self.path) else: d = None n = self.base.rfind ('.')
* * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import BaseHTTPServer, cgi, urllib, urllib2 import sys, os, signal, time, re, types, mutex import fnmatch try: import gdbm except ImportError: gdbm = None import email, email.Header import agn agn.require ('2.0.0') # agn.loglevel = agn.LV_INFO # alock = mutex.mutex () class Autoresponder: msgPattern = agn.base + os.sep + 'var' + os.sep + 'spool' + os.sep + 'bav' + os.sep + 'ar_%s.mail' limitPattern = agn.base + os.sep + 'var' + os.sep + 'spool' + os.sep + 'bav' + os.sep + 'ar_%s.limit' wlFile = agn.base + os.sep + 'conf' + os.sep + 'bav' + os.sep + 'ar.whitelist' wlPattern = agn.base + os.sep + 'conf' + os.sep + 'bav' + os.sep + 'ar_%s.whitelist' def __init__ (self, aid, sender): self.aid = aid self.sender = sender
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************** """ # import sys, os, getopt, time, signal, re import agn agn.require ('2.9.8') agn.loglevel = agn.LV_INFO # delay = 30 # class Update: #{{{ def __init__ (self, path, name): self.path = path self.name = name self.base = os.path.basename (self.path) if self.path.find (os.sep) != -1: d = os.path.dirname (self.path) else: d = None n = self.base.rfind ('.') if n != -1: