How to use set_config_path method in tempest

Best Python code snippet using tempest_python

ssh_config.py

Source:ssh_config.py Github

copy

Full Screen

...44 self.augeas.load()45 def config_path(self, *args):46 path = os.path.join("/files/", self.ssh_config, *args)47 return path48 def set_config_path(self, *args):49 LOG.debug("set_config_path({}) = '{}'".format(", ".join(args[:-1]), args[-1]))50 return self.augeas.set(self.config_path(*args[:-1]), args[-1])51 def set_defaults(self, configure_multiplex=False):52 defaults = dict(DEFAULT_CONFIG)53 if configure_multiplex:54 defaults.update(DEFAULT_MULTIPLEX)55 # Create multiplex directory56 multiplex_dir = os.path.join(self.ssh_dir, "multiplex")57 if not os.path.isdir(multiplex_dir):58 os.mkdir(multiplex_dir)59 os.chmod(multiplex_dir, 600)60 defaults["ControlPath"] = "{}/%r@%c:%p".format(multiplex_dir)61 host_key = "Host[.='*']"62 if not self.augeas.match(self.config_path("Host", "*")):63 self.set_config_path(host_key, "*")64 for key, value in defaults.items():65 if not self.augeas.get(self.config_path(host_key, key)):66 LOG.info("[default] {} {}".format(key, value))67 self.set_config_path(host_key, key, value)68 def set_host_field(self, host_alias, field, value):69 host_key = "Host[.='{}']".format(host_alias)70 if not self.augeas.get(self.config_path("Host", host_alias)):71 self.set_config_path(host_key, host_alias)72 self.set_config_path(host_key, field, value)73 def define_host(74 self,75 user,76 host_alias,77 host_name,78 key_file,79 proxy_command,80 port,81 jump_host=None,82 **kwargs,83 ):84 if not os.path.isfile(key_file):85 raise ValueError("'{}' is not a valid file".format(key_file))86 # chmod file to correct rights...

Full Screen

Full Screen

checker.py

Source:checker.py Github

copy

Full Screen

1"""2run inference and show UI3multiprocessing4"""56import time7import os8import sys9from pathlib import Path10from multiprocessing import Process, Queue, Value, Array11import yaml12import traceback1314FILE = Path(__file__).resolve()15ROOT = FILE.parents[0] # YOLOv5 root directory16if str(ROOT) not in sys.path:17 sys.path.append(str(ROOT)) # add ROOT to PATH18ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative1920def inference_thread(q, config_path, set_config_path, class_path, set_class_path, tmp_vars):21 from main.run_inference import Inference_app2223 try:24 p = Inference_app(q, config_path, set_config_path, set_class_path, **tmp_vars)2526 # モデル、データセットのロード27 p.load_model_data()2829 # モデルのクラスを更新30 with open(class_path, 'r') as yml:31 class_data = yaml.load(yml, Loader=yaml.SafeLoader)32 class_data["all_names"] = p.names33 with open(class_path, mode='w') as yml:34 yaml.dump(class_data, yml, default_flow_style=False, sort_keys=False, allow_unicode=True)3536 # フラグ管理37 tmp_vars["finish_load"].value = 138 while not tmp_vars["push_inference"].value:39 if tmp_vars["close_flg"].value==1:40 return41 time.sleep(1)4243 # 推論44 p.run()4546 except Exception:47 print(traceback.format_exc())48 sys.exit()4950def tkapp_thread(q, set_config_path, class_path, set_class_path, sound_path, tmp_vars):51 import tkinter as tk52 import pygame53 from main.show_app import Tk_app5455 try:56 root_tk = tk.Tk()5758 # 音出すライブラリ初期化59 pygame.init()60 pygame.mixer.init()6162 app = Tk_app(root_tk, q, set_config_path, class_path, set_class_path, sound_path, **tmp_vars) # Inherit63 app.mainloop()6465 except Exception:66 print(traceback.format_exc())67 sys.exit()686970class CheckerMain():71 def __init__(self,72 config_path=ROOT / "main" / "config.yaml",73 set_config_path=ROOT / "main" / "set_config.yaml",74 class_path=ROOT / "main" / "class.yaml",75 set_class_path=ROOT / "main" / "set_class.yaml",76 sound_path=ROOT / "utils" / "Buzzer"):77 self.config_path = config_path78 self.set_config_path = set_config_path79 self.class_path = class_path80 self.set_class_path = set_class_path81 self.sound_path = sound_path82 pass83 def main(self):84 # 共有メモリ85 push_inference = Value('i', 0) # 推論ボタン押打フラグ86 finish_load = Value('i', 0) # モデルのロード完了フラグ87 close_flg = Value('i', 0) # UI終了ボタン押打フラグ88 show_results = Value('i', 0) # 結果表示中フラグ8990 tmp_vars = vars().copy()91 del tmp_vars["self"]9293 q = Queue()94 # UI95 p_tkapp = Process(target = tkapp_thread, args=(q, self.set_config_path, self.class_path,96 self.set_class_path, self.sound_path, tmp_vars))97 # 推論98 p_inference = Process(target = inference_thread, args=(q, self.config_path, self.set_config_path,99 self.class_path, self.set_class_path, tmp_vars))100 p_tkapp.start()101 p_inference.start()102 # どちらかが停止したら両方終了103 while p_tkapp.is_alive():104 if not p_inference.is_alive():105 p_tkapp.terminate()106 break107 time.sleep(1)108 p_tkapp.join()109 # p_tkapp終了したら推論も停止110 p_inference.terminate()111 p_inference.join()112113def main():114 process = CheckerMain()115 process.main()116117if __name__ == "__main__": ...

Full Screen

Full Screen

test_config.py

Source:test_config.py Github

copy

Full Screen

...36 reset()37 yield38 reset()39 def test_config_port(self):40 set_config_path(config_path=PORT_YAML)41 TestConfig._validate_port_config(config())42 TestConfig._validate_port_config(config())43 @patch.dict(os.environ, {"HOME": "/home/whatever"}, clear=True)44 def test_config_socket(self):45 set_config_path(config_path=SOCKET_YAML)46 TestConfig._validate_socket_config(config())47 TestConfig._validate_socket_config(config())48 def test_config_unset(self):49 set_config_path(config_path=None)50 with pytest.raises(ClickException, match="^Internal error: no config path set"):51 config()52 def test_config_not_found(self, tmpdir):53 set_config_path(config_path=tmpdir.join("bogus.yaml"))54 with pytest.raises(UsageError, match="^.*Client configuration is not readable.*"):55 config()56 @patch.dict(os.environ, {"HOME": "/home/whatever"}, clear=True)57 def test_api_url(self):58 set_config_path(config_path=SOCKET_YAML)59 config()60 assert api_url() == config().api_url()61 @staticmethod62 def _validate_port_config(result):63 assert result.mode == ConnectionMode.PORT64 assert result.api_endpoint == "http://localhost:8080"65 assert result.api_socket is None66 assert result.api_url() == "http://localhost:8080"67 @staticmethod68 def _validate_socket_config(result):69 assert result.mode == ConnectionMode.SOCKET70 assert result.api_endpoint is None71 assert result.api_socket == "/home/whatever/.config/vplan/server/run/engine.sock"72 assert result.api_url() == "http+unix://%2Fhome%2Fwhatever%2F.config%2Fvplan%2Fserver%2Frun%2Fengine.sock"

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 tempest 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