0

I want my program to open iTunes during runtime. How do I implement this ? I looked around for answers but didn't get any concrete complete answers. Till now, all I know is I could use the os module and then call the os.system() function to open iTunes. If this is right, what goes into the brackets ? I have a Mac OS X machine.

Shonu93
  • 846
  • 1
  • 10
  • 19

4 Answers4

0

This should be able to help you.

From the article linked above...

import sys, string, os, arcgisscripting
os.chdir( 'c:\\documents and settings\\flow_model' )
os.system( '"C:\\Documents and Settings\\flow_model\\flow.exe"' )
Community
  • 1
  • 1
Mark
  • 418
  • 1
  • 4
  • 13
0

Use subprocess.call() if you want to simply run an executable.

os.system() run the command in a subshell, which generates an unnecessary extra process and slightly different behavior depending on the operating system/console used (for example cmd.exe have different escaping than bash)

KurzedMetal
  • 12,540
  • 6
  • 39
  • 65
0

One straightforward way to do this on Mac OS X will be to use the open command:

os.system("open -a iTunes")

There are undoubtedly other ways of doing this (e.g, using the Cocoa/Python bridge), but this is the simplest.

  • Hey thanks ! Worked like a charm. What would I need to input if I want to enter a particular song (say x.mp3) through iTunes ? – Shonu93 Aug 30 '13 at 16:39
0

Read subprocess, is better than os.system in your case.

Subprocess module: http://docs.python.org/2/library/subprocess.html

Black_Ram
  • 343
  • 5
  • 9
  • 19