Added bat file to source correct venv and run script. Reorganized db connection stuff and added check to create db/tables if they don't exist. Uncommented email section and set mark_sent method to only be called if not testing.
This commit is contained in:
2
CFFInvoice.bat
Normal file
2
CFFInvoice.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@echo off
|
||||||
|
cmd /k "cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice\Scripts & activate & cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice & python main.py"
|
||||||
@@ -3,9 +3,6 @@ from sqlalchemy import create_engine, Column, Integer, String, REAL, Boolean
|
|||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
|
||||||
engine = create_engine('sqlite:///cffInvoice.db')
|
|
||||||
engine.connect()
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +30,7 @@ class Invoice(Base):
|
|||||||
ShippingState = Column(String)
|
ShippingState = Column(String)
|
||||||
ShippingPostalCode = Column(String)
|
ShippingPostalCode = Column(String)
|
||||||
InvoiceID = Column(Integer, primary_key=True, autoincrement=True)
|
InvoiceID = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
InvoiceSent = Column(Boolean)
|
InvoiceSent = Column(Boolean, default=0)
|
||||||
|
|
||||||
|
|
||||||
class ItemDetail(Base):
|
class ItemDetail(Base):
|
||||||
@@ -53,7 +50,11 @@ class SentInvoices(Base):
|
|||||||
InvoiceID = Column(Integer)
|
InvoiceID = Column(Integer)
|
||||||
SentDate = Column(String)
|
SentDate = Column(String)
|
||||||
|
|
||||||
|
engine = create_engine('sqlite:///cffInvoice.db')
|
||||||
|
engine.connect()
|
||||||
|
Invoice.__table__.create(bind=engine, checkfirst=True)
|
||||||
|
ItemDetail.__table__.create(bind=engine, checkfirst=True)
|
||||||
|
SentInvoices.__table__.create(bind=engine, checkfirst=True)
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
|
|
||||||
|
|||||||
14
sendEmail.py
14
sendEmail.py
@@ -191,13 +191,13 @@ def send_email(test, record):
|
|||||||
|
|
||||||
msg.add_header('Content-Type', 'text/html')
|
msg.add_header('Content-Type', 'text/html')
|
||||||
msg.attach(bodyHTML)
|
msg.attach(bodyHTML)
|
||||||
# try:
|
try:
|
||||||
# with smtplib.SMTP(smtp_server, port, timeout=120) as server:
|
with smtplib.SMTP(smtp_server, port, timeout=120) as server:
|
||||||
# # server.sendmail(msg['From'], msg['To'] + ',' + msg['Cc'] + ',' + msg['Bcc'], msg.as_string())
|
# server.sendmail(msg['From'], msg['To'] + ',' + msg['Cc'] + ',' + msg['Bcc'], msg.as_string())
|
||||||
# server.send_message(msg)
|
server.send_message(msg)
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# print(e)
|
print(e)
|
||||||
if test is True:
|
if test is False:
|
||||||
InvoiceDatabase.mark_sent(InvoiceID, InvoiceDate)
|
InvoiceDatabase.mark_sent(InvoiceID, InvoiceDate)
|
||||||
sent_orders.append(OrderNumber)
|
sent_orders.append(OrderNumber)
|
||||||
print(sent_orders)
|
print(sent_orders)
|
||||||
|
|||||||
Reference in New Issue
Block a user