How to use working_path method in lisa

Best Python code snippet using lisa_python

edoc_downloader.py

Source:edoc_downloader.py Github

copy

Full Screen

1import urllib.request2import requests3from bs4 import BeautifulSoup4from ftplib import FTP5import pdfkit6import datetime7import os8import shutil9def download_file(branch, doc_types, file_num, save_path):10 server = 'http://edoc.' + branch + '.ei:8018/edoc/'11 url = 'main?object=folder&key=' + file_num + ",CONSOL&method=read"12 content = requests.get(server + url).text13 soup = BeautifulSoup(content, 'html.parser')14 links = soup.find_all('a')15 # assert isinstance(links, object)16 for l in links:17 link = l.get('href')18 text = l.text19 file_type_text = l.find_all('img')[0].attrs['src']20 # download docs21 for doc in doc_types:22 if text.find(doc) > 0:23 if file_type_text == "images/document.gif":24 file_type = '.tif'25 else:26 file_type = '.pdf'27 urllib.request.urlretrieve(server + link, save_path + '\\' + file_num + file_type)28 # urllib.request.urlretrieve(server + link,29 # filename=working_path + '\\' + vat_number + file_type)30 else:31 pass32def get_file_link(branch, file_num):33 server = 'http://edoc.' + branch + '.ei:8018/edoc/'34 url = 'main?object=folder&key=' + file_num + ",CONSOL&method=read"35 content = requests.get(server + url).text36 soup = BeautifulSoup(content, 'html.parser')37 link = soup.find_all('a')[0]38 link = link.get('href')39 file_link = (server + link).lower()40 return file_link41def ftp_connect(branch):42 ftp_server = 'edoc.' + branch + '.ei'43 username = 'edocftp'44 password = 'capture2'45 ftp = FTP()46 ftp.set_debuglevel(0) # 打开调试级别2,显示详细信息47 ftp.connect(ftp_server, 21) # 连接48 ftp.login(username, password) # 登录,如果匿名登录则用空串代替即可49 return ftp50def convert_pdf(working_path, invoices_ref, hbls, gci):51 options = {52 'page-size': 'A4',53 'margin-top': '0.75in',54 'margin-right': '0.75in',55 'margin-bottom': '0.75in',56 'margin-left': '0.75in',57 'encoding': "UTF-8", # 支持中文58 'custom-header': [59 ('Accept-Encoding', 'gzip')60 ],61 'no-outline': None62 }63 for split_hbl in hbls:64 pdfkit.from_file(working_path + '\\' + invoices_ref + '.html', working_path + '\\' + split_hbl + '.pdf',65 options=options)66 # Rename 2380294268_PIE_20200323042544411_G2232818.pdf.tsk67 dt = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')68 print(dt)69 os.rename(working_path + '\\' + split_hbl + '.pdf',70 working_path + '\\' + split_hbl + '_PIE_' + str(dt) + '_' + gci + '.pdf.tsk')71 # Delete files and folders72 os.remove(working_path + '\\' + invoices_ref + '.html')73 shutil.rmtree(working_path + '\\' + invoices_ref + '_files')74def edoc_upload(branch, working_path):75 ftp = ftp_connect(branch)76 remotepath = "/prod/app/edoc/edocworkers/current/work/images/inbox"77 bufsize = 102478 files = [fn for root, dirs, files in os.walk(working_path) for fn in files]79 for file in files:80 fp = open(working_path + '\\' + file, 'rb')81 ftp.storbinary('STOR ' + remotepath + '/' + file, fp, bufsize) # 上传文件82 fp.close() # 关闭文件83 os.remove(working_path + '\\' + file)84 ftp.quit()85if __name__ == '__main__':86 la = get_file_link('tsn', 'T200005490')...

Full Screen

Full Screen

coco.py

Source:coco.py Github

copy

Full Screen

