Skip to content

Instantly share code, notes, and snippets.

@tthoma24
Created December 12, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tthoma24/29ba5fd8525276ddf82f93456b1a9178 to your computer and use it in GitHub Desktop.
Save tthoma24/29ba5fd8525276ddf82f93456b1a9178 to your computer and use it in GitHub Desktop.
Python settings file from GSB lists
#!/usr/bin/python2.7
import pyodbc
import settings # file settings.py
# [SNIP]
try:
if from_field.strip() != "":
conn_str = Template('Driver=FreeTDS;DSN=connections;uid=$user;pwd=$password')
cnxn = pyodbc.connect(conn_str.substitute(user = settings.db_user, password = settings.db_password))
cursor = cnxn.cursor()
cursor.execute("INSERT INTO mailPost (Author,Subject,creationDate,XCBSList,XCBSDate,XCBSMessageID,XCBSMessageParent,XCBSTopicMessageID) values (?, ?, getDate(), ?, ?, ?, ?, 'None')",
(from_field[:255], subj[:255], msg['X-CBS-List'][:50], msg['X-CBS-Date'][:50], msg['X-CBS-Message-ID'][:50], msg['X-CBS-Message-Parent'][:50]))
cursor.commit()
cursor.close()
cnxn.close()
# [SNIP]
############################################
# Email-unpack settings
# Usage:
# import settings
# print settings.variable
############################################
debug_trace = "false";
import socket
hostname = socket.gethostname()
#Stage Settings(190.62)
if(hostname == "stag-lists-01"):
db_user = 'alumnidb'
db_password = '[REDACTED]'
sender = "postmaster_stage@lists.gsb.columbia.edu"
postmaster = ['[REDACTED]@gsb.columbia.edu']
#Development Settings(84.113)
if(hostname == "dev-lists-01"):
db_user = 'dev_srv_alumni'
db_password = '[REDACTED]'
postmaster = ['[REDACTED]@gsb.columbia.edu']
#Production Settings(84.70)
if(hostname == "prod-lists-01"):
db_user = 'alumnidb'
db_password = '[REDACTED]'
postmaster = ['[REDACTED]@gsb.columbia.edu','[REDACTED]@gsb.columbia.edu']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment