| 1 | #!/usr/bin/python |
|---|
| 2 | # -*- coding: UTF-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2007 Tarek Ziadé |
|---|
| 5 | # |
|---|
| 6 | # Authors: |
|---|
| 7 | # Tarek Ziadé <tarek@ziade.org> |
|---|
| 8 | # |
|---|
| 9 | # This program is free software; you can redistribute it and/or |
|---|
| 10 | # modify it under the terms of the GNU General Public License |
|---|
| 11 | # as published by the Free Software Foundation; either version 2 |
|---|
| 12 | # of the License, or (at your option) any later version. |
|---|
| 13 | # |
|---|
| 14 | # This program is distributed in the hope that it will be useful, |
|---|
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | # GNU General Public License for more details. |
|---|
| 18 | # |
|---|
| 19 | # You should have received a copy of the GNU General Public License |
|---|
| 20 | # along with this program; if not, write to the Free Software |
|---|
| 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | |
|---|
| 23 | import os |
|---|
| 24 | from sqlalchemy import * |
|---|
| 25 | from settings import DATABASE |
|---|
| 26 | |
|---|
| 27 | curdir = os.path.dirname(__file__) |
|---|
| 28 | if curdir == '': |
|---|
| 29 | curdir = '.' |
|---|
| 30 | |
|---|
| 31 | curdir = os.path.realpath(curdir) |
|---|
| 32 | |
|---|
| 33 | sql_db = create_engine(DATABASE) |
|---|
| 34 | metadata = BoundMetaData(sql_db) |
|---|
| 35 | |
|---|
| 36 | mail_data = Table('mailer_mail_data', metadata, |
|---|
| 37 | Column('id', Integer, primary_key=True, autoincrement=True), |
|---|
| 38 | Column('subject', String(300)), |
|---|
| 39 | Column('sender', String(300)), |
|---|
| 40 | Column('recipients', String(300)), |
|---|
| 41 | Column('date', DateTime()), |
|---|
| 42 | Column('data', TEXT())) |
|---|
| 43 | |
|---|
| 44 | try: |
|---|
| 45 | mail_data.create() |
|---|
| 46 | except exceptions.SQLError: |
|---|
| 47 | # already exists |
|---|
| 48 | pass |
|---|
| 49 | |
|---|
| 50 | mailed_data = Table('mailer_mailed_data', metadata, |
|---|
| 51 | Column('id', Integer, primary_key=True, autoincrement=True), |
|---|
| 52 | Column('subject', String(300)), |
|---|
| 53 | Column('sender', String(300)), |
|---|
| 54 | Column('original_id', Integer), |
|---|
| 55 | Column('recipients', String(300)), |
|---|
| 56 | Column('error', String(300)), |
|---|
| 57 | Column('data', TEXT()), |
|---|
| 58 | Column('date', DateTime()), |
|---|
| 59 | Column('status', String(10)),) |
|---|
| 60 | |
|---|
| 61 | try: |
|---|
| 62 | mailed_data.create() |
|---|
| 63 | except exceptions.SQLError: |
|---|
| 64 | # already exists |
|---|
| 65 | pass |
|---|