#jython IRC Log (v0.9)

Index

IRC Log for 2011-12-02

Timestamps are in GMT/BST.

[0:11] * plankton (~peretto@187.54.10.106) Quit ()
[0:41] * KayT3 (~KayT3@63.84.81.41) Quit (Ping timeout: 244 seconds)
[1:34] * shashank (~shashank@ucb-np2-97.colorado.edu) Quit (Quit: Leaving.)
[1:36] * shashank (~shashank@ucb-np2-97.colorado.edu) has joined #jython
[2:20] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) Quit (Quit: clajo04_)
[3:17] * shashank (~shashank@ucb-np2-97.colorado.edu) Quit (Ping timeout: 244 seconds)
[3:30] * G3n3r0 (~G3n3r0@h-68-167-71-56.nycmny83.dynamic.covad.net) Quit (Quit: Leaving)
[4:11] * SinZ|offline is now known as SinZ
[5:58] * shashank (~shashank@174-29-75-118.hlrn.qwest.net) has joined #jython
[6:26] <SinZ> Lets say I had a folder called API, and in that was the src code for a .jar
[6:26] <SinZ> How would I import a .java from within the src folder
[6:27] <agronholm> you have to compile them first
[6:27] <SinZ> so it'll need to be API.jar
[6:27] <agronholm> you have to compile them first, packaging to a jar or not doesn't matter
[6:28] <SinZ> brb
[7:02] * Oti (~ohumbel@adsl-89-217-59-220.adslplus.ch) Quit (Quit: Oti)
[7:18] * shashank (~shashank@174-29-75-118.hlrn.qwest.net) Quit (Ping timeout: 244 seconds)
[7:50] * stakkars_ (~tismer@p5DDB7E68.dip.t-dialin.net) Quit (Quit: schnarch)
[8:11] * Oti (5390f2dc@gateway/web/freenode/ip.83.144.242.220) has joined #jython
[9:24] <SinZ> so, how do you import a Folder (which contains more folders which in them have .class files and more folders)
[9:25] <agronholm> you don't import Folders
[9:25] <agronholm> sinz, seriously, you really should learn the language basics first before trying to work on a practical project
[9:25] <SinZ> packaging to a jar or not doesn't matter
[9:26] <agronholm> in python you import packages and modules
[9:26] <agronholm> a package is a directory with __init__.py in it
[9:26] <agronholm> in java, however, things are a little different
[9:26] <agronholm> in Java you import classes
[9:27] <agronholm> sinz, believe me when I say you're in way over your head
[9:27] <SinZ> python, you can do from folder.file import class
[9:29] <agronholm> yes, but "folder" needs to have __init__.py in it
[9:30] <SinZ> can you do "from folder.folder.folder.file import class" for importing a java .class
[9:31] <agronholm> yes
[11:19] * wainersm (~wainersm@201.82.225.3) has joined #jython
[11:50] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) has joined #jython
[11:57] * juneau001_ (~juneau@50-103-20-201.dklb.il.frontiernet.net) has joined #jython
[11:59] * juneau001 (~juneau@50-103-41-145.dklb.il.frontiernet.net) Quit (Ping timeout: 244 seconds)
[11:59] * juneau001_ is now known as juneau001
[12:02] * RichardLynch (~RichardLy@c-67-162-103-133.hsd1.il.comcast.net) has joined #jython
[12:05] <RichardLynch> foo = "whatever" is creating a Unicode string. I need to get that to be byte[] to send through this: http://grinder.sourceforge.net/g3/script-javadoc/net/grinder/plugin/http/HTTPRequest.html#POST%28java.lang.String,%20byte[]%29
[12:05] <RichardLynch> I've tried a lot of things...
[12:06] <agronholm> RichardLynch: what version of Jython are you using?
[12:08] <RichardLynch> It's bundled with The Grinder, and I have no idea, and don't even know how to find out...
[12:08] <agronholm> can you get the interpreter running in interactive mode?
[12:09] <agronholm> if not, you could always import sys; print sys.version
[12:09] <agronholm> from the code
[12:10] <RichardLynch> 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[12:11] <agronholm> well foo = "whatever" does NOT create a unicode string
[12:11] <agronholm> foo = u"whatever" does that
[12:13] <RichardLynch> post_data = "subscribe=1" result = self.request.POST(self.url + 'learn/mod/forum/post.php', post_data.getBytes()) Jython exception: <type 'exceptions.AttributeError'>: 'unicode' object has no attribute 'getBytes'
[12:13] <RichardLynch> SOMETHING turned it into unicode along the way...
[12:14] <RichardLynch> post_data = post_data + "&foo=5" may have done it?
[12:14] <agronholm> no, that does not convert anything to unicode
[12:15] <agronholm> but str does not have a getBytes method either
[12:15] <agronholm> so what do you hope to accomplish with that code?
[12:15] <RichardLynch> Other than a lot more post_data = post_data + "xyz" there just isn't anything else IN the function...
[12:16] <RichardLynch> Send a POST to the URL, including a NAME like message[format] (message%5Bformat%5D after urlencoding) that NVPair won't do.
[12:16] <agronholm> but getBytes() will NEVER work
[12:17] <agronholm> since str nor unicode has that method
[12:17] <RichardLynch> I'm trying to use this method: http://grinder.sourceforge.net/g3/script-javadoc/net/grinder/plugin/http/HTTPRequest.html#POST%28java.lang.String,%20byte[]%29
[12:17] <agronholm> getBytes() only works on a String
[12:18] <agronholm> a Java String that is
[12:18] <RichardLynch> Or convince NVPair to accept a NAME with [] or %5B in it.
[12:18] <RichardLynch> I'm a PHP guy.... This un-holy marriage of Java and Python is driving me nuts :-p
[12:18] <agronholm> you need a byte[] right?
[12:18] <agronholm> from array import array
[12:18] <agronholm> some_bytes = array('b', some_str)
[12:19] <agronholm> RichardLynch: why is java even involved?
[12:19] <agronholm> jython is not exactly a speed demon
[12:19] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) Quit (Quit: clajo04_)
[12:20] <RichardLynch> Because my Testing Engineer uses the Grinder which uses Jython but we're load testing so trying to use native Java and ... Jeez, I dunno... I'm just stuck with this conversion problem to get the job done.
[12:22] <agronholm> well did that code help?
[12:22] <RichardLynch> "An integer is requried"
[12:22] <agronholm> ....what?
[12:22] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) has joined #jython
[12:22] <RichardLynch> Jython exception: <type 'exceptions.TypeError'>: an integer is required
[12:23] <RichardLynch> Ya got me...
[12:23] <agronholm> what are you feeding to it
[12:23] <agronholm> worked fine when I tested
[12:23] <agronholm> are you feeding a unicode string to it?
[12:25] <RichardLynch> Well, you claim that foo = "wahtever" isn't unicode, but then Jython errors tell me it is, so I don't know what I'm feeding to it, really...
[12:25] <agronholm> easy to find out: print type(variable)
[12:26] <RichardLynch> <type 'unicode'>
[12:26] <agronholm> your variable must be changing to unicode at some later point
[12:26] <agronholm> try right after assigning the value
[12:26] <RichardLynch> So, yes, it is type unicode.
[12:26] <agronholm> foo = "whatever"
[12:26] <agronholm> print type(foo)
[12:26] <RichardLynch> I have it right before the array('b', foo) call...
[12:26] <agronholm> what does it give you
[12:28] <RichardLynch> It's type str on the first assignment, type unicode after all the string appends, and unicode right before I try to typecast to array.
[12:28] <RichardLynch> Does %5B in the string force it to be unicode?
[12:28] <agronholm> no
[12:28] <agronholm> track down the exact statement which turns it into unicode
[12:29] <RichardLynch> D'oh: foo = foo + "&whatever=" + URLEncoder.encode(value, "UTF-8") is probably stupid when it's all ASCII data.
[12:30] <RichardLynch> I change UTF-8 to ascii and it STILL forces it to unicode.
[12:30] <RichardLynch> Bah! Have to run...
[12:30] <RichardLynch> THANKS!!!
[12:31] <agronholm> URLEncoder is Java?
[12:31] <agronholm> java Strings are turned to unicode
[12:31] <agronholm> since they are internally unicode too
[12:31] <agronholm> use the python urlencode function instead
[12:37] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) Quit (Quit: clajo04_)
[12:43] <SinZ> http://pastebin.com/KRJTJEfp
[12:45] <agronholm> sinz, yes?
[12:46] <SinZ> How would I port that java to jython
[12:46] <SinZ> (from this to self didnt work)
[12:46] <agronholm> well obviously your class has to implement that interface
[12:46] <agronholm> but you wouldn't know that since you have no experience in java
[12:53] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) has joined #jython
[12:55] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) Quit (Client Quit)
[12:58] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) has joined #jython
[13:01] * RichardLynch (~RichardLy@c-67-162-103-133.hsd1.il.comcast.net) Quit (Quit: RichardLynch)
[13:05] <SinZ> agronholm: and how to do that in python?
[13:05] <SinZ> jython*
[13:06] <agronholm> inherit from it and add the proper methods
[13:14] <SinZ> thanks
[13:41] * stakkars_ (~tismer@i59F76401.versanet.de) has joined #jython
[14:06] * SinZ is now known as SinZ|offline
[14:59] * enebo (~enebo@67-4-171-166.mpls.qwest.net) has joined #jython
[14:59] * enebo (~enebo@67-4-171-166.mpls.qwest.net) Quit (Client Quit)
[15:12] * KayT3 (~KayT3@63.84.81.41) has joined #jython
[15:29] * KayT3 (~KayT3@63.84.81.41) Quit (Quit: Leaving)
[15:30] * KayT3 (~KayT3@63.84.81.41) has joined #jython
[16:24] * shashank (~shashank@174-29-75-118.hlrn.qwest.net) has joined #jython
[16:37] * mcella (~mcella@212.165.33.54) has joined #jython
[17:39] * Oti (5390f2dc@gateway/web/freenode/ip.83.144.242.220) Quit (Quit: Page closed)
[17:43] * mcella (~mcella@212.165.33.54) Quit (Remote host closed the connection)
[17:46] * shashank (~shashank@174-29-75-118.hlrn.qwest.net) Quit (Ping timeout: 244 seconds)
[18:04] * shashank (~shashank@65-101-219-90.hlrn.qwest.net) has joined #jython
[18:20] * mcella (~mcella@212.165.33.54) has joined #jython
[18:35] * RichardLynch (~RichardLy@67-128-187-35.dia.static.qwest.net) has joined #jython
[18:39] <RichardLynch> Is there some sort of "macro" in Jython so I can write something like this def GET200( ANY_FUNCTION_SIGNATURE_WILDCARD_HERE): result = self.request.GET(WILDCARD); if (not result): raise RuntimeError("Failed to load: '"+self.request.url+"' HTTP Status: '"+result.getStatusCode()+"'")
[18:40] <RichardLynch> I'm getting a bit tired of re-typing the same 2 lines for non-200 responses :-p
[18:41] <RichardLynch> Clue bats for a better way most welcome... I'm just a PHP guy trapped in Jython :-)
[18:44] <RichardLynch> I don't really want to sub-class HTTPRequest with every single method signature for something this inane... Do I?
[18:45] <RichardLynch> agronholm: Thanks for help earlier. I must have been particularly stupid earlier, as the NVPair() worked just fine when I went back to basics. Sigh.
[18:46] <pjenvey> RichardLynch - def get200(*args, **kwargs)
[18:46] <pjenvey> read http://docs.python.org/tutorial/controlflow.html#arbitrary-argument-lists and the section above it
[18:46] <RichardLynch> pjenvey: Thanks!
[18:55] * stakkars_ (~tismer@i59F76401.versanet.de) Quit (Quit: schnarch)
[19:07] <RichardLynch> pjenvey: I've got it working, I think... Haven't tried keyword args, but it compiles with **kwargs in the parameter and arguments being passed on, so I suppose that bit is correct...
[19:08] <RichardLynch> One thing that I'm still a bit cloudy on in general is the first argument/param being 'self' all the time... Is that part of __call__ magic or just an inherent argument always pre-pended or what? I'm sure there's a page I was supposed to read, but finding said page without knowing the term for this...
[19:13] * stakkars_ (~tismer@g225044039.adsl.alicedsl.de) has joined #jython
[19:23] <RichardLynch> Since this: http://grinder.sourceforge.net/g3/script-javadoc/HTTPClient/URI.html has a toString method, why am I getting this: Jython exception: <type 'exceptions.TypeError'>: cannot concatenate 'str' and 'HTTPClient.URI' objects
[19:24] <RichardLynch> So many different classes just to represent * char[] or string or whatever...
[19:25] <RichardLynch> Ah well. I can typecast it with str() and make it work.
[19:49] * enebo (~enebo@67-4-171-166.mpls.qwest.net) has joined #jython
[19:49] * enebo (~enebo@67-4-171-166.mpls.qwest.net) Quit (Client Quit)
[20:00] * srcerer (~chatzilla@dns2.klsairexpress.com) Quit (Quit: ChatZilla 0.9.87 [Firefox 3.6.24/20111103063747])
[20:02] * srcerer (~chatzilla@dns2.klsairexpress.com) has joined #jython
[20:20] * stakkars_ (~tismer@g225044039.adsl.alicedsl.de) Quit (Quit: schnarch)
[20:26] * wainersm (~wainersm@201.82.225.3) Quit (Quit: Ex-Chat)
[20:28] * stakkars_ (~tismer@g225044039.adsl.alicedsl.de) has joined #jython
[20:38] * mcella (~mcella@212.165.33.54) Quit (Remote host closed the connection)
[20:44] * shashank (~shashank@65-101-219-90.hlrn.qwest.net) Quit (Ping timeout: 258 seconds)
[21:06] * RichardLynch (~RichardLy@67-128-187-35.dia.static.qwest.net) Quit (Quit: RichardLynch)
[21:10] * thegeekinside (~thegeekin@200-52-45-239.dynamic.axtel.net) has joined #jython
[21:22] * thegeekinside (~thegeekin@200-52-45-239.dynamic.axtel.net) Quit (Quit: Leaving...)
[21:24] * shashank1 (~shashank@ucb-np2-77.colorado.edu) has joined #jython
[21:33] * stakkars_ (~tismer@g225044039.adsl.alicedsl.de) Quit (Quit: schnarch)
[23:46] * SinZ|offline is now known as SinZ

Index

These logs were automatically created by JythonLogBot_ on irc.freenode.net using a slightly modified version of the Java IRC LogBot (github).