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
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=
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
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
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.