Operating System: Mac OS X Lion 10.7.3
Sublime Text 2 Version: 2181
I’m sorry, I’ve only just started programming and am switching over (or hoping to) from Textmate.
Sublime feels SO much better, but I haven’t managed to get anything like the “Run” option in Textmate (where I can just look at the output and stuff from the text editor itself. I can’t figure out what to modify in “Python.sublime-build” (if that’s even what I’m supposed to be editing).
If I use
#!/usr/bin/python
import os, sys, subprocess, shlex, re, string
print "Hello?"
then everything is good.
However, if I try:
#!/usr/bin/python
import os, sys, subprocess, shlex, re, string
def probe_file(filename):
print "Hello?"
[probe_file(f) for f in os.listdir('/foo/bar') if os.path.isfile(f) and not f.startswith('.')]
print "Hello World!"
nothing comes back; I just see “[Finished]”
Ditto with:
#!/usr/bin/python
import os, sys, subprocess, shlex, re, string
def probe_file(filename):
output = subprocess.Popen('ffprobe', '-show_format', '-pretty', '-loglevel', 'verbose', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print output
[probe_file(f) for f in os.listdir('.') if os.path.isfile(f) and not f.startswith('.')]
(Both print fine if I run them in terminal).
What’s (perhaps) curious to me is if I try to bypass this, I get weird errors from python that I don’t understand:
#!/usr/bin/python
import os, sys, subprocess, shlex, re, string
from subprocess import call
for f in os.listdir('foo/bar'): print f
for f in os.listdir('foo/bar'): output = subprocess.Popen('ffprobe', '-show_format', '-pretty', '-loglevel', 'verbose', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
output = output[0] + output[1]
print output
returns:
My File Name.avi
Traceback (most recent call last):
File "/Users/../test", line 5, in <module>
for f in os.listdir('/foo/bar'): output = subprocess.Popen('ffprobe', '-show_format', '-pretty', '-loglevel', 'verbose', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
[Finished]
All this code runs smoothly in Terminal.