How to use install_path method in molecule

Best Python code snippet using molecule_python

pvw-setup

Source:pvw-setup Github

copy

Full Screen

1#!/usr/bin/python2import urllib2, sys, os, zipfile, subprocess, json, shutil3# ===================================================================4# ParaView files / URLs5# ===================================================================6url = "http://paraview.org/files/v4.1/"7application = {8 'osx' : "ParaView-4.1.0-Darwin-64bit-Lion-Python27.dmg",9 'linux32': "ParaView-4.1.0-Linux-32bit-glibc-2.3.6.tar.gz",10 'linux64': "ParaView-4.1.0-Linux-64bit-glibc-2.3.6.tar.gz",11 'win32' : "ParaView-4.1.0-Windows-32bit.zip",12 'win64' : "ParaView-4.1.0-Windows-64bit.zip"13 }14data = "ParaViewData-v4.1.zip"15documentation = "ParaView-API-docs-v4.1.zip"16# ===================================================================17# Download helper18# ===================================================================19def download(url, file_name):20 u = urllib2.urlopen(url)21 f = open(file_name, 'wb')22 meta = u.info()23 file_size = int(meta.getheaders("Content-Length")[0])24 print "\nDownloading: %s Bytes: %s" % (file_name, file_size)25 file_size_dl = 026 block_sz = 819227 while True:28 buffer = u.read(block_sz)29 if not buffer:30 break31 file_size_dl += len(buffer)32 f.write(buffer)33 status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)34 status = status + chr(8)*(len(status)+1)35 print status,36 f.close()37# ===================================================================38def unzip(file, destination):39 zfile = zipfile.ZipFile(file)40 for name in zfile.namelist():41 fullPath = os.path.join(destination, name)42 if name.endswith('/'):43 os.makedirs(fullPath)44 else:45 if not os.path.exists(os.path.dirname(fullPath)):46 os.makedirs(os.path.dirname(fullPath))47 fd = open(fullPath,"w")48 fd.write(zfile.read(name))49 fd.close()50 status = r" Unzip "51 if len(name) > 70:52 status += "[..]" + name[-70:]53 else:54 status += name55 status += " "*(80-len(status))56 status = status + chr(8)*(len(status)+1)57 print status,58 print59# ===================================================================60# Get data locally61# ===================================================================62print63install_path = os.getcwd()64q = ''65while q != 'y' and q != 'yes':66 if q == 'n' or q == 'no':67 install_path = raw_input("Enter ParaViewWeb install path: ")68 if q == 'q' or q == 'quit':69 sys.exit("We did nothing")70 q = raw_input("Is ParaViewWeb install path correct? (%s) yes/no/quit: " % install_path)71print "\nInstalling ParaViewWeb inside:", install_path72if not os.path.exists(install_path):73 os.makedirs(install_path)74download_path = os.path.join(install_path, "download")75if not os.path.exists(download_path):76 os.makedirs(download_path)77# Download data + doc78data_file = os.path.join(download_path, data)79documentation_file = os.path.join(download_path, documentation)80if not os.path.exists(data_file):81 download(url + data, data_file)82if not os.path.exists(documentation_file):83 download(url + documentation, documentation_file)84# Download only for all OS for future setup85app_type = raw_input("\nWhich system? [osx, linux32, linux64, win32, win64, all]: ")86if app_type == 'all':87 print "\nThis will only download all OS files for future install."88 for app_type in application:89 app_file = os.path.join(download_path, application[app_type])90 if not os.path.exists(app_file):91 download(url + application[app_type], app_file)92 sys.exit("Downloading done")93else:94 # Check files and download them if needed95 app_file = os.path.join(download_path, application[app_type])96 if not os.path.exists(app_file):97 download(url + application[app_type], app_file)98print99# ===================================================================100# Unpack data101# ===================================================================102if app_type == 'osx':103 if not os.path.exists(os.path.join(install_path, 'paraview.app')):104 print " => Unpack ParaView"105 # Mount DMG106 retvalue = subprocess.check_output(['hdiutil', 'attach', app_file])107 list = retvalue.split()108 dir_path = list[-1]109 dmg_mount = list[-3]110 # Copy application111 os.system("cp -r %s/paraview.app %s/paraview.app" % (dir_path, install_path))112 # Unmount dmg113 subprocess.check_output(["hdiutil", "detach", dmg_mount])114elif not os.path.exists(os.path.join(install_path, 'paraview')):115 print " => Unpack ParaView"116 if app_type == 'linux32':117 os.system("cd %s;tar xvzf %s" % (install_path, app_file))118 os.rename(os.path.join(install_path, "ParaView-4.1.0-Linux-32bit"), os.path.join(install_path, "paraview"))119 elif app_type == 'linux64':120 os.system("cd %s;tar xvzf %s" % (install_path, app_file))121 os.rename(os.path.join(install_path, "ParaView-4.1.0-Linux-64bit"), os.path.join(install_path, "paraview"))122 else:123 # Unzip app124 unzip(app_file, install_path)125 if app_type == 'win64':126 os.rename(os.path.join(install_path, "ParaView-4.1.0-Windows-64bit"), os.path.join(install_path, "paraview"))127 if app_type == 'win32':128 os.rename(os.path.join(install_path, "ParaView-4.1.0-Windows-32bit"), os.path.join(install_path, "paraview"))129# ===================================================================130# Structure directories131# ===================================================================132# /data133if not os.path.exists(os.path.join(install_path, 'data')):134 print " => Unpack data"135 unzip(data_file, install_path)136 src = os.path.join(install_path, data[:-4], "Data")137 dst = os.path.join(install_path, 'data')138 os.rename(src, dst)139 shutil.rmtree(os.path.join(install_path, data[:-4]))140# /www141if not os.path.exists(os.path.join(install_path, 'www')):142 print " => Unpack Web"143 unzip(documentation_file, install_path)144 src = os.path.join(install_path, documentation[:-4], 'js-doc')145 dst = os.path.join(install_path, 'www')146 os.rename(src, dst)147 src = os.path.join(install_path, documentation[:-4], 'lib')148 dst = os.path.join(install_path, 'www/lib')149 os.rename(src, dst)150 src = os.path.join(install_path, documentation[:-4], 'ext')151 dst = os.path.join(install_path, 'www/ext')152 os.rename(src, dst)153 src = os.path.join(install_path, documentation[:-4], 'apps')154 dst = os.path.join(install_path, 'www/apps')155 os.rename(src, dst)156 print " => Clean web directory"157 shutil.rmtree(os.path.join(install_path, documentation[:-4]))158# /bin159if not os.path.exists(os.path.join(install_path, 'bin')):160 os.makedirs(os.path.join(install_path, 'bin'))161# /conf162if not os.path.exists(os.path.join(install_path, 'conf')):163 os.makedirs(os.path.join(install_path, 'conf'))164# /logs165if not os.path.exists(os.path.join(install_path, 'logs')):166 os.makedirs(os.path.join(install_path, 'logs'))167# ===================================================================168# Configure169# ===================================================================170print " => Configure local instance"171python_exec = ''172base_python_path = ''173if app_type == 'osx':174 python_exec = os.path.join(install_path, 'paraview.app/Contents/bin/pvpython')175 base_python_path = os.path.join(install_path, 'paraview.app/Contents/Python/')176elif app_type == 'linux32' or app_type == 'linux64':177 python_exec = os.path.join(install_path, 'paraview/bin/pvpython')178 base_python_path = os.path.join(install_path, 'paraview/lib/paraview-4.1/site-packages/')179elif app_type == 'win32' or app_type == 'win64':180 python_exec = os.path.join(install_path, 'paraview/bin/pvpython.exe')181 base_python_path = os.path.join(install_path, 'paraview/lib/paraview-4.1/site-packages/')182default_launcher_config = {183 "sessionData" : {184 "updir": "/Home"185 },186 "resources" : [ { "host" : "localhost", "port_range" : [9001, 9003] } ],187 "properties" : {188 "python_exec": python_exec,189 "python_path": base_python_path,190 "data": os.path.join(install_path, 'data'),191 },192 "configuration": {193 "host": "localhost",194 "port": 8080,195 "endpoint": "paraview",196 "content": os.path.join(install_path, 'www'),197 "proxy_file": os.path.join(install_path, 'conf/proxy.conf'),198 "sessionURL" : "ws://${host}:${port}/ws",199 "timeout" : 5,200 "log_dir" : os.path.join(install_path, 'logs'),201 "upload_dir" : os.path.join(install_path, 'data'),202 "fields" : ["file", "host", "port", "updir"]203 },204 "apps": {205 "pipeline": {206 "cmd": ["${python_exec}", "${python_path}/paraview/web/pv_web_visualizer.py", "--port", "${port}", "--data-dir", "${data}" ]207 },208 "loader": {209 "cmd": ["${python_exec}", "${python_path}/paraview/web/pv_web_file_loader.py", "--port", "${port}", "--data-dir", "${data}"]210 },211 "data_prober": {212 "cmd": ["${python_exec}", "${python_path}/paraview/web/pv_web_data_prober.py", "--port", "${port}", "--data-dir", "${data}"]213 }214 }215}216with open(os.path.join(install_path, 'conf/launch.json'), "w") as config_file:217 config_file.write(json.dumps(default_launcher_config))218web_exec = ''219if app_type.startswith('win'):220 web_exec = os.path.join(install_path, 'bin/start.bat')221 with open(web_exec, "w") as run_file:222 run_file.write("%s %s %s" % (python_exec, os.path.join(base_python_path, 'vtk/web/launcher.py'), os.path.join(install_path, 'conf/launch.json')))223else:224 web_exec = os.path.join(install_path, 'bin/start.sh')225 with open(web_exec, "w") as run_file:226 run_file.write("%s %s %s" % (python_exec, os.path.join(base_python_path, 'vtk/web/launcher.py'), os.path.join(install_path, 'conf/launch.json')))227 os.chmod(web_exec, 0750)228# ===================================================================229# Enable ParaViewWeb application inside index.html230# ===================================================================231index_html = os.path.join(install_path,"www/index.html")232index_origin = os.path.join(install_path,"www/index.origin")233os.rename(index_html, index_origin)234with open(index_origin, "r") as fr:235 with open(index_html, "w") as fw:236 for line in fr:237 if not "DEMO-APPS" in line:238 fw.write(line)239# ===================================================================240# Print help241# ===================================================================242print243print "To start ParaViewWeb web server just run:"244print " "*5, web_exec245print246print "And go in your Web browser (Safari, Chrome, Firefox) to:"247print " "*5, "http://localhost:8080/"248print...

Full Screen

Full Screen

get_auto_backup.py

Source:get_auto_backup.py Github

copy

Full Screen

1# linux: curl https://raw.githubusercontent.com/CrazyVideoGamer/auto-backup/main/get_auto_backup.py | python3 <-- not yet tested2# windows cmd: curl https://raw.githubusercontent.com/CrazyVideoGamer/auto-backup/main/get_auto_backup.py | python <-- not yet tested 3from pathlib import Path4import argparse5import sys, platform, subprocess6def does_git_exist():7 system = platform.system()8 if system == "Linux":9 log = subprocess.run("command -v git >/dev/null 2>&1 || { echo 'error: git not found' >&2;}", shell=True)10 if log.stdout == b'error: git not found':11 return False12 return True13 elif system == "Windows":14 log = subprocess.run("where git >nul 2>&1 || ( echo error: git not found )", shell=True)15 if log.stdout == b'error: git not found':16 return False17 return True18def error_message(message: str) -> None:19 # \u001b[31m makes it red, \u001b[0m makes the color reset20 system = platform.system()21 if system == "Windows":22 subprocess.run("color", shell=True) 23 print("\u001b[31;1m" + message + "\u001b[0m", file=sys.stderr)24 sys.exit(0)25def create_parser() -> argparse.ArgumentParser:26 parser = argparse.ArgumentParser(description="Install or uninstall auto-backup")27 parser.add_argument("--uninstall", action='store_true')28 return parser29args = create_parser().parse_args()30system = platform.system()31if system == "Linux":32 install_path = Path.home() / ".auto-backup"33 34 if not args.uninstall:35 if (install_path.exists() and (install_path / '.is-auto-backup').exists()):36 error_message("Already installed auto-backup")37 elif (install_path.exists() and not (install_path / '.is-auto-backup').exists()):38 error_message("Could not create the ~/.auto-backup directory: directory already exists")39 else: # this else statement only runs if ~/.auto-backup doesn't exist40 install_path.mkdir(exist_ok=True)41 (install_path / ".is-auto-backup").touch()42 # add this git repository (and also leave out the .git directory and name it `backup`)43 if does_git_exist():44 if not (install_path / "backup").exists():45 print("Installing auto-backup...")46 subprocess.run("git clone --quiet --depth=1 --branch=main https://github.com/CrazyVideoGamer/auto-backup.git backup", cwd=install_path, shell=True)47 subprocess.run("rm -rf ./backup/.git", cwd=install_path, shell=True)48 subprocess.run("pip install -r requirements.txt -t lib2 > /dev/null 2>&1", cwd=(install_path / "backup"), shell=True)49 print("Done!\n")50 else:51 error_message("Please install git using `sudo apt install git`")52 print(f"add `export PATH={str(install_path / 'auto-backup' / 'backup' / 'bin')}:$PATH` to ~/.bashrc to complete the installation")53 else:54 if (not install_path.exists() or (install_path.exists() and not (install_path / '.is-auto-backup').exists())):55 error_message("auto-backup is not installed")56 print("Uninstalling auto-backup...")57 subprocess.run(f"rm -r {str(install_path)}", shell=True)58 print("Done!")59elif system == "Windows":60 install_path = Path.home() / "auto-backup"61 if not args.uninstall:62 if (install_path.exists() and (install_path / 'is-auto-backup').exists()):63 error_message("Already installed auto-backup")64 elif (install_path.exists() and not (install_path / 'is-auto-backup').exists()):65 error_message(f"Could not create the {str(install_path)} directory: directory already exists")66 else:67 install_path.mkdir(exist_ok=True)68 (install_path / "is-auto-backup").touch() # note that it is "is-auto-backup", not ".is-auto-backup"69 # add this git repository (and also leave out the .git directory and name it `backup`)70 if does_git_exist():71 if not (install_path / "backup").exists():72 print("Installing auto-backup...")73 subprocess.run("git clone --quiet --depth=1 --branch=main https://github.com/CrazyVideoGamer/auto-backup.git backup", cwd=install_path, shell=True)74 subprocess.run("rd /s /q \"backup/.git\"", cwd=install_path, shell=True)75 subprocess.run("pip install -r requirements.txt -t lib > nul 2>&1", cwd=(install_path / "backup"), shell=True)76 77 print("Done!\n")78 else:79 error_message("Please install git first (go to https://git-scm.com/) ")80 print(f"add {str(install_path / 'auto-backup' / 'backup' / 'bin')} to PATH to complete the installation")81 else:82 if (not install_path.exists() or (install_path.exists() and not (install_path / 'is-auto-backup').exists())):83 error_message("auto-backup is not installed")84 print("Uninstalling auto-backup...")85 subprocess.run(f"rd /s /q {str(install_path)}", shell=True)86 print("Done!")87else:...

