Solved

Need help python script

Posted on 2011-03-01
3
495 Views
Last Modified: 2012-05-11
Hey Guys,

I have another question but the title is wrong and it has sort of gone off topic.

I have a script, that is called by another python script to PostProcess some files. It uses a filenamepath that is parsed from the first script.

My script (the PostProcess script) is:
import os
import sys

#path to file from the first argument (no checking)
fname = sys.argv[1]
#fname = r'E:\\TV Shows\\How I Met Your Mother\\Season 6\\How.I.Met.Your.Mother.S06E18.720p.HDTV.X264-DIMENSION.mkv'

# Now split the path to the directory and the bare name (better to say it 
# splits the last element of the path and it does not care whether it is 
# a file name or a subdirectory name.
path, barename = os.path.split(fname)
print path
print barename

parent = os.path.normpath(os.path.join(path, '..'))

print "parent directory:", parent

# Create file, delete and recreate it if it exists. This will
# change the date modified status of the Show Name folder
# so you can view your show list by date order.
if os.path.isfile(parent + "/" + 'DateMarker.log'):
    os.remove(parent + "/" + 'DateMarker.log')
logfile = open(parent + "/" + 'DateMarker.log', 'w')
logfile.write('Episode ' + fname + ' has been created. This is a marker file, to change the date modified status of the show name.')
logfile.close

Open in new window


The first script that runs it, spits out this error:
Mar-02 11:44:50 INFO     POSTPROCESSER :: Unable to run extra_script: [Error 193] %1 is not a valid Win32 application
Mar-02 11:44:50 INFO     POSTPROCESSER :: Executing command ['DateM.py', u'E:\\TV Shows\\The Mentalist\\Season 01\\the.mentalist.s01e10.720p.hdtv.x264-ctu.mkv', u'E:\\Complete\\The Mentalist S01E10 720p HDTV x264 CTU\\the.mentalist.s01e10.720p.hdtv.x264-ctu.mkv', '82459', '1', '10', '2008-12-16']

Open in new window


I'm not sure if it is a problem with my python script, or if it's not being run properly by the first.

Can you see anything wrong with my script?

Cheers.
0
Comment
Question by:chipped
  • 2
3 Comments
 

Author Comment

by:chipped
Comment Utility
This
"The first script runs it, spits out this error:"

should have said

"The first that script runs it, spits out this error:"

Just so you don't get confused.
0
 

Author Comment

by:chipped
Comment Utility
Bloody hell, this site needs a edit button.

Disregard the comment above this, lol.

This
"The first script runs it, spits out this error:"

Should have said

"The first script that runs it, spits out this error:"
0
 
LVL 28

Accepted Solution

by:
pepr earned 500 total points
Comment Utility
Have a look at your earlier question at point http:Q_26852254.html#a35014986 and upper.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now