Best Python code snippet using localstack_python
nginx_util.py
Source:nginx_util.py
...38 ):39 mkdir_p(path)40 os.chmod(nua_nginx, 0o755) # noqa:S10341 # S103=Chmod setting a permissive mask 0o755 on file42 chown_r(nua_nginx, "nua", "nua")43 chown_r(nua_nginx / "www", "www-data", "www-data")44def install_nua_nginx_default_site():45 default = nua_env.nginx_path() / "sites" / "default"46 default_template = CONF_NGINX / "template" / "default_site"47 jinja2_render_file(default_template, default, nua_env.as_dict())48 os.chmod(default, 0o644)49def clean_nua_nginx_default_site():50 """warning: only for user 'nua' or 'root'"""51 nua_nginx = nua_env.nginx_path()52 sites = nua_nginx / "sites"53 rm_fr(sites)54 mkdir_p(sites)55 os.chmod(nua_nginx, 0o755) # noqa:S10356 install_nua_nginx_default_site()57def configure_nginx_domain(domain_dict):58 """warning: only for user 'nua' or 'root'"""59 nua_nginx = nua_env.nginx_path()60 if domain_dict["prefixed"]:61 template = CONF_NGINX / "template" / "domain_prefixed_template"62 else:63 template = CONF_NGINX / "template" / "domain_not_prefixed_template"64 dest_path = nua_nginx / "sites" / domain_dict["domain"]65 jinja2_render_file(template, dest_path, domain_dict)66 os.chmod(dest_path, 0o644)67def chown_r_nua_nginx():68 if not os.getuid():69 chown_r(nua_env.nginx_path(), "nua", "nua")70def install_nua_nginx_default_index_html():71 page = nua_env.nginx_path() / "www" / "html" / "index.html"72 page_src = CONF_NGINX / "html" / "index.html"73 jinja2_render_file(page_src, page, nua_env.as_dict())74 os.chmod(page, 0o644)75 chown_r(page, "www-data", "www-data")76def nginx_restart():77 # assuming some recent ubuntu distribution:78 cmd = "systemctl restart nginx"79 if os.geteuid() == 0:80 sh(cmd)81 else:...
hooks.py
Source:hooks.py
...24 if not os.path.exists(os.path.join(log_dir, 'info.log')):25 touch(os.path.join(log_dir, 'info.log'))26 if not os.path.exists(os.path.join(log_dir, 'exception.log')):27 touch(os.path.join(log_dir, 'exception.log'))28 chown_r(log_dir, 'www-data', 'www-data')...
data.py
Source:data.py
...15 if self.config is None:16 raise Exception("Config hasn't been loaded yet")17 if not os.path.exists(self.data_dir):18 os.mkdir(self.data_dir)19 chown_r(self.data_dir, 'www-data', 'www-data')20 def datadir_deployed(self):21 if os.path.exists(self.data_dir):22 chown_r(self.data_dir, 'www-data', 'www-data')23 @property24 def data_dir(self):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!