def test_klaxon(title, subtitle, message): klaxon(title=title, subtitle=subtitle, message=message, sound=None) sp.run( f"klaxon " f'--title "{title}" ' f'--subtitle "{subtitle}" ' f'--message "{message}" ' f'--sound ""', shell=True, )
def deploy(c, profile=AWS_PROFILE, region=AWS_REGION, force=False, app=APP, stack=None): """Deploy CDK CloudFormation stack(s).""" if stack: c.run( f"cdk deploy --profile={profile} {stack}" + (" --require-approval never" if force else ""), pty=True, env={"AWS_DEFAULT_REGION": region}, ) klaxon(title=app, subtitle="deployed CDK stack") else: print("Please provide a stack to deploy")
async def handleMsg(self, messages: List[Dict], position: str) -> ActionFlow: for msg in messages: data = msg.get('data', {}) user = data.get('user', 'unknown user') text = data.get('text', '<invalid message>') encrypted = data.get('encrypted', False) if encrypted: text = decrypt(text, self.password) # We could extract a time and from the message too # We could display a channel klaxon( title=f'New message from Bavarde', # App name ? subtitle=f'From {user}', message=text, ) return ActionFlow.CONTINUE
def destroy(c, profile=AWS_PROFILE, region=AWS_REGION, force=False, app=APP, stack=None): """Tear-down CDK CloudFormation stack(s).""" responder = Responder(pattern="Are you sure you want to delete.*", response="y\n") if stack: c.run( f"cdk destroy --profile={profile} {stack}", pty=True, watchers=[responder] if force else [], env={"AWS_DEFAULT_REGION": region}, ) klaxon(title=app, subtitle="destroyed CDK stack") else: print("Please provide a stack to deploy")
def wrapper(c, *args, **kwargs): success = False failed_with_regular_exception = False try: func(c, *args, **kwargs) except Exception as e: klaxon(subtitle=f"{func.__name__}", message=f"failed: {repr(e)}") failed_with_regular_exception = True else: klaxon(subtitle=f"{func.__name__}", message="success") success = True finally: if not success and not failed_with_regular_exception: klaxon(subtitle=f"{func.__name__}", message=f"failed: catastrophically")
print("Device present at script start") connected_flag = True strikes = DEFAULT_STRIKES else: print("Device not present at script start") connected_flag = False strikes = 0 while True: time.sleep(10) output = scan_network() # Newly connected if output and not connected_flag: klaxon(title='Network Listener', message=f"{PERSON} has connected to the network") connected_flag = True strikes = DEFAULT_STRIKES # Not on network but still in grace period, deduct strike elif not output and connected_flag and (strikes > 0): strikes -= 1 # Connected now and before, resets strikes elif output and connected_flag: strikes = DEFAULT_STRIKES # Not connected and out of strikes. Setting to disconnected elif not output and connected_flag and (strikes == 0): klaxon(title='Network Listener', message=f"{PERSON} has disonnected from the network") connected_flag = False
def alert(_, title="airflow cdk", subtitle="task finished", message="complete"): """Send MacOS osascript notification.""" klaxon(title=title, subtitle=subtitle, message=message)