ZSMS Python Module


License
AGPL-3.0
Install
pip install pySMS==3.0.7

Documentation

#pySMS Automation and Macro Tools for SMS

pySMS is a python build module for scripting automation of SMS for ZimmerBiomet. pySMS utilizes the Selenium webdriver to send commands and information to the site. pySMS comes with a prebuilt data set of paths to interact with the site!

Getting Started

Prerequisites

you will need the following modules to be installed before using pySMS:

Selenium
colorama
binascii
lxml
cssselect
xlrd
pythoncom
prettytable
gzip
clr

To install these, simply use pip from the command line or pip install pySMS and run this code in python:

from pySMS.req import prereq

prereq.import_pkgs()
prereq.upgrade_pkgs()

the follow can be downloaded from the extenstions folder!

pyHook
psycopg2

To Install pyHook:

  • download the correct wheel and run pip:

pip install pyHook-1.5.1-cp35-none-win_amd64.whl

To Install Pyscopg2

  • download pyscopg2.exe and run

Installing

Download pySMS from pip:

pip install pySMS

or download the zip file, unzip it, and run setup.py:

python setup.py build
python setup.py install

To install the required modules, simply use pip from the command line or pip install pySMS and run this code in python:

from pySMS.req import prereq

prereq.import_pkgs()
prereq.upgrade_pkgs()

to verify pySMS is installed correctly:

from pySMS.req import verify

verify.report()

Cloning

If you are cloning this repository, make sure you clone to this directory ONLY:

  • C:\Users\YOUR USER NAME\

A Simple Script

open python and type:

from pySMS import selenium as s

m = s.macros('[Test]')

m.launch() #After this you will be prompted for your login information
m.var()    #must be called immediatly after launch, this defines the variables

m.login()  #This will log you in

m.slay() #closes SMS and chrome

Connecting to the IW (postgres)

If you want to pull data straight from the IW into python you can use the pgsql module for this! The following code is required before you can start using the IW. This code creates a credentials file that is encrypted.

from pySMS.pgsql import cipher as c

c.build_cipher_file()

The following code will test the connection to postgres:

from pySMS.pgsql.postgres import Postgres

p = Postgres()
p.load_postgres_data() #decrypts information stored in credntials file
p.test_connection()    #test connection to IW, will retry 5 times by default

The following example will query the enum table in the sms schema

from pySMS.pgsql.postgres import Postgres

query = 'SELECT * FROM sms.enum'
	
p = Postgres()
p.load_postgres_data() 
p.establish_connection()
data = p.execute(query)
print(data)

Other Examples

Other examples of using pySMS are the scripts:

  • mutation.py

How to build

Use some of the different tools in the utils folder for building and distributing this.

Contact Me

For questions or help using this contact me at:

Ian.Doarn@zimmerbiomet.com

TO DO LIST

  • Rewrite older modules. Make them more pythonic and readable.
  • Clean up core modules and remove broken or unused files:
    • The following modules need complete rewrites: selenium, excelparse, livery, prompts, html, req.verify, req.prereq, utils.logger
  • Comment literally everything. I never commented.
  • Get ready for more automations
  • Create decoraters @await_for_click, @await_element, @catchexception, @wait. These will allow the program to wait for an element to be clicked and will also allow for custom excpetions and custom timings, this is important because processor speed and internet connection greatly effects how the application runs
  • Add exceptions to stop program from crashing on the following problems:
    • Crash on login failed, when user logs in before prompt is shown
    • Crash when item can not be found in data library, happens when bool_data_from_table returns a dictionary with a NoneType value or is give a NoneType value. Almost fixed
    • Sometimes no item is added to the product chooser and finish will be clicked. Happens mainly with tray that begin with 'P' and 'R'.
    • Crash on custom exceptions being thrown.
    • Faster CPU and Internet Connections can cause the program to error time out faster. This happens because faster processors run the scripts faster, meaning that the response time from the chromedriver and python is much shorter, and the functions 'wait_for_element' and 'wait_for_click' error out much faster.
    • Work with Patrick to figure out the best query to pull back all items related to CI. current item types include: Trays, Kits, Pieces, Components
    • Logging does not fully work, only if the program fully completes without crashing are logs written, if it crashes a crash report log is written but all data for the current run automation is lost. Need to figure out how to save both in the event of a crash.