Using Python to automatically boot my computer at a specific time andplay a podcast

C

C. N. Desrosiers

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python?

Thanks in advance.

CND
 
S

Steven D'Aprano

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of
alarm. I'd like to write a program that boots my computer at a specific
time,

If your computer is turned off, how is the program supposed to run?
 
J

Joel Goldstick

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm.
I'd like to write a program that boots my computer at a specific time,
loads iTunes, and starts playing a podcast. Is this sort of thing possible
in Python?

Thanks in advance.

Since Macs run a version of Unix underneath you can write a cron job to get
things started at a specific time. I'm not sure about the iTunes
interface. Have you researched to see if it has and API? If it does,
likely python could handle that.
 
J

Joel Goldstick

On Sun, Jun 16, 2013 at 3:22 PM, Steven D'Aprano <
If your computer is turned off, how is the program supposed to run?

I was thinking maybe it could in some sleep mode that still ran cron jobs.
but I am totally guessing that. If its OFF off then you might need another
computer attached to a robot arm that could push the on button first!
 
P

Petite Abeille

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast.

Under preferences, take a look at Energy Saver -> Power Adapter -> Schedule -> Start up or wake.

Alternatively, the command line utility pmset allows one to access the same functionalities.
Is this sort of thing possible in Python?

Sure. But why bother? All at one's finger tip already...
 
J

Jason Swails

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm.
I'd like to write a program that boots my computer at a specific time,
loads iTunes, and starts playing a podcast. Is this sort of thing possible
in Python?

Python cannot do this by itself, as has already been mentioned.

If you're using a Mac, you can schedule your computer to turn on (and/or
off) using System Preferences->Energy Saver->Schedule...

Then run a Python script in a cron job.

In fact, you could do this in bash ;)

HTH,
Jason
 
D

Dennis Lee Bieber

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python?
Uhm... It can't run a program until after it has been booted.

And if you leave the system up and running, I'm sure the OS has some
sort of scheduled task system (probably a version of cron) in which you can
define what should happen when...
 
C

Chris Angelico

Hi,

I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python?


Python *on the system itself* cannot do this. However, if the BIOS
features aren't enough (eg if you want more flexibility), there's one
option to explore. See if your Macbook has Wake-On-LAN support; with
that, you could have a Python script *on a different machine* send a
magic packet that wakes your target. However, this isn't a Python
question, it's a systems administration one. (The very specific
question "How can I trigger wake-on-LAN from a Python program" would
be a Python question (obviously!), but that's only a tiny part of your
problem.)

ChrisA
 
L

Lefavor, Matthew (GSFC-582.0)[MICROTEL LLC]

And as for launching iTunes and playing a Podcast, you should take a look at AppleScript. AppleScript is designed specifically for running and controlling Mac OS X applications—iTunes among them. (I once wrote a script to sync my iTunes play counts from last.fm, for example.)

You might also look at the Automator program (I guess it's still included on most Macs). It does mostly the same thing as Applescript (automate Mac processes) but it's graphical and doesn't do quite as much.

-MCL

On Jun 16, 2013, at 3:44 PM, Petite Abeille wrote:



I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast.

Under preferences, take a look at Energy Saver -> Power Adapter -> Schedule-> Start up or wake.

Alternatively, the command line utility pmset allows one to access the samefunctionalities.

Is this sort of thing possible in Python?

Sure. But why bother? All at one's finger tip already...
 
I

Irmen de Jong

You can use the osascript utility to send commands to itunes, and invoke it from Python
like this:

import subprocess
listname = "My Playlist"
subprocess.call(["osascript", "-e", "tell application \"iTunes\" to play playlist
\"{0}\"".format(listname)])

But that seems overkill (using Python to use Applescript to control iTunes)...

Irmen
 
G

Giorgos Tzampanakis

I'm planning to buy a Macbook Air and I want to use it as a sort of
alarm. I'd like to write a program that boots my computer at a specific
time, loads iTunes, and starts playing a podcast. Is this sort of thing
possible in Python?

I would suggest leaving your computer on and using the sched and
subprocess modules of the standard library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top