How to use _install_dep method in lisa

Best Python code snippet using lisa_python

fabfile.py

Source:fabfile.py Github

copy

Full Screen

...124 sudo('python flask-microblog/setup.py develop')125 sudo('pip install -r ~/flask-microblog/requirements.txt')126def sync_it():127 run_command_on_selected_server(_sync_it)128def _install_dep():129 sudo('apt-get -y install nginx')130 sudo('apt-get -y install supervisor')131 sudo('apt-get -y install gunicorn')132 sudo('apt-get -y install python-pip')133 sudo('apt-get update')134 sudo('apt-get -y install libpq-dev')135 sudo('apt-get -y install python-dev')136 sudo('apt-get -y install postgresql')137 sudo('apt-get -y upgrade gunicorn')138def install_dep():139 run_command_on_selected_server(_install_dep)140def _start_server():141 sudo('/etc/init.d/nginx stop')142 sudo('/etc/init.d/nginx start')...

Full Screen

Full Screen

hybrid-cg-main.py

Source:hybrid-cg-main.py Github

copy

Full Screen

...18 if diff_file:19 print('Applying patches...')20 subprocess.run(['git', 'apply', diff_file])21 22def _install_dep(module_name):23 print('Installing node dependencies for ' + module_name)24 subprocess.run(['npm', 'install'])25 26def _change_path(json_file, path_part):27 jf = json.load(open(json_file, 'r'))28 for node in jf['nodes']:29 node['pos'] = node['pos'].replace(path_part + '/', '') 30 json.dump(jf, open(json_file, 'w'), indent = 2)31 32def _run_dynamic(tools_dir, filter, node_cg, node_bin, cg_path, module_name, wd):33 print('Running npm test')34 my_env = os.environ.copy()35 my_env["PATH"] = node_cg + os.pathsep + my_env["PATH"]36 my_env["CALLCHAIN_INCLUDE"] = '|'.join(filter)37 subprocess.run(['npm', 'test'], env=my_env)38 subprocess.run([os.path.join(tools_dir, 'process-results.sh'), 'v8', '-cg', tools_dir, node_bin])39 if not os.path.exists(os.path.join(cg_path, "dyn-v8")):40 os.mkdir(os.path.join(cg_path, "dyn-v8"))41 shutil.move("full-trace.json.txt", os.path.join(cg_path, "dyn-v8", module_name + ".json"))42 _change_path(os.path.join(cg_path, "dyn-v8", module_name + ".json"), wd)43 44def _run_static(tools_dir, filter, cg_path, module_name, wd):45 def _run_with_strategy(strategy):46 print('Running ACG analysis with %s strategy' % strategy)47 with open(module_name + '.cgtxt', 'w') as cg_out:48 subprocess.run(['node', os.path.join(tools_dir, 'js-callgraph', 'js-callgraph.js'), '--cg', '--v8', '--strategy', strategy, '--baseDirToCut', wd, os.path.join(wd, filter[0])], stdout=cg_out)49 converter.convert_acg_js(os.path.join(wd, module_name))50 if not os.path.exists(os.path.join(cg_path, "acg-" + strategy)):51 os.mkdir(os.path.join(cg_path, "acg-" + strategy))52 shutil.move(module_name + ".json", os.path.join(cg_path, "acg-" + strategy, module_name + ".json")) 53 54 _run_with_strategy('ONESHOT')55 _run_with_strategy('DEMAND')56def _create_final_cg(cg_path):57 def _get_conf(foundBy):58 if 'dyn-v8' in foundBy:59 return 160 elif 'acg-demand' in foundBy and 'acg-oneshot' in foundBy:61 return 0.1962 elif 'acg-oneshot' in foundBy:63 return 0.2764 else:65 return 0.0366 for merged_cg in os.listdir(os.path.join(cg_path, 'x-compared')):67 mcg = json.load(open(os.path.join(cg_path, 'x-compared', merged_cg), 'r'))68 for node in mcg['nodes']:69 node.pop('foundBy', None)70 for link in mcg['links']:71 link['confidence'] = _get_conf(link['foundBy'])72 link.pop('foundBy', None)73 json.dump(mcg, open(os.path.join(cg_path, merged_cg), 'w'), indent = 2)74def main(skip_clone=False):75 wd = os.path.abspath(CONF['working-dir'])76 td = os.path.abspath(CONF['js-tools'])77 node_cg = os.path.dirname(os.path.join(td, 'node'))78 node_bin = os.path.abspath(CONF['node-orig'])79 cg_path = os.path.abspath(CONF['cg-path'])80 cwd = os.getcwd()81 diff_file = None82 for node_module in CONF['modules']:83 if not skip_clone:84 if node_module['patch']:85 diff_file = os.path.abspath(os.path.join(cwd, node_module['patch']))86 _clone(node_module['repo'], node_module['hash'], diff_file, wd)87 diff_file = None88 _install_dep(node_module['name'])89 else:90 os.chdir(os.path.join(wd, node_module['name']))91 _run_dynamic(td, node_module['filter'], node_cg, node_bin, cg_path, node_module['name'], wd)92 _run_static(td, node_module['filter'], cg_path, node_module['name'], wd)93 os.chdir(cwd)94 comparator.compare(filter_entry=True, filter_wrapper=True)95 _create_final_cg(cg_path)96 generator.generate_csv()97if __name__ == '__main__':...

