Pannos Scripting Library Documentation (WIP)
Documentation for various Python scripts used for automation and scraping tasks at Pannos Marketing
Setup
-
Clone the repository found on Beanstalk by running this terminal command:
git clone https://pannos.beanstalkapp.com/pannos-automation-and-scripting
- Download Python 3.x (preferably the latest version)
-
When running the Python installer, make sure to check the box that says "Add Python to PATH"
-
Ensure Python and PIP have been installed by testing both of these commands in a terminal:
pip
python
-
Install the required Python packages by running the following command in the root of the project:
pip install -r PannosTools/pip.txt
-
Some scripts use secure passwords or keys.
Get Pannos Scripting Library Encryption Key from password manager and set it as the environment variable:
PANNOS_ASL_KEY
To add new keys, run addKey.py from the script menu and enter in the alias and key.
Usage
All the scripts are designed to be run from the root of the project.
From the root, you can run a script by either:
-
Using A direct terminal command (example runs SFTP Check):
python \SFTP Check\pannosSFTP.py
-
Through the menu script:
python scriptMenu.py
Documentation for Scripts
SFTP Check
To use this script, first ensure you are in office or connected to the VPN.
The script will output a CSV named sftp-expiring {date of runtime}.csv to SFTP Check/output
Pages Scrape (Port Tools)
WIP
Articles Scrape (Port Tools)
WIP
Creating New Scripts
If you want to create a script, there is a library of functions available to help you.
Create a folder in the root with your project name.
It is a good convention to have your script output (if applicable) to an /output folder in this directory (contents will be gitignored)
This Header and import statement give access to these functions and maintain consistency in the library:
#########################################################################################
# #
# File Name: filename.py #
# Created by: @name for Pannos Marketing #
# Last Modified: XXXX-XX-XX #
# Description: Description of file. #
# Disclaimer: Only for use by the Pannos Marketing Web Team #
# #
# Notes: Notes can go here. #
# #
#########################################################################################
# Import from PannosTools module
import sys
sys.path.append("./")
from PannosTools.imports import *
from PannosTools.pannosTools import *
The next sections contain documentation for differnet included modules in this library.
Documentation for pannosTools
Key:
Argument
Optional Keyword Argument
Return
initChromedriver()
Chrome Options
Selenium Driver Object
Easier Chromedriver Init
Optional : Provide custom Chromedriver arguments:
Usage:
driver = initChromedriver(options)
# or
driver = initChromedriver()
findElement()
Selector
Selector Type
Parent
Timeout (seconds)
Logging
Selenium Object
Better find element selenium wrapper function
Optional : Provide parent element (as selenium object) and logging (True/False)
Usage:
element = findElement("myID", "id", parent=driver, timeout=2, logging=True)
# or
element = findElement("myID", "id", parent=driver)
findElements()
Selector
Selector Type
Parent
Timeout (seconds)
Logging
List of Selenium Objects
Better find_elements selenium wrapper function
Optional : Provide parent element (as selenium object) and logging (True/False)
Usage:
elements = findElements(".className", "css", parent=driver, timeout=2, logging=True)
# or
elements = findElements(".className", "css", parent=driver)
NewTab()
Driver Object
URL
Managing new tabs can be tricky in selenium, so this context manager class helps to smooth this out.
Once this code block is executed, the context will swap back to the previous tab
Usage:
with NewTab(driver, editPage):
# do something in new tab