Skip to content

Commit

Permalink
Merge pull request #11 from dmatik/master
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mer committed Nov 3, 2020
2 parents 00ba290 + 327a143 commit a490731
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ COPY workers/Webtop_Health_Statements.py /opt/dockerbot
COPY workers/Infogan_Health_Statements.py /opt/dockerbot
COPY workers/Hilan_Health_Statements.py /opt/dockerbot
COPY workers/Hbinov_Health_Statements.py /opt/dockerbot
COPY workers/Amdocs_Health_Statements.py /opt/dockerbot
COPY helpers.py /opt/dockerbot
COPY dockerbot.py /opt/dockerbot
COPY please_sign.jpg /opt/dockerbot
Expand Down
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ hilan:
URL:
EMPLOYEE_NUM:
PASSWORD:
amdocs:
EMAIL:
USER_ID:
PASSWORD:
24 changes: 24 additions & 0 deletions dockerbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
webtop_Image = '/opt/dockerbot/images/webtop_approval.png'
infogan_Image = '/opt/dockerbot/images/infogan_approval.png'
hilan_Image = '/opt/dockerbot/images/hilan_approval.png'
amdocs_Image = '/opt/dockerbot/images/amdocs_approval.png'
hbinov_Image = '/opt/dockerbot/images/hbinov_approval.png'

def CopyConfig():
Expand Down Expand Up @@ -172,6 +173,29 @@ def hilan_statement():
else:
return send_file(str(default_Image), mimetype='image/jpeg',cache_timeout=-1)

@app.route('/amdocs/sign')
def sign_amdocs():
list = ReadConfig()
if list['amdocs']['EMAIL'] and list['amdocs']['USER_ID'] and list['amdocs']['PASSWORD'] != None:
try:
logger.info("Starting Sign process at Amdocs")
import Amdocs_Health_Statements
if Amdocs_Health_Statements.sign(list['amdocs']['EMAIL'], str(list['amdocs']['USER_ID']), list['amdocs']['PASSWORD'], amdocs_Image) == 1:
return jsonify('{"signed":"1","data":""}')
else:
return jsonify('{"signed":"0","data":""}')
except Exception as ex:
logger.error(str(ex))
return jsonify('{"signed":"0","data":"' + str(ex) + '"}')

return jsonify('{"signed":"0","data":"Amdocs is not configured"}')

@app.route('/amdocs/statement')
def amdocs_statement():
if os.path.exists(amdocs_Image):
return send_file(str(amdocs_Image), mimetype='image/png', cache_timeout=-1)
else:
return send_file(str(default_Image), mimetype='image/jpeg',cache_timeout=-1)

#### Not Operational Yet ######
@app.route('/hbinov/sign')
Expand Down
60 changes: 60 additions & 0 deletions workers/Amdocs_Health_Statements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from datetime import date, datetime
import time, os
from selenium.common.exceptions import InvalidSessionIdException
from loguru import logger
import helpers

def sign(email, user_id, password, Image):

try:
logger.info("Starting process")
browser = helpers.GetBrowser()
try:
helpers.ping(browser, 'infogan')
except:
logger.debug('Unable to ping')

browser.delete_all_cookies()
browser.get("https://amdocsprodmain.service-now.com/one_portal?id=aop_sc_cat_item&sys_id=781f12f1db5cd8903780e1aa4b961903")
helpers.log_browser(browser)

time.sleep(4)

# Email page
xpath_email = browser.find_element_by_xpath('//*[@id="i0116"]')
xpath_email_submit = browser.find_element_by_xpath('//*[@id="idSIButton9"]')

xpath_email.send_keys(email)
xpath_email_submit.click()

time.sleep(4)

# User and Password page
xpath_user = browser.find_element_by_xpath('//*[@id="userNameInput"]')
xpath_password = browser.find_element_by_xpath('//*[@id="passwordInput"]')
xpath_sign_in = browser.find_element_by_xpath('//*[@id="submitButton"]')

xpath_user.clear()
xpath_user.send_keys("ntnet\\" + user_id)
xpath_password.send_keys(password)
xpath_sign_in.click()

time.sleep(4)

# Declaration
xpath_approved = browser.find_element_by_xpath("//input[@name='u_approved']")
xpath_submit = browser.find_element_by_xpath("//button[@name='submit']")

xpath_approved.click()
xpath_submit.click()

helpers.log_browser(browser)
helpers.fullpage_screenshot(browser,Image)

return 1
except Exception as ex:
logger.error(str(ex))
return 0

0 comments on commit a490731

Please sign in to comment.