Full Screen

Full Screen

system.py

Source:system.py Github

copy

Full Screen

...5@author: Nishad Mandlik6"""7import os8_SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))9def _install_dep(pkg_name):10 """11 Check is specified package is installed, and it not, install it via apt.12 Args:13 pkg_name (str): Name of the dependency to be checked.14 Returns:15 None.16 """17 if ("install ok installed" not in18 os.popen("dpkg -s " + pkg_name + " | grep Status").read()):19 os.system("sudo apt install " + pkg_name)20 else:21 print(pkg_name + " OK")22def _create_log_dir(logs_dir_path):23 """24 Create the specified directory to store logs, if not already present25 Args:26 logs_dir_path (str): Path of the directory to store logs.27 Returns:28 None.29 """30 os.system("mkdir -p \"" + logs_dir_path + "\"")31def get_iw_devs():32 """33 Get the available wireless devices.34 Returns:35 dict:36 A dictionary consisting of the phy IDs as the keys37 and the interface names as the values.38 """39 dev_strs = os.popen("iw dev").read().split("phy#")[1:]40 devs_dict = {}41 for dev_str in dev_strs:42 phy_id = dev_str[:dev_str.find("\n")]43 if_name = dev_str.split("Interface ")[1]44 if_name = if_name[:if_name.find("\n")]45 devs_dict[phy_id] = if_name46 return devs_dict47def _get_iw_modes():48 """49 Get the supported modes of operation for each wireless device.50 Returns:51 dict:52 A dictionary consisting of the phy IDs as the keys53 and a list of available modes as the values.54 """55 list_strs = os.popen("iw list").read().split("Wiphy phy")[1:]56 modes_dict = {}57 for list_str in list_strs:58 phy_id = list_str[:list_str.find("\n")]59 modes_str = list_str.split("Supported interface modes:")[1].lstrip()60 modes_list = []61 for line in modes_str.split("\n"):62 if ("*" in line):63 modes_list.append(line.split("* ")[1])64 else:65 break66 modes_dict[phy_id] = modes_list67 return modes_dict68def _get_monitor_compatible_ifs():69 """70 Return a list of wireless interfaces that support monitor mode.71 Returns:72 list:73 Names of interfaces which support monitor mode.74 """75 devs = get_iw_devs()76 modes = _get_iw_modes()77 monitor_if_names = []78 for dev in devs.items():79 if ("monitor" in modes[dev[0]]):80 monitor_if_names.append(dev[1])81 return monitor_if_names82def check(logs_dir_path=None):83 """84 Check if necessary dependencies are met, install missing packages and85 select an interface for sniffing.86 Args:87 logs_dir_path (str, optional): Path of the directory to store logs.88 If None, the default path (USER_HOME/pysniff_logs) is used.89 Defaults to None.90 Raises:91 RuntimeError: If no monitor-capable interface is found.92 Returns:93 tuple:94 Tuple containing name of the interface selected for sniffing and95 path of the logs directory. If a custom path is supplied to the96 function, the same path is returned. Otherwise,97 the default path is returned.98 """99 if logs_dir_path is None:100 logs_dir_path = os.path.join(os.path.expanduser("~"), "pysniff_logs")101 _install_dep("net-tools")102 _install_dep("wireless-tools")103 _install_dep("iw")104 monitor_if_names = _get_monitor_compatible_ifs()105 if (len(monitor_if_names) == 0):106 raise RuntimeError(107 "Wireless interface with monitor capability not found")108 else:109 print("Found interface(s) with monitor capbility. Selecting " +110 monitor_if_names[0])111 _install_dep("tshark")112 _create_log_dir(logs_dir_path)...

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