예제 #1
0
class Database:
    """
	PostgreSQL specific database adapter.
	"""
    def __init__(self, configFile=None, logger=None):
        self.configParser = Config(configFile, logger=logger)

        self.logger = logger
        self.downTime = None
        self.connection = None
        self.transaction_cursor = None

    def connect(self):
        """
		Connection to database. Settings are loaded from config.ini

		@raise DatabaseConnectionFailedException Raised when conneciton to database failed.
		"""
        host = self.configParser.get('database', 'host')
        db = self.configParser.get('database', 'database')
        user = self.configParser.get('database', 'username')
        password = self.configParser.get('database', 'password')

        try:
            self.connection = pgdb.connect(dsn=host + ":" + db,
                                           user=user,
                                           password=password)
        except pgdb.DatabaseError, e:
            raise DatabaseConnectionFailedException(e)
예제 #2
0
파일: database.py 프로젝트: dotse/Mailcheck
class Database:
	"""
	PostgreSQL specific database adapter.
	"""
	def __init__(self, configFile=None, logger=None):
		self.configParser = Config(configFile, logger=logger)

		self.logger = logger
		self.downTime = None
		self.connection = None
		self.transaction_cursor = None

	def connect(self):
		"""
		Connection to database. Settings are loaded from config.ini

		@raise DatabaseConnectionFailedException Raised when conneciton to database failed.
		"""
		host = self.configParser.get('database', 'host')
		db = self.configParser.get('database', 'database')
		user = self.configParser.get('database', 'username')
		password = self.configParser.get('database', 'password')

		try:
			self.connection = pgdb.connect(dsn=host+":"+db, user=user, password=password)
		except pgdb.DatabaseError, e:
			raise DatabaseConnectionFailedException(e)
예제 #3
0
def get_application(config=None):
    if config is None:
        config = Config()
    apppath = config.get('application', 'engine.app.application')
    appfunc = load_object(apppath)
    # heart_beat(config)
    return appfunc(config)
예제 #4
0
파일: pop.py 프로젝트: tejastank/Mailcheck
import poplib
import socket

from subprocess import Popen, PIPE

from engine.config import Config


config = Config()
password = config.get('email', 'password')

handle_mail="/var/www/mailcheck/engine/handle_mail.py"
handle_mail_args="-ihotmail"
output=""

M = None
try:
  M=poplib.POP3_SSL("pop3.live.com", "995")
except socket.error:
  sys.exit(1)
except socket.timeout:
  sys.exit(1)
M.user("*****@*****.**")
M.pass_(password)

numMessages = len(M.list()[1])
for i in range(numMessages):
  p=Popen([handle_mail, handle_mail_args], stdin=PIPE, close_fds=True)
  for j in M.retr(i+1)[1]:
    output += j+"\n"
  p.stdin.write(output);