Hey all,

Trying to execute a command line from python. Here's some code:

class EncodeJob:
    def __init__(self,asset,recipe):
        self.asset = asset
        self.recipe = recipe
        self.original = self.asset.fullPath
        self.stdout = None
        self.stderr = None
        self.flv = os.path.normpath(self.recipe.configs['Flv Path'] + '/' + self.asset.filename.split('.')[0] + '.flv')
        self.thumb = os.path.normpath(self.recipe.configs['Thumb Path'] + '/' + self.asset.filename.split('.')[0] + '.jpg')
        ffmpeg_line = '"%s" -i "%s" %s "%s"' %(recipe.ffmpeg,self.original,asset.makeStr(self.recipe.configs),self.flv)
        [B]self.command = subprocess.Popen(ffmpeg_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)[/B]
    def encode(self):
        self.stdout,self.stderr = self.command.communicate()
        if os.path.exists(self.flv):
            return self.flv
        else:
            return "ERROR"
    def show_output(self):
        #if self.stdout and self.stderr:
        return """Standard Out:
%s
%s
Standard Error
%s""" %(self.stdout,Slumdog.bar(),self.stderr)
        #else:
            #return "Nothing to show"
    def cut_thumb(self):
        if os.path.exists(self.flv):
            cut_thumb(self.flv,self.thumb,self.recipe.configs,self.recipe.ffmpeg)
            if os.path.exists(self.thumb):
                return self.thumb
            else:
                return "ERROR"
        else:
            print "Flv does not exist, cannot cut thumb."
    def __str__(self):
        s = str(self.asset)
        return s

I put in bold the line that's throwing this error:

Traceback (most recent call last):
File "C:\Documents and Settings\zhobesh\Desktop\Thumb Cutter\cut_thumbs.py", line 12, in <module>
job = Casablanca.EncodeJob(asset,recipe)
File "\\carpenter\pylib\Casablanca.py", line 40, in __init__
self.command = subprocess.Popen(ffmpeg_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
File "C:\Python26\lib\subprocess.py", line 595, in __init__
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 804, in _execute_child
startupinfo)
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect

Here's my theory: I have my pylib set as a shared directory on shared computer, and that's screwing with the subprocess? I'm stumped.

Any and all theories/ideas/help is appreciated.

Thanks,

zac

Maybe as a sanity check print out the contents of ffmpeg_line before calling the subprocess to make sure you've actually constructed the proper system call.

Also, the shared computer... is it a different platform? What is the purpose of that setup? I could imagine if you were running a script on a linux box with your version of PYthon that is installed on a Windows machine you'd run into many, many problems.

Turned out to be I was passing bad stuff in ffmpeg_line (backslashes and whatnot). Figured it out when it worked when I called it in a command prompt but not when I just ran the script itself.

Durrrr.

Thanks for the reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.