Frank Wierzbicki | 2 Jun 03:49
Picon
Gravatar

Re: Jython internals : AST?

On Fri, May 30, 2008 at 7:11 PM, rahul garg <whycode <at> gmail.com> wrote:
> Hi.
> I am not sure whether this message belongs here or in jython-dev but anyway
> here it goes :
>
> I am writing a Python-to-C compiler. The project is called unpython and is
> located here http://www.cs.ualberta.ca/~garg1/unpython/
> I am writing it in Java. For the frontend, I am currently using CPython's
> compiler module, dumping the AST into a file, then reading it back in Java.
> I was recommended to see if I can reuse portions of Jython instead. So my
> questions are :
> a) Where should I look in Jython ?
The asm branch uses this parser:
https://jython.svn.sourceforge.net/svnroot/jython/branches/asm

> b) I believe an ANTLR based frontend was being worked upon. Is it working
> and in Jython already?
You can find the grammars here:
https://jython.svn.sourceforge.net/svnroot/jython/branches/asm/grammar

> c) What kind of data structure is returned by Jython "frontend"? How
> similar/dissimilar are these to the ASTs returned by compiler module  of
> cpython 2.5?
The Jython frontend produces nodes that are generated from a version
of the Python asdl mechanism.  See here for that stuff:
https://jython.svn.sourceforge.net/svnroot/jython/branches/asm/ast

or see the generated files here:
https://jython.svn.sourceforge.net/svnroot/jython/branches/asm/src/org/python/antlr/ast

(Continue reading)

Frank Cohen | 4 Jun 07:34

Using Jython, XPath for SOAP services

Hi Jythonistas!

I needed to write a SOAP-based Web service to show off the SOAP  
testing capabilities for PushToTest TestMaker. I wanted to use XPath  
expressions to change the search expressions easily over time. I chose  
to use Jaxen and Xerces APIs. Figuring this out in Java wound up  
taking a long time - all those visits to change-compile-run-check  
land! So I broke out my trusty Jython (embedded in TestMaker) and  
wrote the following script.

I like example code. So I am posting this here to help anyone else  
that needs to do XPath expressions. Also, I figure that I will need  
this again in my own future and this list is indexed on Google. The  
future is now baby!

Enjoy.

-Frank

from java.io import ByteArrayInputStream
from org.apache.axis.utils import XMLUtils
from org.apache.axis.message import MessageElement
from java.lang import String
from org.jaxen.dom import DOMXPath

