def setUp(self): global config_path global cwd # Save and set the current working directory in case some service changes it. if not cwd: cwd = os.getcwd() else: os.chdir(cwd) try: self.config_dict = configobj.ConfigObj(config_path, file_error=True, encoding='utf-8') except IOError: sys.stderr.write("Unable to open configuration file %s" % self.config_path) # Reraise the exception (this will eventually cause the program to exit) raise except configobj.ConfigObjError: sys.stderr.write("Error while parsing configuration file %s" % config_path) raise # Remove the old directory: try: test_html_dir = os.path.join(self.config_dict['WEEWX_ROOT'], self.config_dict['StdReport']['HTML_ROOT']) shutil.rmtree(test_html_dir) except OSError as e: if os.path.exists(test_html_dir): print("\nUnable to remove old test directory %s", test_html_dir, file=sys.stderr) print("Reason:", e, file=sys.stderr) print("Aborting", file=sys.stderr) exit(1) # This will generate the test databases if necessary: gen_fake_data.configDatabases(self.config_dict, database_type=self.database_type)
def setUp(self): global config_path global cwd # Save and set the current working directory in case some service changes it. if cwd: os.chdir(cwd) else: cwd = os.getcwd() try: self.config_dict = configobj.ConfigObj(config_path, file_error=True, encoding='utf-8') except IOError: sys.stderr.write("Unable to open configuration file %s" % self.config_path) # Reraise the exception (this will eventually cause the program to exit) raise except configobj.ConfigObjError: sys.stderr.write("Error while parsing configuration file %s" % config_path) raise # This will generate the test databases if necessary: gen_fake_data.configDatabases(self.config_dict, database_type=self.database_type)
def setUp(self): global config_path global cwd weewx.debug = 1 syslog.openlog('test_stats', syslog.LOG_CONS) syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG)) # Save and set the current working directory in case some service changes it. if not cwd: cwd = os.getcwd() else: os.chdir(cwd) try : config_dict = configobj.ConfigObj(config_path, file_error=True) except IOError: sys.stderr.write("Unable to open configuration file %s" % self.config_path) # Reraise the exception (this will eventually cause the program to exit) raise except configobj.ConfigObjError: sys.stderr.write("Error while parsing configuration file %s" % config_path) raise self.archive_db_dict = config_dict['Databases'][self.archive_db] self.stats_db_dict = config_dict['Databases'][self.stats_db] # This will generate the test databases if necessary: gen_fake_data.configDatabases(self.archive_db_dict, self.stats_db_dict)
def setUp(self): global config_path global cwd weewx.debug = 1 syslog.openlog('test_templates', syslog.LOG_CONS) syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG)) # Save and set the current working directory in case some service changes it. if not cwd: cwd = os.getcwd() else: os.chdir(cwd) try: self.config_dict = configobj.ConfigObj(config_path, file_error=True) except IOError: sys.stderr.write("Unable to open configuration file %s" % config_path) # Reraise the exception (this will eventually cause the program to exit) raise except configobj.ConfigObjError: sys.stderr.write("Error while parsing configuration file %s" % config_path) raise # Remove the old directory: try: test_html_dir = os.path.join( self.config_dict['WEEWX_ROOT'], self.config_dict['StdReport']['HTML_ROOT']) shutil.rmtree(test_html_dir) except OSError as e: if os.path.exists(test_html_dir): print >> sys.stderr, "\nUnable to remove old test directory %s", test_html_dir print >> sys.stderr, "Reason:", e print >> sys.stderr, "Aborting" exit(1) # This will generate the test databases if necessary: gen_fake_data.configDatabases(self.config_dict, database_type=self.database_type)
def setUp(self): global config_path try: self.config_dict = configobj.ConfigObj(config_path, file_error=True, encoding='utf-8') except IOError: sys.stderr.write("Unable to open configuration file %s" % config_path) # Reraise the exception (this will eventually cause the program to exit) raise except configobj.ConfigObjError: sys.stderr.write("Error while parsing configuration file %s" % config_path) raise # This will generate the test databases if necessary. Use the SQLite database: it's faster. gen_fake_data.configDatabases(self.config_dict, database_type='sqlite')