Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> Getting sys.argv using embedded jython


Copy link to this message
-
Re: Getting sys.argv using embedded jython
Thanks Daniel. I will get a build of trunk and test as well.

On Jun 19, 2012, at 4:53 PM, "Daniel Dai" <[EMAIL PROTECTED]> wrote:

> Yes, I can see this. However, trunk runs fine for me. I don't yet know why
> was that.
>
> Daniel
>
> On Mon, Jun 18, 2012 at 2:52 PM, Duckworth, Will <[EMAIL PROTECTED]>wrote:
>
>> I tried a couple other versions.
>>
>> This will work:
>>
>> #!/usr/bin/python
>>
>> import sys
>>
>> from org.apache.pig.scripting import Pig
>>
>> if __name__ == '__main__':
>>   print sys.argv[1]
>>
>>
>> This will not:
>>
>> #!/usr/bin/python
>>
>> import sys
>>
>> from org.apache.pig.scripting import Pig
>>
>> @outputSchema("ip_address:long")
>> def Ip2Num(ip):
>>   pass
>>
>> if __name__ == '__main__':
>>   print sys.argv[1]
>>
>>
>>
>>
>> Will Duckworth  Senior Vice President, Software Engineering  | comScore,
>> Inc.(NASDAQ:SCOR)
>> o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:[EMAIL PROTECTED]
>>
>> .....................................................................................................
>> -----Original Message-----
>> From: Duckworth, Will [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, June 18, 2012 5:19 PM
>> To: [EMAIL PROTECTED]
>> Subject: Getting sys.argv using embedded jython
>>
>> This has to be something obvious but I can’t seem to get python parameters
>> once I add in a main().  Thanks.
>>
>> ~/pig-0.10/bin/pig pytest.py haha
>> ...
>> 2012-06-18 17:11:50,312 [main] INFO
>> org.apache.pig.scripting.jython.JythonScriptEngine - created tmp
>> python.cachedir=/tmp/pig_jytho
>> n_9083561197267275440
>> haha
>>
>> ~/pig-0.10/bin/pig pytest2.py haha
>> ...
>> 2012-06-18 17:13:25,609 [main] INFO
>> org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
>> UDF: main
>> 2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121:
>> Python Error. Traceback (most recent call last):
>> File "/home/wduckworth/pytest2.py", line 11, in <module>
>>   print sys.argv[1]
>> IndexError: index out of range: 1
>>
>> * * * pytest.py
>>
>> #!/usr/bin/python
>>
>> import sys
>> from org.apache.pig.scripting import Pig
>> print sys.argv[1]
>>
>> * * * pytest2.py
>>
>> #!/usr/bin/python
>>
>> import sys
>> from org.apache.pig.scripting import Pig
>>
>> def main():
>>   print sys.argv[1]
>>
>> if __name__ == '__main__':
>>   main()
>>
>>
>>
>>
>> Will Duckworth Senior Vice President, Software Engineering | comScore,
>> Inc. (NASDAQ:SCOR)
>>
>> o +1 (703) 438-2108 | m +1 (301) 606-2977 | [EMAIL PROTECTED]
>> <mailto:[EMAIL PROTECTED]>
>>
>>
>> ...........................................................................................................
>>
>> Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral
>> measurement
>> www.comscore.com/MobileMetrix<
>> http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>
>>
>>
>>