Example #1
0
    def __init__(self,
                 dbUser=None,
                 dbName=None,
                 dbHost=None,
                 dbPwd=None,
                 SQLiteDB=None,
                 tablePerPlatform=False,
                 chart=False):
        self.tablePerPlatform = tablePerPlatform  #Flag that specifies whether or not we create a seperate HTML page per platform. True, each platform gets a seperate page, False all results on 1.
        self.chart = chart  #Flag that specifies if we add a URL to a google chart for the observation.
        if (SQLiteDB == None):
            self.xeniaDB = xeniaPostGres()  #Database object.
            if (self.xeniaDB.connect(None, dbUser, dbPwd, dbHost, dbName)):
                print("Successfully connected to Xenia DB: Name: %s at %s\n" %
                      (dbName, dbHost))
            else:
                print( "Failed to connect to Xenia DB: Host: %s Name: %s User: %s(%s)\nError: %s"\
                        %( dbHost, dbName, dbUser, dbPwd, self.xeniaDB.getErrorInfo() ) )
                sys.exit(-1)
        else:
            self.xeniaDB = xeniaSQLite()  #Database object.
            if (self.xeniaDB.connect(SQLiteDB)):
                print("Successfully connected to Xenia DB: Name: %s\n" %
                      (SQLiteDB))
            else:
                print( "Failed to connect to Xenia DB: %s\nError: %s"\
                        %( SQLiteDB, self.xeniaDB.getErrorInfo() ) )
                sys.exit(-1)

        self.obsDataPoints = recursivedefaultdict(
        )  #Dictionary keyed on obs and sOrder for each data point. Used to collect the points to graph.
Example #2
0
 def __init__(self, dbUser=None, dbName=None, dbHost=None, dbPwd=None, SQLiteDB=None, tablePerPlatform=False,chart=False):
   self.tablePerPlatform = tablePerPlatform    #Flag that specifies whether or not we create a seperate HTML page per platform. True, each platform gets a seperate page, False all results on 1.
   self.chart = chart  #Flag that specifies if we add a URL to a google chart for the observation.
   if(SQLiteDB == None):
     self.xeniaDB = xeniaPostGres()  #Database object.
     if( self.xeniaDB.connect( None, dbUser, dbPwd, dbHost, dbName ) ):
       print( "Successfully connected to Xenia DB: Name: %s at %s\n" % ( dbName, dbHost) )
     else:
       print( "Failed to connect to Xenia DB: Host: %s Name: %s User: %s(%s)\nError: %s"\
               %( dbHost, dbName, dbUser, dbPwd, self.xeniaDB.getErrorInfo() ) )      
       sys.exit(-1)
   else:
     self.xeniaDB = xeniaSQLite()  #Database object.
     if( self.xeniaDB.connect( SQLiteDB ) ):
       print( "Successfully connected to Xenia DB: Name: %s\n" % ( SQLiteDB) )
     else:
       print( "Failed to connect to Xenia DB: %s\nError: %s"\
               %( SQLiteDB, self.xeniaDB.getErrorInfo() ) )      
       sys.exit(-1)
     
   self.obsDataPoints = recursivedefaultdict() #Dictionary keyed on obs and sOrder for each data point. Used to collect the points to graph.
Example #3
0
  def __init__(self, configSettings):
    
    alertsDBFile = configSettings.getEntry("//environment/database/alertsDB/name")   
    xeniaDBSettings = configSettings.getDatabaseSettings()
    conversionXMLFile = configSettings.getEntry("//environment/unitsConversion/file")
    
    self.unsubURL = configSettings.getEntry("//environment/unsubscribeURL")
    self.georssURL = configSettings.getEntry("//environment/geoRSSURL")
    self.surveyURL = configSettings.getEntry("//environment/surveyURL")
    
    self.uomConverter = uomconversionFunctions( conversionXMLFile )        
    self.logger = logging.getLogger("emailalert_logger.alertsDB")
    self.logger.info("creating an instance of emailAlerts")
    
    self.alertsDB = alertsDB( alertsDBFile )
    if( self.alertsDB.connectDB() == False ):
      self.logger.error( "Unable to connect to Alerts DB: %s" % ( alertsDBFile ) )
      sys.exit(-1)
    else:
      self.logger.debug( "Connected to Alerts DB: %s" % ( alertsDBFile ) )

    if( xeniaDBSettings['type'] == 'SQLite' ):     
      self.obsDB = xeniaSQLite()
      if( self.obsDB.connect( xeniaDBSettings['dbName'] ) == False ):
        self.logger.error( "Unable to connect to xenia DB: %s Error: %s" % ( xeniaDBSettings['dbName'], self.obsDB.lastErrorMsg ) )
        sys.exit(-1)
      else:
        self.logger.debug( "Connected to xenia DB: %s" % ( xeniaDBSettings['dbName'] ) )
    else:
      self.obsDB = xeniaPostGres()
      if( self.obsDB.connect( None, 
                      xeniaDBSettings['dbUser'],
                      xeniaDBSettings['dbPwd'],
                      xeniaDBSettings['dbHost'],
                      xeniaDBSettings['dbName']
                     ) == False ):
        self.logger.error( "Unable to connect to xeniaDB: %s Host: %s User: %s\nError: %s" % (xeniaDBSettings['dbName'], xeniaDBSettings['dbHost'], xeniaDBSettings['dbUser'] ,self.obsDB.lastErrorMsg) )
        sys.exit(-1)
      else:
        self.logger.debug( "Connected to Host: %s Name: %s User: %s", xeniaDBSettings['dbHost'],xeniaDBSettings['dbName'],xeniaDBSettings['dbUser']  )