mystring = '''<change_price_response>
    <Inventory>
        <Product number="1000">
            <InStock>
                <part quantity="2" location="10"/>
(Continue reading)

Paolo | 4 Jun 18:47

Subprocess and jython

Hi,
i have this command in python :

p = subprocess.Popen([PATH, "-v", str(verbose), "-i", str(num), file.txt], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

which is the better way to implement his functioni jython ?
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Brian O'Neill | 5 Jun 22:24
Picon
Favicon

Using os.altsep in Windows

I'm using Jython 2.2.1 and I've noticed that os.altsep returns None for Windows.  I was expecting to get '/' particularly since the Python Library Reference uses this case as its example.  Was this not included in Jython?  Is this a known bug?

Brian

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
James R Eagan | 6 Jun 17:41

Re: Using os.altsep in Windows

On Jun 5, 2008, at 16:24 , Brian O'Neill wrote:

> I'm using Jython 2.2.1 and I've noticed that os.altsep returns None  
> for Windows.  I was expecting to get '/' particularly since the  
> Python Library Reference uses this case as its example.  Was this  
> not included in Jython?  Is this a known bug?

I can't say whether this is a known bug in Jython, but it was a known  
bug in CPython (see bug #709428) that was resolved in the CPython 2.3  
branch.

Should Jython 2.2 match CPython 2.2's bugs, or should it demonstrate  
the correct (documented) behavior?

James

--
There is no spoo.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Paolo | 6 Jun 17:59

Error hex to int

Hi,
i get an error while run this code line:

for p in ['time', 'us_hash', 'uid_hash']:
  ident[p] = int(ident[p][:-1], 16)

Traceback (innermost last):
  File "/usr/bin/builder.py", line 134, in ?
ValueError: invalid literal for __int__: BD429971
     
from debugger--> uid_hash:   0xBD429971L


help me, thanks.

PS: this code run very well in python 2.5!

Paolo
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Josh Juneau | 10 Jun 19:22
Picon

Jython Monthly - June 2008 Call for Articles

The June 2008 edition of the Jython Monthly newsletter is scheduled for distribution on June 17, 2008.

Please post any articles or contributions for the June 2008 distribution of the Jython Monthly newsletter at the following link:


Visit http://wiki.python.org/jython/JythonMonthly/Articles/Submitting for details regarding newsletter artical submittals.

All contributions are appreciated!  Please feel free to contact me if you have any questions.

--
Josh Juneau
juneau001 <at> gmail.com
http://jj-blogger.blogspot.com
http://www.gathereventplanning.com
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
astigmatik | 12 Jun 16:27
Picon

thread/daemon help

I have an identd (or ident) script. I use it for my IRC client. It is
only enabled when I try to connect to a server -- because that's the
only time that I want to respond to ident requests. My client has
multi-server capability, so when two sessions are attempting to
connect at the same time using the same ident script, I get an error
because the port is already in use. How do I sort of queue ident
requests? Or queue socket listens? (If that makes sense).

Here's the script:

--- identd.py ---

import socket, string
def listen(id):
   HOST = ''
   PORT = 113
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   s.bind((HOST, PORT))
   s.listen(1)
   conn, addr = s.accept()
   while 1:
      data = conn.recv(1024)
      if not data: break
      a, b = map(string.strip, data.split(','))
      conn.send("%s , %s : USERID : UNIX : %s\r\n" % (a, b, id))
   conn.close()

--- identd.py end ---

Regards,
astigmatik

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Michael Chisholm | 12 Jun 18:54
Picon
Favicon

Re: thread/daemon help

Looks like the problem is that you are trying to open two server sockets 
on the same port?  You can't do that afaik.  Can you respond in the same 
way to all the servers?  If so, just use same keep the same server 
socket open and use it to respond to all ident requests.  If not, 
perhaps you can check the remote host/port of the connection to 
determine which server is connecting and respond appropriately.

You could implement this in a multi-threaded way by spawning a thread 
for each incoming connection and servicing all the requests 
simultaneously (this is what I typically do when I need to service 
multiple connections to the same server socket).  Or if you wanted to 
remain single-threaded, you might want to increase the incoming 
connection queue size--check the documentation for the listen() method.  
Looks like you have the queue size set to 1; you might want to increase 
this.  Then just service all the ident requests sequentially.

Andy

astigmatik <at> gmail.com wrote:
> I have an identd (or ident) script. I use it for my IRC client. It is
> only enabled when I try to connect to a server -- because that's the
> only time that I want to respond to ident requests. My client has
> multi-server capability, so when two sessions are attempting to
> connect at the same time using the same ident script, I get an error
> because the port is already in use. How do I sort of queue ident
> requests? Or queue socket listens? (If that makes sense).
>
> Here's the script:
>
> --- identd.py ---
>
> import socket, string
> def listen(id):
>    HOST = ''
>    PORT = 113
>    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>    s.bind((HOST, PORT))
>    s.listen(1)
>    conn, addr = s.accept()
>    while 1:
>       data = conn.recv(1024)
>       if not data: break
>       a, b = map(string.strip, data.split(','))
>       conn.send("%s , %s : USERID : UNIX : %s\r\n" % (a, b, id))
>    conn.close()
>
> --- identd.py end ---
>
> Regards,
> astigmatik
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Jython-users mailing list
> Jython-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>   

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Nick Rothwell | 12 Jun 21:23
Favicon
Gravatar

Re: thread/daemon help

Perhaps you could just drop into the Java API for this? Create a  
ServerSocket, and spawn a thread on each successful call to accept().

	-- N.

Nick Rothwell / Cassiel.com Limited
www.cassiel.com
www.myspace.com/cassieldotcom
www.last.fm/music/cassiel
www.reverbnation.com/cassiel
www.linkedin.com/in/cassiel
www.loadbang.net

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

Gmane