Created
July 26, 2016 04:10
-
-
Save Dref360/21a43ca9a149011cfc9ef8239a2be20f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" | |
Simple alarm clock to be awaken to the sound of your choice | |
""" | |
import datetime as dt | |
import time | |
import webbrowser | |
import argparse | |
import sys | |
from dateutil.relativedelta import relativedelta | |
def parse(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-time",dest="time",type=str,default="6:30") | |
parser.add_argument("-url",dest="url",type=str,default="https://www.youtube.com/watch?v=7YIrHphl_1g") | |
return parser.parse_args() | |
def alarm_clock(hour,minute): | |
a = dt.datetime.now() | |
alarm = dt.datetime(a.year,a.month,a.day,hour,minute) | |
if alarm < a: | |
alarm += relativedelta(days=1) | |
print alarm | |
time.sleep((alarm-a).total_seconds()) | |
webbrowser.open(url, new=0, autoraise=True) | |
option = parse() | |
hour,minute = option.time.split(":")[:2] | |
url = option.url | |
alarm_clock(int(hour),int(minute)) | |
time.sleep(99999) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment