-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Albel Azure
committed
Dec 31, 2021
1 parent
f66d7a4
commit d3e9568
Showing
33 changed files
with
305 additions
and
117 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from RPA.Email.ImapSmtp import ImapSmtp | ||
from RPA.Outlook.Application import Application | ||
from RPA.Robocorp.Vault import Vault | ||
import time | ||
|
||
def send_gmail_email(recipient, subject, body): | ||
secret = Vault().get_secret("emailGmailCredentials") | ||
gmail_account = secret["username"] | ||
gmail_password = secret["password"] | ||
mail = ImapSmtp(smtp_server="smtp.gmail.com", smtp_port=587) | ||
mail.authorize(account=gmail_account, password=gmail_password) | ||
mail.send_message( | ||
sender=gmail_account, | ||
recipients=recipient, | ||
subject=subject, | ||
body=body, | ||
) | ||
|
||
def send_outlook_email(recipient, subject, body): | ||
app = Application() | ||
app.open_application() | ||
try: | ||
app.send_email(recipients=recipient, subject=subject, body=body) | ||
except Exception as e: | ||
if e.strerror == 'Call was rejected by callee.': | ||
time.sleep(2) | ||
app.send_email(recipients=recipient, subject=subject, body=body) | ||
|
||
def get_outlook_email(account_name,folder_name): | ||
app = Application() | ||
app.open_application() | ||
time.sleep(2) | ||
email_list = app.get_emails(account_name=account_name, folder_name=folder_name, save_attachments=True, attachment_folder="D:\\RobotFramework\\attachments\\") | ||
return email_list | ||
|
||
# def send_outlook_email(recipient, subject, body): | ||
# secret = Vault().get_secret("emailOutlookCredentials") | ||
# outlook_account = secret["username"] | ||
# outlook_password = secret["password"] | ||
# mail = ImapSmtp(smtp_server="smtp.office365.com", smtp_port=587) #should enable smtp access in Exchange | ||
# mail.authorize(account=outlook_account, password=outlook_password) | ||
# mail.send_message( | ||
# sender=outlook_account, | ||
# recipients=recipient, | ||
# subject=subject, | ||
# body=body, | ||
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
from RPA.Excel.Files import Files | ||
from RPA.Tables import Tables | ||
|
||
# FILE_EXCEL_PATH = os.environ["<path to Excel file>"] | ||
|
||
excel = Files() | ||
tables = Tables() | ||
|
||
# def get_filtered_excel(excel_path): | ||
# excel = read_excel_as_table(excel_path) | ||
# tables.filter_table_by_column(excel, "<column to filter>", "==", "<value to filter>") | ||
# return excel | ||
|
||
def read_excel_as_table(excel_path): | ||
try: | ||
excel.open_workbook(excel_path) | ||
return excel.read_worksheet_as_table(header=True) | ||
finally: | ||
excel.close_workbook() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import fitz | ||
from RPA.Tables import Tables | ||
from RPA.PDF import PDF | ||
|
||
|
||
def get_pdf_widgets(): | ||
|
||
table = Tables() | ||
filename = "documents/Generali-page21.pdf" | ||
doc = fitz.open(filename) | ||
page = doc.load_page(0) | ||
|
||
columns_list = ['field_name','field_label','field_value'] | ||
mytable = table.create_table(None, False, columns_list) | ||
|
||
# table.add_table_column(mytable, "field_name") | ||
# table.add_table_column(mytable,"field_label") | ||
# table.add_table_column("field_value") | ||
|
||
list_values=[] | ||
for field in page.widgets(): | ||
list_values.append(field.field_name) | ||
list_values.append(field.field_label) | ||
list_values.append(field.field_value) | ||
table.add_table_row(mytable, list_values) | ||
list_values=[] | ||
# print("field name : %s **** field label : %s **** field value : %s" %(field.field_name,field.field_label,field.field_value)) | ||
|
||
rows, columns = mytable.dimensions | ||
print(rows,columns) | ||
for i in range(1, rows): | ||
row = mytable.get_row(i) | ||
print(row["field_name"] + " *** " + row["field_label"] + " *** " + row["field_value"]) | ||
#table.group_by_column | ||
|
||
|
||
def get_pdf_fields(): | ||
pdf = PDF() | ||
fields = pdf.get_input_fields("documents/Generali-page21.pdf") | ||
print(fields) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from exceler import read_excel_as_table | ||
from RPA.Tables import Tables | ||
from variables import today | ||
import emailer | ||
|
||
from RPA.Browser.Selenium import Selenium | ||
from RPA.Robocorp.Vault import Vault | ||
from robot.api import logger | ||
|
||
import logging | ||
import sys | ||
|
||
from playwright.sync_api import sync_playwright | ||
|
||
stdout = logging.StreamHandler(sys.stdout) | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="[{%(filename)s:%(lineno)d} %(levelname)s - %(message)s", | ||
handlers=[stdout], | ||
) | ||
|
||
lib = Selenium() | ||
|
||
|
||
secret = Vault().get_secret("credentials") | ||
|
||
username = secret["username"] #"[email protected]" | ||
password = secret["password"] # "Dasilva2010" | ||
|
||
def connect_to_sangoma(): | ||
lib.open_available_browser("https://portal.sangoma.com/") | ||
lib.input_text("id:email_address", username) | ||
lib.input_text("id:password", password) | ||
lib.click_button("css=button[class=\"btn btn-primary btn-block\"]") | ||
selected_option = "//span[text()='Users/Customers']" | ||
lib.wait_until_element_is_visible(selected_option) # must read doc | ||
lib.click_element(selected_option) # must read doc | ||
selected_option = "//a[text()='List Users']" | ||
lib.click_element(selected_option) | ||
import time | ||
time.sleep(5) | ||
logger.info("Connection to Sangoma has been completed.", html=True) | ||
|
||
def connect_with_playwright(): | ||
with sync_playwright() as p: | ||
for browser_type in [p.chromium]: | ||
browser = browser_type.launch() | ||
page = browser.new_page() | ||
page.goto('http://whatsmyuseragent.org/') | ||
page.screenshot(path=f'my-browser-specs-{browser_type.name}.png') | ||
browser.close() | ||
|
||
def email_to_send(): | ||
receiver_name = "Ali" | ||
name = f"{receiver_name}" | ||
recipient = "[email protected]" | ||
subject = "This a Robot speaking to Ali!" | ||
body = ( | ||
f"Hi, {name}! " | ||
f"Remember that you have to finish your wonderful robot and get it up and running on {today()}." | ||
) | ||
emailer.send_outlook_email(recipient, subject, body) | ||
|
||
def get_outlook_emails(): | ||
account_name = "[email protected]" | ||
folder_name = "Inbox" | ||
emails = emailer.get_outlook_email(account_name,folder_name) | ||
for email in emails: | ||
#print(email) | ||
print(email["Sender"] + " **** " + email["Subject"]) | ||
|
||
def read_from_excel(): | ||
table = Tables() | ||
path = "D:\\RobotFramework\\documents\\persons.xlsx" | ||
table = read_excel_as_table(path) | ||
rows, columns = table.dimensions | ||
print(rows,columns) | ||
for i in range(1, rows): | ||
row = table.get_row(i) | ||
print(row["Name"] + " *** " + row["email"] + " *** " + row["Location"]) | ||
table.group_by_column | ||
|
||
if __name__ == "__main__": | ||
LOGGER = logging.getLogger(__name__) | ||
#connect_to_sangoma() | ||
#email_to_send() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1799,31 +1799,31 @@ | |
window.output = {}; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["suite"] = [1,2,3,4,[],[1,0,13335],[],[[5,0,0,[],[1,1483,11847],[[0,6,7,0,0,0,0,0,[1,1486,11839],[[8,1508,2,8],[8,1519,2,9],[8,1520,2,10],[8,1521,2,8],[8,3049,2,11],[8,3049,2,12],[8,3049,2,13],[8,4592,2,14],[8,4665,2,15],[8,4744,2,16],[8,7541,2,17],[8,7582,2,18],[8,13325,2,19]]],[0,20,21,0,22,23,0,0,[1,13327,2],[[8,13328,2,24]]]]]],[],[1,1,0,0]]; | ||
window.output["suite"] = [1,2,3,4,[],[1,0,5184],[],[[5,0,0,[],[1,3554,1626],[[0,6,7,0,0,0,0,0,[1,3556,1622],[]]]]],[],[1,1,0,0]]; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["strings"] = []; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["strings"] = window.output["strings"].concat(["*","*Tasks","*d:\\RobotFramework\\tasks.robot","eNqzSVTIKEpNs1VKy8xJtdLX13ex0g/KT8ovcStKzE0tzy/K1i9JLM4u1isCCSrZEaXMRj/RDgBV5h8O","*<p>Robot that connect to Sangoma website.\x3c/p>","*Sangoma task","*Connect To Sangoma","*tasks","*Creating an instance of the Chrome WebDriver.","*Created download root directory: C:\\Users\\albel\\AppData\\Local\\robocorp\\webdrivers","*Created symlink directory: C:\\Users\\albel\\AppData\\Local\\robocorp\\webdrivers","*Created Chrome browser with arguments: --disable-dev-shm-usage --disable-web-security --allow-running-insecure-content --no-sandbox","eNp9ULtuwzAM3PsVRJZs5m6oApI+0KVAhvyALBG2AFk0SDnp51dRgiRThgN5xzfNYnel0LwUCuB5HmJ2JXLW3uBiTYgn8Mmpvm8C+401xQ2JqpGKye6Fz0pisPoX/snnnNiFu/AlwrcwtpoLgv2YhGeqUmj02yV9sF9SdSP1sPUtLUg8kWyB/sivbT5koqBQGAaCmOGwO/50cEjklECJYCpl0R5RYyHtRuYxUVevQ4etZ1znjmXE5wE4VfftusWLXY+yPshTNt4+g/Vl9h/PY3eM","*Opening url '<a href=\"https://portal.sangoma.com/\">https://portal.sangoma.com/\x3c/a>'","*Typing text '[email protected]' into text field 'id:email_address'.","*Typing text 'Dasilva2010' into text field 'id:password'.","*Clicking button 'css=button[class=\"btn btn-primary btn-block\"]'.","*Clicking element '//span[text()='Users/Customers']'.","*Clicking element '//a[text()='List Users']'.","*Connection to Sangoma has been completed.","*Log","*BuiltIn","*<p>Logs the given message with the given level.\x3c/p>","*${TODAY}","*2021-12-27 18:08:50.508610"]); | ||
window.output["strings"] = window.output["strings"].concat(["*","*Tasks","*d:\\RobotFramework\\tasks.robot","eNqzSVTIKEpNs1VKy8xJtdLX13ex0g/KT8ovcStKzE0tzy/K1i9JLM4u1isCCSrZEaXMRj/RDgBV5h8O","*<p>Robot that do a lot of things\x3c/p>","*Experiments task","*Connect With Playwright","*tasks"]); | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["stats"] = [[{"elapsed":"00:00:12","fail":0,"label":"All Tasks","pass":1,"skip":0}],[],[{"elapsed":"00:00:13","fail":0,"id":"s1","label":"Tasks","name":"Tasks","pass":1,"skip":0}]]; | ||
window.output["stats"] = [[{"elapsed":"00:00:02","fail":0,"label":"All Tasks","pass":1,"skip":0}],[],[{"elapsed":"00:00:05","fail":0,"id":"s1","label":"Tasks","name":"Tasks","pass":1,"skip":0}]]; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["errors"] = []; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["baseMillis"] = 1640624929031; | ||
window.output["baseMillis"] = 1640900850323; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["generated"] = 13360; | ||
window.output["generated"] = 5206; | ||
</script> | ||
<script type="text/javascript"> | ||
window.output["expand_keywords"] = null; | ||
</script> | ||
<script type="text/javascript"> | ||
window.settings = {"defaultLevel":"INFO","minLevel":"INFO","reportURL":"report.html","rpa":true,"splitLogBase":"log","title":""}; | ||
window.settings = {"defaultLevel":"INFO","minLevel":"NONE","reportURL":"report.html","rpa":true,"splitLogBase":"log","title":""}; | ||
</script> | ||
<title></title> | ||
</head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<robot generator="Robot 4.1.3 (Python 3.9.7 on win32)" generated="20211227 18:08:49.024" rpa="true" schemaversion="2"> | ||
<robot generator="Robot 4.1.3 (Python 3.9.7 on win32)" generated="20211230 22:47:30.317" rpa="true" schemaversion="2"> | ||
<suite id="s1" name="Tasks" source="d:\RobotFramework\tasks.robot"> | ||
<test id="s1-t1" name="Sangoma task"> | ||
<kw name="Connect To Sangoma" library="tasks"> | ||
<msg timestamp="20211227 18:08:50.539" level="INFO">Creating an instance of the Chrome WebDriver.</msg> | ||
<msg timestamp="20211227 18:08:50.550" level="INFO">Created download root directory: C:\Users\albel\AppData\Local\robocorp\webdrivers</msg> | ||
<msg timestamp="20211227 18:08:50.551" level="INFO">Created symlink directory: C:\Users\albel\AppData\Local\robocorp\webdrivers</msg> | ||
<msg timestamp="20211227 18:08:50.552" level="INFO">Creating an instance of the Chrome WebDriver.</msg> | ||
<msg timestamp="20211227 18:08:52.080" level="INFO">Created Chrome browser with arguments: --disable-dev-shm-usage --disable-web-security --allow-running-insecure-content --no-sandbox</msg> | ||
<msg timestamp="20211227 18:08:52.080" level="INFO" html="true"><p>Attempted combinations:</p><div class="doc"><table><tr><th>Browser</th><th>Download</th><th>Error</th></tr><tr><td>Chrome</td><td>False</td><td>Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home | ||
</td></tr><tr><td>Chrome</td><td>True</td><td></td></tr></table></div></msg> | ||
<msg timestamp="20211227 18:08:52.080" level="INFO">Opening url 'https://portal.sangoma.com/'</msg> | ||
<msg timestamp="20211227 18:08:53.623" level="INFO">Typing text '[email protected]' into text field 'id:email_address'.</msg> | ||
<msg timestamp="20211227 18:08:53.696" level="INFO">Typing text 'Dasilva2010' into text field 'id:password'.</msg> | ||
<msg timestamp="20211227 18:08:53.775" level="INFO">Clicking button 'css=button[class="btn btn-primary btn-block"]'.</msg> | ||
<msg timestamp="20211227 18:08:56.572" level="INFO">Clicking element '//span[text()='Users/Customers']'.</msg> | ||
<msg timestamp="20211227 18:08:56.613" level="INFO">Clicking element '//a[text()='List Users']'.</msg> | ||
<msg timestamp="20211227 18:09:02.356" level="INFO" html="true">Connection to Sangoma has been completed.</msg> | ||
<status status="PASS" starttime="20211227 18:08:50.517" endtime="20211227 18:09:02.356"/> | ||
<test id="s1-t1" name="Experiments task"> | ||
<kw name="Connect With Playwright" library="tasks"> | ||
<status status="PASS" starttime="20211230 22:47:33.879" endtime="20211230 22:47:35.501"/> | ||
</kw> | ||
<kw name="Log" library="BuiltIn"> | ||
<arg>${TODAY}</arg> | ||
<doc>Logs the given message with the given level.</doc> | ||
<msg timestamp="20211227 18:09:02.359" level="INFO">2021-12-27 18:08:50.508610</msg> | ||
<status status="PASS" starttime="20211227 18:09:02.358" endtime="20211227 18:09:02.360"/> | ||
</kw> | ||
<status status="PASS" starttime="20211227 18:08:50.514" endtime="20211227 18:09:02.361"/> | ||
<status status="PASS" starttime="20211230 22:47:33.877" endtime="20211230 22:47:35.503"/> | ||
</test> | ||
<doc>Robot that connect to Sangoma website.</doc> | ||
<status status="PASS" starttime="20211227 18:08:49.031" endtime="20211227 18:09:02.366"/> | ||
<doc>Robot that do a lot of things</doc> | ||
<status status="PASS" starttime="20211230 22:47:30.323" endtime="20211230 22:47:35.507"/> | ||
</suite> | ||
<statistics> | ||
<total> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
job "job_Sangoma" { | ||
#periodic { | ||
# cron = "0 9 * * 1-5" | ||
# prohibit_overlap = true | ||
#} | ||
datacenters = ["dc1"] | ||
group "group_tasks" { | ||
#count = 1 | ||
task "setup_task" { | ||
driver = "raw_exec" | ||
config { | ||
command = "xcopy" | ||
args = ["D:\\RobotFramework\\","${NOMAD_ALLOC_DIR}\\run_task\\","/E"] | ||
} | ||
lifecycle { | ||
hook = "prestart" | ||
sidecar = false | ||
} | ||
} | ||
task "run_task" { | ||
driver = "raw_exec" | ||
config { | ||
command = "${NOMAD_ALLOC_DIR}\\run_task\\rcc" | ||
args = ["run","-e", "${NOMAD_ALLOC_DIR}\\run_task\\devdata\\env.json"] | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
Oops, something went wrong.