A autopytic package
Project description
autopytic
Improve your RPA python code with wrapper 🤯
Feautes
- Easy to use on existing scripts
- Send email notifications on exception
- Auto-timmings
- Auto-logging
- Auto-documentation
...
Installation
Use the package manager pip to install foobar.
pip install autopytic
pip install python-dotenv
In your main python script localization create file named .pytic with:
# Settings
DEBUG_MODE=false
ERROR_RAISE=false
# Email Settings
SEND_EXCEPTIONS=false
SMTP_HOST=
SMTP_PORT=
SENDER_EMAIL=
SENDER_PASS=
RECIVER_EMAIL=
# Coverage Settings
EXCLUDE_VENV=/vev
Usage example
from autopytic.tools.wrapper import Wrapper
import requests
logfile = "log.txt"
class Robot:
@Wrapper.register_event(logfile=logfile, description="Send requests to get scrapping page")
def get_page(self, url):
r = requests.get(url)
self.process_and_response(r)
@Wrapper.register_event(logfile=logfile, description="Try to scrap something and return value")
def process_and_response(self, request):
## some processing
return request.status_code
@Wrapper.register_event(logfile=logfile, description="Say hello")
def say_hello(self):
return 'hello'
def run(self):
self.say_hello()
self.get_page("https://www.google.pl/")
r = Robot()
r.run()
Console output
Debug mode console output
Tips
Error handling
ERROR_RAISE=false # Wrapper will not return any exception after a failed action easy to debug step actions
ERROR_RAISE=true # Wrapper will return exception after a failed action
Loop handling
If you want to read the code based on loops easier, use in_loop (default false):
@Wrapper.register_event(logfile=logfile, description="Say hello", in_loop=True)
def say_hello():
return 'hello'
Email reports
Auto-logging
FAIL | 2021-03-18 20:01:19.479666 | say_hello | (<__main__.Robot object at 0x105d20460>,) | Say hello | - ms | unsupported operand type(s) for +: 'int' and 'str'
PASS | 2021-03-18 20:01:19.789123 | process_and_response | (<__main__.Robot object at 0x105d20460>, <Response [200]>) | Try to scrap something and return value | 0.0019073486328125ms | -
PASS | 2021-03-18 20:01:19.789445 | get_page | (<__main__.Robot object at 0x105d20460>, 'https://www.google.pl/') | Send requests to get scrapping page | 307.56616592407227ms | -
Auto-documentation
To make auto-documentation file add to the end of the script:
Wrapper.build_docs()
Output
Step 0 use function say_hello to do Say hello
Step 1 use function get_page to do Send requests to get scrapping page
Step 2 use function process_and_response to do Try to scrap something and return value
Code coverage
To check code coverage use in main directory
python3 -m autopytic coverage
Output:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.