1. Instalar rcc
En https://github.com/robocorp/rcc?tab=readme-ov-file#installing-rcc-from-the-command-line dice literalmente:
- Open the command prompt
- Download:
curl -o rcc.exe https://downloads.robocorp.com/rcc/releases/latest/windows64/rcc.exe
- Add to system path: Open Start ->
Edit the system environment variables
- Test:
rcc
- Update brew:
brew update
- Install:
brew install robocorp/tools/rcc
- Test:
rcc
Upgrading: brew upgrade rcc
- Open the terminal
- Download:
curl -o rcc https://downloads.robocorp.com/rcc/releases/latest/linux64/rcc
- Make the downloaded file executable:
chmod a+x rcc
- Add to path:
sudo mv rcc /usr/local/bin/
- Test:
rcc
===================
2. Ejecutar el módulo de ejemplo del principiante
En https://robocorp.com/docs/courses/beginners-course-python/11-creating-pdf hay un fichero tasks.py que copiamos aquí.
from robocorp.tasks import task from robocorp import browser from RPA.HTTP import HTTP from RPA.Excel.Files import Files from RPA.PDF import PDF @task def robot_spare_bin_python(): """Insert the sales data for the week and export it as a PDF""" browser.configure( slowmo=100, ) open_the_intranet_website() log_in() download_excel_file() fill_form_with_excel_data() collect_results() export_as_pdf() log_out() def open_the_intranet_website(): """Navigates to the given URL""" browser.goto("https://robotsparebinindustries.com/") def log_in(): """Fills in the login form and clicks the 'Log in' button""" page = browser.page() page.fill("#username", "maria") page.fill("#password", "thoushallnotpass") page.click("button:text('Log in')") def fill_and_submit_sales_form(sales_rep): """Fills in the sales data and click the 'Submit' button""" page = browser.page() page.fill("#firstname", sales_rep["First Name"]) page.fill("#lastname", sales_rep["Last Name"]) page.select_option("#salestarget", str(sales_rep["Sales Target"])) page.fill("#salesresult", str(sales_rep["Sales"])) page.click("text=Submit") def download_excel_file(): """Downloads excel file from the given URL""" http = HTTP() http.download(url="https://robotsparebinindustries.com/SalesData.xlsx", overwrite=True) def fill_form_with_excel_data(): """Read data from excel and fill in the sales form""" excel = Files() excel.open_workbook("SalesData.xlsx") worksheet = excel.read_worksheet_as_table("data", header=True) excel.close_workbook() for row in worksheet: fill_and_submit_sales_form(row) def collect_results(): """Take a screenshot of the page""" page = browser.page() page.screenshot(path="output/sales_summary.png") def export_as_pdf(): """Export the data to a pdf file""" page = browser.page() sales_results_html = page.locator("#sales-results").inner_html() pdf = PDF() pdf.html_to_pdf(sales_results_html, "output/sales_results.pdf") def log_out(): """Presses the 'Log out' button""" page = browser.page() page.click("text=Log out")
Para ello creamos una carpeta por ejemplo ~/MyPython/prova06_rcc
Copiamos el fichero anterior (tasks.py) en dicha carpeta
Copiamos el siguiente fichero conda.yaml que sale si hemos completado el tutorial indicado en dicha página
# For more details on the format and content:# https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-condayaml# Tip: Adding a link to the release notes of the packages helps maintenance and security.channels:- conda-forgedependencies:- python=3.10.12 # https://pyreadiness.org/3.10- pip=23.2.1 # https://pip.pypa.io/en/stable/news- robocorp-truststore=0.8.0 # https://pypi.org/project/robocorp-truststore/- pip:- rpaframework==28.0.0 # https://rpaframework.org/releasenotes.html- robocorp==1.4.0 # https://pypi.org/project/robocorp- robocorp-browser==2.2.1 # https://pypi.org/project/robocorp-browser
Opcionalmente podemos copiar los ficheros LICENSE y README.md
Copiamos el fichero robot.yaml
# For more details on the format and content:# https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-robotyamltasks:Run Task:shell: python -m robocorp.tasks run tasks.pyenvironmentConfigs:- environment_windows_amd64_freeze.yaml- environment_linux_amd64_freeze.yaml- environment_darwin_amd64_freeze.yaml- conda.yamlartifactsDir: outputPATH:- .PYTHONPATH:- .ignoreFiles:- .gitignore
Nos situamos en dichar carpeta y ejecutamos el programa mediante "rcc run"
# Nos situamos y ejecutamos rcccd ~/MyPython/prova06_rccrcc run
Y ejecuta todo el proceso
No hay comentarios :
Publicar un comentario