Full Screen

Full Screen

installation.smk

Source:installation.smk Github

copy

Full Screen

1rule install_augustus:2 output:3 os.path.join(INSTALL_PATH, 'augustus/bin/augustus'),4 directory(os.path.join(INSTALL_PATH, 'augustus/config')),5 params:6 git_commit= 'd1fd097',7 INSTALL_PATH= INSTALL_PATH,8 shell:9 r"""10 rm -rf Augustus11 git clone https://github.com/Gaius-Augustus/Augustus.git12 cd Augustus13 git checkout {params.git_commit}14 git checkout common.mk # Reset to original before editing it15 > common.tmp16 echo "17 INCLUDE_PATH_ZLIB := -I{params.INSTALL_PATH}/include18 INCLUDE_PATH_BOOST := -I{params.INSTALL_PATH}/include19 INCLUDE_PATH_LPSOLVE := -I{params.INSTALL_PATH}/include/lpsolve20 INCLUDE_PATH_SUITESPARSE := -I{params.INSTALL_PATH}/include/suitesparse/21 INCLUDE_PATH_GSL := -I{params.INSTALL_PATH}/include22 INCLUDE_PATH_SQLITE := -I{params.INSTALL_PATH}/include23 INCLUDE_PATH_BAMTOOLS := -I{params.INSTALL_PATH}/include/bamtools24 INCLUDE_PATH_HTSLIB := -I{params.INSTALL_PATH}/include/htslib25 INCLUDE_PATH_SEQLIB := -I {params.INSTALL_PATH}/include/SeqLib -I{params.INSTALL_PATH}/include/htslib -I{params.INSTALL_PATH}/include/jsoncpp26 LIBRARY_PATH_LPSOLVE := -L{params.INSTALL_PATH}/lib/lp_solve/ -Wl,-rpath,{params.INSTALL_PATH}/lib/lp_solve/27 LIBRARY_PATH_ZLIB := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib28 LIBRARY_PATH_BOOST := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib29 LIBRARY_PATH_SUITESPARSE := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib30 LIBRARY_PATH_GSL := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib31 LIBRARY_PATH_SQLITE := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib32 LIBRARY_PATH_BAMTOOLS := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib33 LIBRARY_PATH_HTSLIB := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib34 LIBRARY_PATH_SEQLIB := -L{params.INSTALL_PATH}/lib -Wl,-rpath,{params.INSTALL_PATH}/lib35 " >> common.tmp36 cat common.mk >> common.tmp37 mv common.tmp common.mk38 make -j 8 MYSQL=false augustus auxprogs39 mkdir -p {params.INSTALL_PATH}/augustus/bin40 mv bin/* {params.INSTALL_PATH}/augustus/bin/41 cp -r scripts/* {params.INSTALL_PATH}/augustus/bin/42 cp -r config {params.INSTALL_PATH}/augustus/43 # Some basic tests:44 {params.INSTALL_PATH}/augustus/bin/augustus --version45 {params.INSTALL_PATH}/augustus/bin/autoAug.pl --help46 """47rule install_braker:48 # Braker is on bioconda but it may be outdated so we install it ourselves49 output:50 os.path.join(INSTALL_PATH, 'bin/braker.pl'),51 params:52 git_commit= '1af9bdc',53 INSTALL_PATH= INSTALL_PATH,54 shell:55 r"""56 rm -rf BRAKER57 git clone https://github.com/Gaius-Augustus/BRAKER58 cd BRAKER59 git checkout {params.git_commit}60 chmod +x scripts/*.pl scripts/*.py61 cp scripts/*.pl {params.INSTALL_PATH}/bin/62 cp scripts/*.pm {params.INSTALL_PATH}/bin/63 cp scripts/*.py {params.INSTALL_PATH}/bin/64 cp -r scripts/cfg/ {params.INSTALL_PATH}/bin/65 rm -rf BRAKER66 braker.pl --help > /dev/null67 """68rule install_genemark:69 input:70 gm= config['genemark_tar_gz'],71 output:72 touch('genemark_installation.done'),73 params:74 gmpath= GENEMARK_PATH,75 shell:76 r"""77 gm=`basename {input.gm} .tar.gz`78 rm -rf {params.gmpath}79 cp {input.gm} ${{gm}}.tar.gz80 tar zxf ${{gm}}.tar.gz81 mv ${{gm}} {params.gmpath} 82 rm -rf ${{gm}}.tar.gz83 cd {params.gmpath}84 # Copy key if necessary. We assume the key in the tar archive is valid 85 if [ -f ~/.gm_key ]86 then87 my5=`md5sum ~/.gm_key | cut -d ' ' -f 1`88 else89 my5='notfound'90 fi91 this5=`md5sum gm_key | cut -d ' ' -f 1`92 if [ "$my5" != "$this5" ]93 then94 cp gm_key ~/.gm_key95 fi96 # Use perl on PATH97 perl change_path_in_perl_scripts.pl '/usr/bin/env perl'98 99 # Test installation100 ./check_install.bash...

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