1import traceback2import sys3import os4import subprocess5import util as ut6import tokenizer as tkr7import symbol_table as st8import type_check as tc9import parser_coco as pc10import imcg as im11import generate_py as gp12import parse_tree as pt13def main():14 conf = ut.get_config()15 if conf["env"] == "testing":16 # Only For Testing Puropses17 ut.check_verbosity(f"{ut.bcolors.BOLD}{ut.bcolors.CITALIC}{ut.bcolors.UNDERLINE}{ut.bcolors.CBLINK}*************** Running in Test Environment ***************\n{ut.bcolors.ENDC}")18 test_path = ut.get_test_log_path()19 working_path = os.path.join(os.getcwd(), "test.txt")20 tkz = tkr.Tokenize(working_path, test_path).get_tk()21 pc.Parse(tkz)22 if ut.get_config()["generate_parse_tree"] == 1: pt.ParseTree("test.txt", ut.get_test_log_path())23 st.SymbolTable(working_path, test_path)24 tc.TypeCheck(working_path)25 im.IntermediateCode(working_path, test_path)26 gpp = gp.GeneratePy(os.path.join(test_path, "imc.txt"), test_path).get_path()27 if conf["execute"] == 1:28 ut.check_verbosity(f"{ut.bcolors.BOLD}--- Code Execution ---{ut.bcolors.ENDC}")29 ut.check_verbosity(f"{ut.bcolors.OKBLUE}\t* Executing Code from: {gpp}{ut.bcolors.ENDC}")30 ut.check_verbosity(f"{ut.bcolors.CYELLOW}\t - {gpp}{ut.bcolors.ENDC}")31 subprocess.call(["python", gpp])32 else:33 if len(sys.argv) == 1:34 raise Exception("Expected 1 argument but found 0! Please provide file path.")35 ut.check_verbosity(f"{ut.bcolors.BOLD}{ut.bcolors.CITALIC}{ut.bcolors.UNDERLINE}{ut.bcolors.CBLINK}*************** Running in Production ***************\n{ut.bcolors.ENDC}")36 log_path = ut.logger_dir()37 working_path = os.path.join(os.getcwd(), sys.argv[1])38 tkz = tkr.Tokenize(working_path, log_path).get_tk()39 pc.Parse(tkz)40 if ut.get_config()["generate_parse_tree"] == 1: pt.ParseTree(working_path, log_path)41 stt = st.SymbolTable(working_path, log_path).get_st()42 tc.TypeCheck(working_path)43 imc = im.IntermediateCode(working_path, log_path).get_imc_path()44 gpp = gp.GeneratePy(os.path.join(log_path, "imc.txt"), log_path).get_path()45 if conf["execute"] == 1:46 ut.check_verbosity(f"{ut.bcolors.BOLD}--- Code Execution ---{ut.bcolors.ENDC}")47 ut.check_verbosity(f"{ut.bcolors.OKBLUE}\t* Executing Code from: {gpp}{ut.bcolors.ENDC}")48 subprocess.call(["python", gpp])49if __name__ == "__main__":50 try:51 main()52 except Exception as e:53 print(f"{ut.bcolors.BOLD}\n--- Traceback ---{ut.bcolors.ENDC}")54 print(f"{ut.bcolors.FAIL}{traceback.format_exc()}{ut.bcolors.ENDC}")55 print(f"{ut.bcolors.BOLD}--- Message ---{ut.bcolors.ENDC}")...

Full Screen

Full Screen

skeleton.py

Source:skeleton.py Github

copy

Full Screen

1import shutil2from pathlib import Path3from youwol.pipelines.pipeline_typescript_weback_npm.common import generate_package_json, copy_files_folders, \4 generate_webpack_config, Dependencies, RunTimeDeps, Template5from youwol.utils.utils_low_level import sed_inplace6from youwol_cdn_backend import get_api_key7def generate_template(input_template: Template):8 working_path = input_template.path / '.template'9 if working_path.is_dir():10 shutil.rmtree(path=working_path)11 input_template.dependencies = Dependencies(12 runTime=RunTimeDeps(13 externals={},14 includedInBundle={15 **input_template.dependencies.runTime.includedInBundle,16 input_template.name: input_template.version17 }18 ),19 devTime=input_template.dependencies.devTime20 )21 Path(working_path).mkdir()22 copy_files_folders(working_path=working_path, base_template_path=Path(__file__).parent / 'templates',23 files=['.gitignore', 'tsconfig.json'],24 folders=['.yw_pipeline', 'src'])25 fill_src_files(working_path=working_path, input_template=input_template)26 generate_package_json(source=Path(__file__).parent / 'templates' / 'package.json',27 working_path=working_path, input_template=input_template)28 generate_readme(working_path=working_path, input_template=input_template)29 generate_webpack_config(source=Path(__file__).parent / 'templates' / 'webpack.config.lib.js',30 working_path=working_path,31 input_template=input_template)32def generate_readme(working_path: Path, input_template: Template):33 filename = working_path / 'README.md'34 shutil.copyfile(Path(__file__).parent / 'templates' / 'README.lib.md', working_path / 'README.md')35 dev_documentation = \36 "[Developers documentation](https://platform.youwol.com/applications/@youwol/cdn-explorer/latest" \37 f"?package={input_template.name})"38 for pattern, repl in [39 ["name", input_template.name],40 ['shortDescription', input_template.shortDescription],41 ['developerDocumentation', dev_documentation],42 ]:43 sed_inplace(filename, "{{"+pattern+"}}", repl)44def fill_src_files(working_path: Path, input_template: Template):45 filename = working_path / 'src' / 'index.ts'46 api_version = get_api_key(input_template.version)47 for pattern, repl in [48 ["name", input_template.name],49 ["exportedSymbol", input_template.exportedSymbol or input_template.name],50 ['apiVersion', api_version],51 ]:...

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