def __init__(self, me_master, settings_inst=None, plot_figure=None): '''CONSTRUCTOR''' Settings.__init__(self, load_initial_settings=False) if not (isinstance(settings_inst, type(None))): self.ResetSettings(settings_inst.GetRawSettings()) else: self.GetInitialSettings() self.__me_master = me_master self.__droneVision_ready = False self.__crop_frames = False self.__delta_fan_angle_divisor = 1.0 if (self.GetSettings('LASER', 'fan_angle') < self.GetSettings( 'CAMERA', 'fan_angle')) and self.GetSettings( 'CV', 'crop_frames'): self.__crop_frames = True self.__delta_fan_angle_divisor = self.GetSettings( 'LASER', 'fan_angle') / self.GetSettings( 'CAMERA', 'fan_angle') self.CheckManualTriggeringAndAutoMode() PointDetection.__init__(self, self.__me_master, self.GetSettings(), plot_figure=plot_figure) Heading.__init__(self, self.GetSettings('CV', 'rho_step_distance'), self.GetSettings('CV', 'rho_min_diag_perc'))
def PrintInfo(): ''' @brief Print info about how to use this program. ''' preset_settings = Settings(skip_checking_for_user_input_cmd_line=True, skip_checking_for_user_input=True) static_settings = preset_settings.GetStaticSettings() print "#------------------------ INFO ------------------------#" print "# Start program by typing 'sudo python main.py' or './main.py', and append following options:" print "# \t Append 'run' with either 'master' or 'slave' to start the main program." print "# \t\t Starting master device: 'sudo python main.py run master'." print "# \t\t Starting slave device: 'sudo python main.py run slave'." print "# \t Calibration of the stereopsis system and/or the standard distance between blobs may be initiated by appending following after 'run master':" print "# \t\t Calibrating both the stereopsis system and the standard distance between blobs, append: 'calibrate'" print "# \t\t Calibrating stereopsis system only, append: 'calibrate_stereopsis'" print "# \t\t Calibrating standard distance between blobs only, append: 'calibrate_blobs'" print "# \t\t (Hint: a full calibration reset may be initiated by just entering one of the calibration commands, and stepping through without capturing any new calibration frames.)" print "# \t Change a specifig setting (may be a mix of lower or upper case):" print "# \t\t -SETTING_TYPE --SETTING ---NEW_SETTING_VALUE" print "# \t Change a specific setting by entering a valid python code, may be commenced by typing: " print "# \t\t -SETTING_TYPE --SETTING" print "# Saved sessions may be simulated by typing 'simulate video' or 'simulate image' instead of 'master'/'slave', with video or image targets given by the settings configurations." print "# Program settings may be changed in detail by changing the settings configuration json file." print "# Program settings may be found at {0}.json.".format(static_settings['settings_params_folder']+static_settings['settings_params_fname']) print "# Append 'configure_settings' to configure settings in the program before program start (must be consistently done on both the master device and slave device)." print "# Append 'reset_settings' to reset settings to default, as specified by the SettingsConfigured unit (must be done on both the master device and slave device)." print "#------------------------------------------------------#" answer = raw_input("# Would you like to see the settings information? [Y/n]: ") if answer.upper() == 'Y': preset_settings.PrintSettingsInfo(ask_user_for_settings_parameters=True)
def __init__(self, content): ''' Constructor ''' l = Settings() self.maillist = l.get_maillist() self.content = content
def __init__(self): cred = Settings('ES_CONN') host= cred['ip']+':'+str(cred['port']) userpass=cred['user']+':'+cred['pass'] self.es = Elasticsearch([host], http_auth=userpass) for index in self.es.indices.get('*'): print(index)
def test_settings_initialize_with_malformed_file(tmp_path): bad_yaml = "setting1:\n subsetting1: bad_yaml: should_be_quoted\n subsetting2: data2\nsetting2: data2\n" tmp_file = tmp_path / "settings.yml" tmp_file.write_text(bad_yaml) with pytest.raises(SettingsError) as e: Settings(tmp_file) assert "You have a malformed 'settings.yml' file" in str(e.value)
def test_settings_initialize_with_yaml_file(tmp_path): test_content = {'setting1': 'data1', 'setting2': 'data2'} test_yaml = yaml.dump(test_content) tmp_file = tmp_path / "settings.yml" tmp_file.write_text(test_yaml) s = Settings(tmp_file) print(dir(s)) assert hasattr(s, 'setting1') assert hasattr(s, 'setting2') assert s.setting1 == 'data1' assert s.setting2 == 'data2'
print "# Saved sessions may be simulated by typing 'simulate video' or 'simulate image' instead of 'master'/'slave', with video or image targets given by the settings configurations." print "# Program settings may be changed in detail by changing the settings configuration json file." print "# Program settings may be found at {0}.json.".format(static_settings['settings_params_folder']+static_settings['settings_params_fname']) print "# Append 'configure_settings' to configure settings in the program before program start (must be consistently done on both the master device and slave device)." print "# Append 'reset_settings' to reset settings to default, as specified by the SettingsConfigured unit (must be done on both the master device and slave device)." print "#------------------------------------------------------#" answer = raw_input("# Would you like to see the settings information? [Y/n]: ") if answer.upper() == 'Y': preset_settings.PrintSettingsInfo(ask_user_for_settings_parameters=True) if __name__ == "__main__": '''START PROGRAM''' if 'info' in sys.argv: PrintInfo() if 'reset_settings' in sys.argv: Settings(reset_settings=True, skip_checking_for_user_input_cmd_line=True, skip_checking_for_user_input=True) print '# Settings were reset to default values...' if 'configure_settings' in sys.argv: Settings(skip_checking_for_user_input_cmd_line=True, skip_checking_for_user_input=True).PrintSettingsInfo(configure_settings=True, ask_user_for_settings_parameters=True) if 'run' in sys.argv: calib_stereopsis = False calib_blobs = False if 'calibrate' in sys.argv: calib_stereopsis = True calib_blobs = True if 'calibrate_stereopsis' in sys.argv: calib_stereopsis = True if 'calibrate_blobs' in sys.argv: calib_blobs = True
''' Created on 2017年11月20日 @author: Administrator ''' import pymysql pymysql.install_as_MySQLdb() from Settings.Settings import Settings from Heartbeat.Server import Server from Heartbeat.Mysql import Mysql from Mysql.Slave import Slave if __name__ == '__main__': l = Settings() servers = l.get_servers() mysqls = l.get_mysqls() mysqlslaves = l.get_mysqlslaves() s = Server(servers) s.alive() m = Mysql(mysqls) m.alive() slave = Slave(mysqlslaves) slave.alive()
def test_settings_initialize_with_no_yaml_file(): Settings()