Validates a --dates
argument in Python with the following possible formats:
- YYYYMMDD (eg. 20120515)
- YYYYMMDD-YYYYMMDD (eg. 20140115-20140315)
- yesterday
- today
To use this function, reference it in the argparse
setup:
# Ansible deployment playbook | |
--- | |
# ------------------------------------------------------------------------------------------------ | |
# Hosts to deploy to (set to all if you want to be able to just limit installation to specific | |
# hosts using the `--limit` arg to `ansible-playbook`. | |
# | |
- hosts: all | |
# ---------------------------------------------------------------------------------------------- | |
# Files containing additional variables | |
# |
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4]) |
Validates a --dates
argument in Python with the following possible formats:
To use this function, reference it in the argparse
setup:
#!/usr/bin/env python | |
from datetime import date, datetime, timedelta | |
import os | |
import sys | |
import jinja2 | |
script_name = os.path.basename(__file__) | |
def usage(): |
When driver.py
finishes running, email.send_email()
is executed. This is because in the driver, it is registered in the atexit
module:
import atexit
atexit.register(send_email)
which means that when the driver is finished and is about to exit, the send_email()
function will be the last thing that runs. In this example send_email()
simply prints that it's sending an email, but this is where you should actually email report_obj
out.
See this script in action.
include VERSION |
#!/bin/csh | |
# Get the name of this script | |
if ( $?_ ) then | |
# With tcsh the name of the file being sourced is available in | |
# $_. | |
set script_name = `basename $_` | |
else | |
# Fall back to $0 which, sometimes, will be the name of the |