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

Discussion in 'Python' started by C. N. Desrosiers, Jun 16, 2013.

  1. 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
    C. N. Desrosiers, Jun 16, 2013
    #1
    1. Advertising

  2. Re: Using Python to automatically boot my computer at a specifictime and play a podcast

    On Sun, 16 Jun 2013 12:06:08 -0700, C. N. Desrosiers wrote:

    > 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?



    --
    Steven
    Steven D'Aprano, Jun 16, 2013
    #2
    1. Advertising

  3. Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Sun, Jun 16, 2013 at 3:06 PM, C. N. Desrosiers <>wrote:

    > 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.

    >
    > CND
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >




    --
    Joel Goldstick
    http://joelgoldstick.com
    Joel Goldstick, Jun 16, 2013
    #3
  4. Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Sun, Jun 16, 2013 at 3:22 PM, Steven D'Aprano <
    > wrote:

    > On Sun, 16 Jun 2013 12:06:08 -0700, C. N. Desrosiers wrote:
    >
    > > 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?
    >


    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!

    >
    >
    >
    > --
    > Steven
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >




    --
    Joel Goldstick
    http://joelgoldstick.com
    Joel Goldstick, Jun 16, 2013
    #4
  5. Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Jun 16, 2013, at 9:06 PM, C. N. Desrosiers <> 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 same functionalities.

    > Is this sort of thing possible in Python?


    Sure. But why bother? All at one's finger tip already...
    Petite Abeille, Jun 16, 2013
    #5
  6. C. N. Desrosiers

    Jason Swails Guest

    Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Sun, Jun 16, 2013 at 3:06 PM, C. N. Desrosiers <>wrote:

    > 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
    Jason Swails, Jun 16, 2013
    #6
  7. Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Sun, 16 Jun 2013 12:06:08 -0700 (PDT), "C. N. Desrosiers"
    <> declaimed the following:

    >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...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Jun 16, 2013
    #7
  8. Re: Using Python to automatically boot my computer at a specific timeand play a podcast

    On Mon, Jun 17, 2013 at 5:06 AM, C. N. Desrosiers
    <> wrote:
    > 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
    Chris Angelico, Jun 16, 2013
    #8
  9. Re: Using Python to automatically boot my computer at a specifictime and play a podcast

    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:


    On Jun 16, 2013, at 9:06 PM, C. N. Desrosiers <<mailto:>> 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...



    --
    http://mail.python.org/mailman/listinfo/python-list
    Lefavor, Matthew (GSFC-582.0)[MICROTEL LLC], Jun 17, 2013
    #9
  10. Re: Using Python to automatically boot my computer at a specifictime and play a podcast

    On 17-6-2013 15:24, inq1ltd wrote:
    > On Sunday, June 16, 2013 12:06:08 PM C. N. Desrosiers wrote:
    >
    >> 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?


    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
    Irmen de Jong, Jun 17, 2013
    #10
  11. Re: Using Python to automatically boot my computer at a specifictime and play a podcast

    On 2013-06-16, C. N. Desrosiers 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. 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.

    --
    Real (i.e. statistical) tennis and snooker player rankings and ratings:
    http://www.statsfair.com/
    Giorgos Tzampanakis, Jun 17, 2013
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    364
  2. John Salerno
    Replies:
    2
    Views:
    303
    John Salerno
    Apr 6, 2006
  3. Replies:
    1
    Views:
    321
    hubritic
    Sep 26, 2006
  4. Ro
    Replies:
    3
    Views:
    354
    Lawrence Kirby
    Jan 26, 2005
  5. =?Utf-8?B?cmRoNTM=?=

    Computer does not boot

    =?Utf-8?B?cmRoNTM=?=, Jul 6, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    441
    RobinS
    Jul 12, 2007
Loading...

Share This Page