示例#1
0
def main():
    # Exit early if any session with my_username is found.
    if any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
        return

    client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)

    # Phone numbers.
    my_number = '+xxx'
    number_of_boss = '+xxx'

    excuses = [
        'Locked out',
        'Pipes broke',
        'Food poisoning',
        'Not feeling well',
        'Flat tires',
        'Got robbed',
        'Lost wallet',
    ]

    try:
        # Send a text message.
        client.messages.create(
            to=number_of_boss,
            from_=my_number,
            body='Gonna work from home. ' + random.choice(excuses),
        )
    except TwilioRestException as e:
        # Log errors.
        with LOG_FILE_PATH.open('a') as f:
            f.write('Failed to send SMS: {}'.format(e))
        raise
示例#2
0
def main():
    # Skip on weekends.
    if datetime.date.today().weekday() in (0, 6,):
        return

    # Exit early if any session with my_username is found.
    if any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
        return

    client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)

    # Phone numbers.
    my_number = '+xxx'
    number_of_boss = '+xxx'

    excuses = [
        'Locked out',
        'Pipes broke',
        'Food poisoning',
        'Not feeling well',
    ]

    try:
        # Send a text message.
        client.messages.create(
            to=number_of_boss,
            from_=my_number,
            body='Gonna work from home. ' + random.choice(excuses),
        )
    except TwilioRestException as e:
        # Log errors.
        with LOG_FILE_PATH.open('a') as f:
            f.write('Failed to send SMS: {}'.format(e))
        raise
示例#3
0
def main():
    # Exit early if no sessions with my_username are found.
    if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
        return

    client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)

    # Phone numbers.
    my_number = '+xxx'
    her_number = '+xxx'

    reasons = [
        'Working hard',
        'Gotta ship this feature',
        'Someone f****d the system again',
    ]

    try:
        # Send a text message.
        client.messages.create(
            to=her_number,
            from_=my_number,
            body='Late at work. ' + random.choice(reasons),
        )
    except TwilioRestException as e:
        # Log errors.
        with LOG_FILE_PATH.open('a') as f:
            f.write('Failed to send SMS: {}'.format(e))
        raise
def main():
    # Skip on weekends.
    if datetime.date.today().weekday() in (0, 6):
        return

    # Exit early if no sessions with my_username are found.
    if not any(s.startswith(b"my_username ") for s in sh("who").split(b"\n")):
        return

    client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)

    # Phone numbers.
    my_number = "+xxx"
    her_number = "+xxx"

    reasons = ["Working hard", "Gotta ship this feature", "Someone f****d the system again"]

    try:
        # Send a text message.
        client.messages.create(to=her_number, from_=my_number, body="Late at work. " + random.choice(reasons))
    except TwilioRestException as e:
        # Log errors.
        with LOG_FILE_PATH.open("a") as f:
            f.write("Failed to send SMS: {}".format(e))
        raise
def main():
    # Exit early if no sessions with my_username are found.
    if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
        return

    client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)

    # Phone numbers.
    my_number = '+xxx'
    her_number = '+xxx'

    reasons = [
        'Working hard',
        'Gotta ship this feature',
        'Someone f****d the system again',
    ]

    try:
        # Send a text message.
        client.messages.create(
            to=her_number,
            from_=my_number,
            body='Late at work. ' + random.choice(reasons),
        )
    except TwilioRestException as e:
        # Log errors.
        with LOG_FILE_PATH.open('a') as f:
            f.write('Failed to send SMS: {}'.format(e))
        raise
示例#6
0
def main():
    # Exit early if no sessions with my_username are found.
    if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
        return

    time.sleep(17)
    conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR)
    conn.open()
    conn.expect([COFFEE_MACHINE_PROM])
    conn.write(COFFEE_MACHINE_PASS)

    conn.write('sys brew')
    time.sleep(24)

    conn.write('sys pour')
    conn.close()
def main():
    # Skip on weekends.
    if datetime.date.today().weekday() in (0, 6):
        return

    # Exit early if no sessions with my_username are found.
    if not any(s.startswith(b"my_username ") for s in sh("who").split(b"\n")):
        return

    time.sleep(17)

    conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR)
    conn.open()
    conn.expect([COFFEE_MACHINE_PROM])
    conn.write(COFFEE_MACHINE_PASS)

    conn.write("sys brew")
    time.sleep(64)

    conn.write("sys pour")
    conn.close()