This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create one log file per module using __file__ for the main filename. | |
""" | |
from log2d import Log, Path | |
if __name__ == '__main__': | |
log = Log(Path(__file__).stem, to_file=True).logger | |
# TEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create ONE log, shared by all instances of a CLASS | |
""" | |
from log2d import Log | |
class MyAbstractClass: | |
def __init__(self, name, *args, **kwargs): | |
params = {"fmt": Log.presets["name_and_time"]} | |
self.log = Log.index.get(name) or Log(name, **params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create individual logs for every INSTANCE of a class | |
""" | |
from log2d import Log | |
class MyClass: | |
def __init__(self, name): | |
params = {"fmt": Log.presets["name_and_time"]} | |
self.log = Log.index.get(name) or Log(name, **params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Rename this file to config.py once completed. | |
Add config.py to .gitignore etc before including in Github or other repository. | |
""" | |
PHONE_ID = "111111111111111" # 15 digit numerical string | |
CONTACTS = [ | |
"447919xxxxxx", # Up to five contact numbers | |
"447940xxxxxx", # Numerical strings starting with country code | |
"44208xxxxxxx", # No leading 0 between country code and area code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from cleverdict import CleverDict | |
from config import CONTACTS, ENDPOINT, HEADERS, TEST_MESSAGE, TEST_URL | |
class Whatsapp: | |
def __init__(self, contact="", content_type="", autosend=True, **kwargs): | |
""" | |
Prepare and optionally execute a request to the Whatsapp Cloud API for sending a message to a pre-approved or opted-in) Whatsapp contact. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def slideshow(cycles=3, interval=5): | |
#TODO: Make non blocking so that effect continues to cycle in parallel | |
for cycle in range(cycles): | |
for source in IMAGES: | |
image = create_full_deck_sized_image(deck, source) | |
for k in range(deck.key_count()): | |
key_image = crop_key_image_from_deck_sized_image(deck, image, k) | |
deck.set_key_image(k, key_image) | |
time.sleep(interval) |