While PO's may be entered manually in a form eventually, I'm assuming that automated processes will be the main usage, and only have it working for a json POST (no manual form) - see exampleSimplePO.json The json POST is validated by schema, field names, and their value types before sending a soap request. See the 'Instructions for PO' under the 'Info' tab on the nav bar.
The PO also only works with the vernonco docker image (vernonco/ps-utils:dev) as it has a fix for suds-py3 included (Dockerfile line 24) - Waiting for fix to module - see suds-py3 issue #41. If you build the image your self, you must add the following lines to 171,172 in site-packages/suds/xsd/sxbase.py for it to correctly parse "ref:..." in the WSDLs if self.ref and self.ref in self.schema.elements.keys(): ns = self.ref
git clone https://github.com/VernonCo/ps_utils.git
Requires python 3.7 +
first create venv
python3 -m venv venv
activate venv
source venv/bin/activate
to deactivate:
deactivate
install requirements into virtualenv pip install --upgrade pip pip install -r requirements.txt
run locally on vscode using F5 and view at http://localhost:5000 or in terminal using venv:
python run.py
to setup the database to test or run on production, it needs to be accessible to the local run
docker-compose [-f dev-docker-compose.yml] up -d
if using weavenet to provide secure WAN to databases etc.
docker-compose $(weave config) [-f dev-docker-compose.yml] up -d
docker-compose files have the option of running the db as a container or comment out db and adminer services and set variables in for remote db access...make sure of persistent volume for production if running in k8 or similar
need the following to run production as gunicorn with multiple workers. This prevents a race condition of multiple works trying to set up permissions.
FAB_UPDATE_PERMS = False
You will need to run the database once with FLASK_ENV=development
used so that only one thread is running and the following COMMENTED out in order FOR THE APP to set the permissions up in the database:
in other words, this needs ran to access the utilities.
export FLASK_APP="run:app"
flask fab create-admin
docker exec -it ps_utils[_dev] bash
export FLASK_APP="run:app"
flask fab create-admin
Make the app available to operators by either putting on limited network or adding users
The config.py (or config-4passwords.py) have configuration to allow public access to the forms. However, the config has been commented out as it was not working as expected. Therefore, for public role use the security model below.
If desiring granular control over access, comment out the FAB_ROLES, and use the security model.
Don't forget to change SECRET_KEY in config.py or config-4passwords.py
View user registration and roles at flask_appbuilder security. The flask_appbuilder security also shows how to change the authentication to use LDAP and create roles in line with your AD groups.
ctl+shft+p
python:select interpeter
pip install pylint
Click Debug -> Open current configurations. Add following to end of configurations if not one created for 'Python: Flask'
,{
"name": "Flask",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"program": "${workspaceFolder}/ps_utils/vs_debug.py",
"envFile": "absolute_path_to/.env",
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
FLASK_APP=ps_utils/app
DB_AUTH=youruser
DB_PASS=yourpassword
DB_HOST=yourhost
DB_PORT=yourhostport
SERVER_PATH=/path to/ps_utils
CONFIG_FILE='config' # or config-4passwords to move existing credentials
#for passwords move
OLD_DB_AUTH=youruser
OLD_DB_PASS=yourpassword
OLD_DB_HOST=yourhost
OLD_DB_PORT=yourhostport
Currently, test coverage is very basic...adding as I have the time or get pull requests
To run tests. cd app; python tests/run_tests.py