Faranak, I haven't tried the code yet, but I think the problem is you call python code like this:
python CARVE_KML_Extractor.py I think using ./ tells the she'll to run it. The shell doesn't understand how to import modules. Try using python instead of the ./ and let me know how it works. Cameron On Apr 15, 2011 9:24 PM, "Davoodi, Faranak (388J)" < [email protected]> wrote: > Due to having a problem with my eyes, I was hesitant to go through this > documentation. I finally endured the pain(literally) and went through it. > Apparently those lines are for running that mp3 java code. Please answer > my question below: > > 1. > The python extractor I have generates the file bellow: > > <?xml version="1.0" encoding="UTF-8"?> > <cas:metadata xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas"> > <keyval> > <key>MasterQualityFlag</key> > <val>Good</val> > </keyval> > <keyval> > <key>ProcessingLevel</key> > <val>L1</val> > </keyval> > </cas:metadata> > > > I do: chmod +x script.py however, it when I try to run it as ./script.py. > It wouldn't and complains about : > ./CARVE_KML_Extractor.py: line 20: import: command not found > ./CARVE_KML_Extractor.py: line 21: import: command not found > ./CARVE_KML_Extractor.py: line 22: import: command not found > from: can't read /var/mail/xml.dom.minidom > However if I simply run like: python script.py [inputProduct][outputdir], > it works fine. Do I need to be able to run that python script like > ./script.py to be able to use it as an metadata extractor. > > Cameron, since this is your code. Would you help me and see what you can > do to make it run like: ./script.py. > > 2. I noticed that in the link > http://oodt.apache.org/components/maven/curator/user/basic.html, the > python code you just specify the input file: > ./mp3PythonExtractor.py /usr/local/staging/products/mp3/Bach-SuiteNo2.mp3. > Since I need to integrate this to my cas-pge crawler, and it needs to > perform this metadata extraction on the product just generated, what > exactly I need to pass as argument in terms of [inputFile][outmetpath]? > > Thanks, > Faranak > > > > > On 4/15/11 7:51 PM, "Davoodi, Faranak (388J)" > <[email protected]> wrote: > >>Based on the document you have sent me, for the simple python script that >>runs like this: kml.python [input][outputmet]. I need to have the config >>file like: >> >> >><?xml version="1.0" encoding="UTF-8"?> >><cas:externextractor xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas"> >> <exec workingDir=""> >> >><extractorBinPath>/usr/local/extractors/mp3extractor/mp3PythonExtractor.py >>< >>/extractorBinPath> >> <args> >> <arg isDataFile="true"/> >> </args> >> </exec> >></cas:externextractor> >> >> >>Do I have to specify the working directory like the first line: <exec >>workingDir="">. Because I don't see that line in the peate's sample file. >>Also I see the python extractor has these lines that mines doesn't. Is >>this the reason my python script doesn't get run? The python file I have >>simply parses the file and generates the output met. >> >> >>cmd = "java -jar /Users/woollard/Desktop/extractors/mp3extractor/" >>cmd += "tika-app-0.5-SNAPSHOT.jar -m "+fullPath+" | awk -F:" >>cmd += " 'BEGIN {print \"<cas:metadata xmlns:cas=" >>cmd += "\\\"http://oodt.jpl.nasa.gov/1.0/cas\\\">\"}" >>cmd += " {print \"<keyval><key>\"$1\"</key><val>\"substr($2,2)\"" >>cmd += "</val></keyval>\"}' > "+fileName+".met" >> >> >> >> >> >> >>#!/usr/bin/python >> >>import os >>import sys >> >>fullPath = sys.argv[1] >>pathElements = fullPath.split("/"); >>fileName = pathElements[len(pathElements)-1] >>fileLocation = fullPath[:(len(fullPath)-len(fileName))] >>productType = "MP3" >> >>cmd = "java -jar /Users/woollard/Desktop/extractors/mp3extractor/" >>cmd += "tika-app-0.5-SNAPSHOT.jar -m "+fullPath+" | awk -F:" >>cmd += " 'BEGIN {print \"<cas:metadata xmlns:cas=" >>cmd += "\\\"http://oodt.jpl.nasa.gov/1.0/cas\\\">\"}" >>cmd += " {print \"<keyval><key>\"$1\"</key><val>\"substr($2,2)\"" >>cmd += "</val></keyval>\"}' > "+fileName+".met" >> >>os.system(cmd) >> >>f = open(fileName+".met", 'a') >>f.write('<keyval><key>ProductType</key><val>'+productType) >>f.write('</val></keyval>\n<keyval><key>Filename</key><val>') >>f.write(fileName+'</val></keyval>\n'<keyval><key>FileLocation') >>f.write('</key><val>'+fileLocation+'</val></keyval>\n') >>f.write('</cas:metadata>') >>f.close() >> >> >> >> >>On 4/15/11 6:22 PM, "Davoodi, Faranak (388J)" >><[email protected]> wrote: >> >>>Thanks Brian. The document was actually very helpful. >>> >>>--Faranak >>> >>>From: holenoter <[email protected]<mailto:[email protected]>> >>>Reply-To: "[email protected]<mailto:[email protected]>" >>><[email protected]<mailto:[email protected]>> >>>Date: Fri, 15 Apr 2011 14:19:04 -0700 >>>To: "[email protected]<mailto:[email protected]>" >>><[email protected]<mailto:[email protected]>> >>>Cc: "[email protected]<mailto:[email protected]>" >>><[email protected]<mailto:[email protected]>> >>>Subject: Re: CAS_PGE's ExternExtractorMetWriter config file >>> >>>http://oodt.apache.org/components/maven/metadata/user/basic.html >>> >>>On Apr 15, 2011, at 02:09 PM, "Davoodi, Faranak (388J)" >>><[email protected]<mailto:[email protected]>> >>>wrote: >>> >>>I have a couple of out put products that I am trying to extract extra >>>metadata and add them to the final .met files. Here is how I run my >>>files: >>> >>>Python [someBinDir]/ncdump [PathToPythonExtractor]/extractor1.py >>>[PathToOutputProduct]/productName [PathToOutPutMet] >>> >>>How should I write the extern extractor config file: >>> >>> >>><?xml version="1.0" encoding="UTF-8"?> >>> >>><cas:externextractor xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas"> >>> >>><exec metFileExt="tmp.cas"> >>><extractorBinPath >>>envReplace="true">[PathToPythonExtractor]</extractorBinPath> >>><args> >>><arg>python</arg> >>><arg>[someBinDir]/ncdump</arg> >>> >>><arg>extractor1.py</arg> >>> >>><arg isDataFile="true"/> >>><arg>-reader</arg> >>><arg>Rtp3FileReader</arg> >>><arg>--metFile</arg> >>><arg>-toFile</arg> >>><arg isMetFile="true"/> >>><arg>-writer</arg> >>><arg>XmlCasWriter</arg> >>></args> >>></exec> >>> >>> >>></cas:externextractor> >>> >>>Thanks, >>>Faranak >> >
