Ejemplo n.º 1
0
def setup_module():
    global me
    if me:
        return
    me = Me()
    me.testDB = TestDB()
    me.config = configurationManager.newConfiguration(
        configurationModule=testConfig,
        applicationName='TestingCachedIdAccess')
    myDir = os.path.split(__file__)[0]
    if not myDir: myDir = '.'
    replDict = {'testDir': '%s' % myDir}
    for i in me.config:
        try:
            me.config[i] = me.config.get(i) % (replDict)
        except:
            pass
    cia.logger.setLevel(logging.DEBUG)
    me.logFilePathname = me.config.logFilePathname
    logfileDir = os.path.split(me.config.logFilePathname)[0]
    try:
        os.makedirs(logfileDir)
    except OSError, x:
        if errno.EEXIST != x.errno: raise
        f = open(me.config.logFilePathname, 'w')
        f.close()
Ejemplo n.º 2
0
def main():
    logger = logging.getLogger("topcrashes_summary")
    logger.setLevel(logging.WARNING)

    stderrLog = logging.StreamHandler()
    stderrLog.setLevel(logging.WARNING)
    stderrLogFormatter = logging.Formatter(
        '%(asctime)s %(levelname)s - %(message)s')
    stderrLog.setFormatter(stderrLogFormatter)
    logger.addHandler(stderrLog)

    kwargs = {}
    for i in sys.argv[1:]:
        if i.startswith('-h') or i.startswith('--he'):
            help()
            sys.exit(0)
        j = i
        if i.startswith('-'):
            j = i.lstrip('-')
        if '=' in j:
            name, value = (s.strip() for s in j.split('='))
            kwargs[name] = value
        else:
            print >> sys.stderr, "Ignoring unkown argument '%s'" % (i)
    sys.argv = sys.argv[:1]
    config = configurationManager.newConfiguration(
        configurationModule=testConfig, applicationName='Create Database')
    config.update(kwargs)
    testDB = TestDB()
    testDB.removeDB(config, logger)
    testDB.createDB(config, logger)
Ejemplo n.º 3
0
 def setUp(self):
     global me
     if not me:
         createMe()
     self.testDB = TestDB()
     self.testDB.removeDB(me.config, me.logger)
     self.testDB.createDB(me.config, me.logger)
     #self.connection = psycopg2.connect(me.dsn)
     self.connection = me.database.connection()
Ejemplo n.º 4
0
 def setUp(self):
     global me
     # config gets messed up by some tests. Use this one by preference
     self.config = configurationManager.newConfiguration(
         configurationModule=testConfig,
         applicationName='Testing Postgresql Utils')
     for i in self.config:
         try:
             self.config[i] = self.config.get(i) % (replDict)
         except:
             pass
     self.connection = psycopg2.connect(me.dsn)
     self.testDB = TestDB()
        if errno.EEXIST == x.errno: pass
        else: raise
    f = open(me.logFilePathname, 'w')
    f.close()
    fileLog = logging.FileHandler(me.logFilePathname, 'a')
    fileLog.setLevel(logging.DEBUG)
    fileLogFormatter = logging.Formatter(
        '%(asctime)s %(levelname)s - %(message)s')
    fileLog.setFormatter(fileLogFormatter)
    me.logger = logging.getLogger("db_test")
    me.logger.addHandler(fileLog)
    me.logger.setLevel(logging.DEBUG)
    me.dsn = "host=%s dbname=%s user=%s password=%s" % (
        me.config.databaseHost, me.config.databaseName,
        me.config.databaseUserName, me.config.databasePassword)
    me.testDB = TestDB()


def teardown_module():
    pass


tptCreationSql = "CREATE TABLE %s (id serial not null primary key, date_col timestamp with time zone)"
partitionSql = "CREATE table %%(partitionName)s () INHERITS (%s)"
tptPartitionCreationSqlTemplate = partitionSql % 'tpt'
tpt3PartitionCreationSqlTemplate = partitionSql % 'tpt3'


class TPT(schema.PartitionedTable):
    def __init__(self, logger):
        super(TPT, self).__init__(