A Simple Python Alarm Clock | TechSource


A Simple Python Alarm Clock

vía A Simple Python Alarm Clock | TechSource.

 

Problem: You are all alone in a far away land and needed to wake up early the next day. The problem is, you forgot to bring any alarm clock. But, you brought a Linux-powered laptop computer with you. Say for example an Asus Eee PC.


Solution
: Most Linux distributions have Python installed out-of-the-box. All you need is this very simple Python alarm clock script:

import time
import os

not_executed = 1

while(not_executed):
dt = list(time.localtime())
hour = dt[3]
minute = dt[4]
if hour == 5 and minute == 45:
os.popen2(«open /Users/jun/shout.mp3»)
not_executed = 0

Happy Hacking! 🙂

Anuncio publicitario

Publicado el 16 diciembre 2010 en Programación, Python y etiquetado en . Guarda el enlace permanente. Deja un comentario.

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: