rufus777 Posted January 26, 2011 Share Posted January 26, 2011 import os #Pidgin-2.7.9 HTTP os.system("wget http://sourceforge.net/projects/pidgin/files/Pidgin/2.7.9/pidgin-2.7.9.exe") #Spotify HTTP os.system("wget http://download.spotify.com/Spotify%20Installer.exe") #Pidgin-2.7.9 Install os.system("pidgin-2.7.9.exe") #Spotify Install os.system("spotify installer.exe") <------------- 'spotify' is not recognized as an internal or external command, operable program or batch file. How should I use "(space)" in os.system??? Quote Link to comment Share on other sites More sharing options...
Jason Cooper Posted January 26, 2011 Share Posted January 26, 2011 Assuming you are using a version of python beyond 2.5 you can, and should, use the subprocess.call instead of the os.system routine. Quote Link to comment Share on other sites More sharing options...
rufus777 Posted January 26, 2011 Author Share Posted January 26, 2011 Assuming you are using a version of python beyond 2.5 you can, and should, use the subprocess.call instead of the os.system routine. hehe, thanks! Quote Link to comment Share on other sites More sharing options...
sablefoxx Posted January 27, 2011 Share Posted January 27, 2011 (edited) You shouldn't make system calls if possible (they're evil), it's actually easy to download files in pure python. Heres a quick example; import urllib from subprocess import Popen path = 'C:\\file.exe' # Local path url = 'http://remote-server.com/file.exe' # Remote path connection = urllib.urlopen(url) remoteFile = connection.read() connection.close() try: localFile = open(path, 'w') localFile.write(remoteFile) localFile.close() Popen(path) # Execute whatever "path" points to except IOError: print '***** OMFG ERROR: Location is not writable %s *****\n' % path Using sys.argv you can even make the 'url' a command line argument. Edited January 27, 2011 by sablefoxx Quote Link to comment Share on other sites More sharing options...
P@c_M@n Posted February 9, 2011 Share Posted February 9, 2011 You shouldn't make system calls if possible (they're evil), it's actually easy to download files in pure python. Heres a quick example; import urllib from subprocess import Popen path = 'C:\\file.exe' # Local path url = 'http://remote-server.com/file.exe' # Remote path connection = urllib.urlopen(url) remoteFile = connection.read() connection.close() try: localFile = open(path, 'w') localFile.write(remoteFile) localFile.close() Popen(path) # Execute whatever "path" points to except IOError: print '***** OMFG ERROR: Location is not writable %s *****\n' % path Using sys.argv you can even make the 'url' a command line argument. Just a suggestion, but instead of using all that code with urllib.urlopen() couldn't you just use urllib.urlretrieve() to grab the file instead? I tried your code on a picture and it jumbled up all the pixels. So this is what i came up with import urllib path="C:\\file.exe" #local path url="http://www.example.com/file.exe" #remote path urllib.urlretrieve(url,path) It seems a lot simpler just to do this instead. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.