How to use set_config_value method in autotest

Best Python code snippet using autotest_python

prepare.py

Source:prepare.py Github

copy

Full Screen

...19 os.makedirs('/ut-data/System', exist_ok=True)20 os.makedirs('/ut-data/Textures', exist_ok=True)21 # Initialize ini with good default values22 ## Enable the web admin and set username/password23 set_config_value(utIniFileServer, 'UWeb.WebServer', 'bEnabled', 'True')24 set_config_value(utIniFileServer, 'UWeb.WebServer', 'ListenPort', '5580')25 set_config_value(utIniFileServer, 'UTServerAdmin.UTServerAdmin', 'AdminUsername', 'admin')26 set_config_value(utIniFileServer, 'UTServerAdmin.UTServerAdmin', 'AdminPassword', 'admin')27 ## Replace / Add Server information28 set_config_value(utIniFileServer, 'Engine.GameReplicationInfo', 'ServerName', 'My UT Server')29 set_config_value(utIniFileServer, 'Engine.GameReplicationInfo', 'AdminName', 'UTAdmin')30 set_config_value(utIniFileServer, 'Engine.GameReplicationInfo', 'AdminEmail', 'no@one.com')31 set_config_value(utIniFileServer, 'Engine.GameReplicationInfo', 'MOTDLine1', 'Have Fun')32 ## Replace / Add Admin and Game password33 set_config_value(utIniFileServer, 'Engine.GameInfo', 'AdminPassword', 'admin')34 set_config_value(utIniFileServer, 'Engine.GameInfo', 'GamePassword', '')35 ## Add some bots by default36 set_config_value(utIniFileServer, 'Botpack.DeathMatchPlus', 'MinPlayers', '4')37 # Add server visibility in server browser inside game by adding correct URLs38 ## URLs39 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerActors', 'IpServer.UdpServerUplink MasterServerAddress=utmaster.epicgames.com MasterServerPort=27900', True)40 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerActors', 'IpServer.UdpServerUplink MasterServerAddress=master.333networks.com MasterServerPort=27900', True)41 ## Replace / Add Master server connection information42 set_config_value(utIniFileServer, 'IpServer.UdpServerUplink', 'DoUpLink', 'True')43 # Add Mutators44 ## CustomCrossHairScale45 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'CCHS4', True)46 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerActors', 'CCHS4.CCHS', True)47 os.remove(f"/{utDataPath}/System/CCHS4.int")48 ## FlagAnnouncementsV249 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'FlagAnnouncementsV2', True)50 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'DefaultAnnouncements', True)51 ## KickIdlePlayers252 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'KickIdlePlayers2', True)53 ## MapVoteLAv254 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'MapVoteLAv2', True)55 ## WhoPushedMe56 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'EnhancedItems', True)57 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'WhoPushedMe', True)58 ## ZeroPingPlus10359 set_config_value(utIniFileServer, 'Engine.GameEngine', 'ServerPackages', 'ZeroPingPlus103', True)60 # Move and/or symlink the original ini files61 move_and_symlink(utIniFileServer, utIniFileData)62 # Fix some file cases (to prevent a warning)63 os.rename(f"/{utServerPath}/System/BotPack.u", f"/{utServerPath}/System/Botpack.u")64 os.rename(f"/{utServerPath}/Textures/UTcrypt.utx", f"/{utServerPath}/Textures/utcrypt.utx")65 os.rename(f"/{utServerPath}/Textures/GenFluid.utx", f"/{utServerPath}/Textures/genfluid.utx")66 os.rename(f"/{utServerPath}/Textures/Soldierskins.utx", f"/{utServerPath}/Textures/SoldierSkins.utx")67def prepare():68 # Remove all Symlinks69 for folder in folders:70 folderPath = os.path.join(utServerPath, folder)71 for entry in os.listdir(folderPath):72 fullFilePath = os.path.join(folderPath, entry)73 if os.path.islink(fullFilePath):74 if entry == "libSDL-1.2.so.0":75 continue76 print(f'[D] {os.path.join(folder, entry)}')77 os.remove(fullFilePath)78 # Add Symlinks79 for folder in folders:80 folderPath = os.path.join(utDataPath, folder)81 for entry in os.listdir(folderPath):82 fullFilePath = os.path.join(folderPath, entry)83 print(f'[L] {os.path.join(folder, entry)}')84 targetPath = os.path.join(utServerPath, folder, entry)85 os.symlink(fullFilePath, targetPath)86 # Update some config values according to optional environment variables87 ## Enable the web admin and set username/password88 set_config_to_environment('UT_WEBADMINUSER', utIniFileServer, 'UTServerAdmin.UTServerAdmin', 'AdminUsername')89 set_config_to_environment('UT_WEBADMINPWD', utIniFileServer, 'UTServerAdmin.UTServerAdmin', 'AdminPassword')90 ## Replace / Add Server information91 set_config_to_environment('UT_SERVERNAME', utIniFileServer, 'Engine.GameReplicationInfo', 'ServerName')92 set_config_to_environment('UT_ADMINNAME', utIniFileServer, 'Engine.GameReplicationInfo', 'AdminName')93 set_config_to_environment('UT_ADMINEMAIL', utIniFileServer, 'Engine.GameReplicationInfo', 'AdminEmail')94 set_config_to_environment('UT_MOTD1', utIniFileServer, 'Engine.GameReplicationInfo', 'MOTDLine1')95 ## Replace / Add Master server connection information96 set_config_to_environment('UT_DOUPLINK', utIniFileServer, 'IpServer.UdpServerUplink', 'DoUpLink')97 ## Replace / Add Admin and Game password98 set_config_to_environment('UT_ADMINPWD', utIniFileServer, 'Engine.GameInfo', 'AdminPassword')99 set_config_to_environment('UT_GAMEPWD', utIniFileServer, 'Engine.GameInfo', 'GamePassword')100def move_and_symlink(fileSrc, fileDest):101 os.rename(fileSrc, fileDest)102 symlink(fileDest, fileSrc)103def symlink(fileSrc, fileDest):104 os.symlink(fileSrc, fileDest)105def set_config_to_environment(environmentKey, filePath, section, key):106 if os.environ.get(environmentKey) is not None:107 set_config_value(filePath, section, key, os.environ.get(environmentKey))108def set_config_value(filePath, section, key, value, alwaysInsert=False):109 """110 This method replaces an exiting key with the value or adds a new one.111 Args:112 filePath (str) : The path to the file.113 section (str) : The desired section name.114 key (str) : The desired key.115 value (str) : The value to set.116 alwaysInsert (bool): A flag to indicate if the value should always be added or replaced if the key already exists.117 """118 # Read all lines of the file (including newlines)119 f = open(filePath, "r")120 contents = f.readlines()121 f.close()122 # Loop thru all existing lines...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...23def get_config_bool(name, fallback=False):24 """Checks if a config value is set to a valid bool value."""25 cli_config = CLIConfig(SF_CLI_CONFIG_DIR, SF_CLI_ENV_VAR_PREFIX)26 return cli_config.getboolean('servicefabric', name, fallback)27def set_config_value(name, value):28 """Set a config by name to a value."""29 cli_config = CLIConfig(SF_CLI_CONFIG_DIR, SF_CLI_ENV_VAR_PREFIX)30 cli_config.set_value('servicefabric', name, value)31def client_endpoint():32 """Cluster HTTP gateway endpoint address and port, represented as a URL."""33 return get_config_value('endpoint', None)34def security_type():35 """The selected security type of client."""36 return get_config_value('security', None)37def set_cluster_endpoint(endpoint):38 """Configure cluster endpoint"""39 set_config_value('endpoint', endpoint)40def no_verify_setting():41 """True to skip certificate SSL validation and verification"""42 return get_config_bool('no_verify')43def set_no_verify(no_verify):44 """Configure if cert verification should be skipped."""45 if no_verify:46 set_config_value('no_verify', 'true')47 else:48 set_config_value('no_verify', 'false')49def ca_cert_info():50 """CA certificate(s) path"""51 if get_config_bool('use_ca'):52 return get_config_value('ca_path', fallback=None)53 return None54def set_ca_cert(ca_path=None):55 """Configure paths to CA cert(s)."""56 if ca_path:57 set_config_value('ca_path', ca_path)58 set_config_value('use_ca', 'true')59 else:60 set_config_value('use_ca', 'false')61def cert_info():62 """Path to certificate related files, either a single file path or a63 tuple. In the case of no security, returns None."""64 sec_type = security_type()65 if sec_type == 'pem':66 return get_config_value('pem_path', fallback=None)67 if sec_type == 'cert':68 cert_path = get_config_value('cert_path', fallback=None)69 key_path = get_config_value('key_path', fallback=None)70 return cert_path, key_path71 return None72def aad_cache():73 """AAD token cache."""74 token_cache = TokenCache()75 token_cache.deserialize(get_config_value('aad_cache', fallback=None))76 return json.loads(get_config_value('aad_token', fallback=None)), token_cache77def set_aad_cache(token, cache):78 """79 Set AAD token cache.80 :param token: dict with several keys, include "accessToken" and "refreshToken"81 :param cache: adal.token_cache.TokenCache82 :return: None83 """84 set_config_value('aad_token', json.dumps(token))85 set_config_value('aad_cache', cache.serialize())86def aad_metadata():87 """AAD metadata."""88 return get_config_value('authority_uri', fallback=None), \89 get_config_value('aad_resource', fallback=None), \90 get_config_value('aad_client', fallback=None)91def set_aad_metadata(uri, resource, client):92 """Set AAD metadata."""93 set_config_value('authority_uri', uri)94 set_config_value('aad_resource', resource)95 set_config_value('aad_client', client)96def set_auth(pem=None, cert=None, key=None, aad=False):97 """Set certificate usage paths"""98 if any([cert, key]) and pem:99 raise ValueError('Cannot specify both pem and cert or key')100 if any([cert, key]) and not all([cert, key]):101 raise ValueError('Must specify both cert and key')102 if pem:103 set_config_value('security', 'pem')104 set_config_value('pem_path', pem)105 elif cert or key:106 set_config_value('security', 'cert')107 set_config_value('cert_path', cert)108 set_config_value('key_path', key)109 elif aad:110 set_config_value('security', 'aad')111 else:112 set_config_value('security', 'none')113def using_aad():114 """115 :return: True if security type is 'aad'. False otherwise116 """117 return security_type() == 'aad'118def get_cluster_auth():119 """120 Return the information that was added to config file by the function select cluster.121 :return: a dictionary with keys: endpoint, cert, key, pem, ca, aad, no_verify122 """123 cluster_auth = dict()124 cluster_auth['endpoint'] = client_endpoint()125 cluster_auth['cert'] = get_config_value('cert_path')126 cluster_auth['key'] = get_config_value('key_path')127 cluster_auth['pem'] = get_config_value('pem_path')128 cluster_auth['ca'] = ca_cert_info()129 cluster_auth['aad'] = using_aad()130 cluster_auth['no_verify'] = no_verify_setting()131 return cluster_auth132def set_telemetry_config(telemetry_on):133 """134 Sets whether or not telemetry is turned on in the configuration file.135 :param telemetry_on: bool. True means telemetry should be on.136 :return: None137 """138 if telemetry_on:139 set_config_value('use_telemetry', 'true')140 else:141 set_config_value('use_telemetry', 'false')142def get_telemetry_config():143 """144 Gets whether or not telemetry is turned on145 Returns True if no value is set.146 :return: bool. True if telemetry is on. False otherwise.147 """148 return get_config_bool('use_telemetry', fallback=True)149def get_cli_version_from_pkg():150 """151 Reads and returns the version number of sfctl. This is the version sfctl is released with.152 For example, 6.0.0.153 :return: str154 """155 from pkg_resources import get_distribution...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful