Dirk Vleugels | 28 Aug 13:24

https & invalid certs

Hi,

i'm able to connect to SSL sockets issuing selfsigned or just plain
invalid certs by using code like this:

class TrustManager(javax.net.ssl.X509TrustManager):
	def checkClientTrusted(self,chain,authtype):
		pass
	def checkServerTrusted(self,chain,authtype):
		pass
	def getAcceptedIssuers(self):
		None

class HostnameVerifier(javax.net.ssl.HostnameVerifier):
	def verify(self,hostname,ssl_session):
		true

def setupSSLFactory():
        sc = javax.net.ssl.SSLContext.getInstance("SSLv3")
        sc.init(None,array([TrustManager()], TrustManager),None)

        urlConn=javax.net.ssl.HttpsURLConnection

        urlConn.setDefaultSSLSocketFactory(sc.getSocketFactory())
        urlConn.setDefaultHostnameVerifier(HostnameVerifier())

setupSSLFactory()
url=java.net.URL("https://domain-with-wrong-cert.com")
[..............]

(Continue reading)

Greg Scott | 27 Aug 12:31

Please explain how to get imports to work for embedded Jython in a .jar

Hello, I have been looking far and wide for an explanation of how to get imports to work as follows:

 

  1. I have a file mypython.py in a package called com.example

  2. I can successfully execute this python file using JSR223, getting the file as a stream etc.

  3. However, if in my python file I try and import another of my files, it always fails, e.g. in the same folder I have a python file myotherfile.py

 

The python code

 

# mypython.py

import myotherfile

 

Produces the error ImportError: no module named myotherfile

 

I am using Netbeans 6.1 if that makes a difference

 

Could someone please explain why this happens and advise how to fix it?

 

Thank you very much indeed.

 

Greg

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

TypeError question

Hi,
    I need to analyse a python script(annotationScript.py) from another python script(Processor) within java.
1). I did like below and it gave an error. It is  confusing for me because when I called the method using python it worked without errors. Can anyone help me to overcome this error.

//java code
        interp.exec("import annotationScript");
        interp.exec("import Processor");
        String stt = "Processor.getDictionary(annotationScript)";
        PyObject ob1 = interp.eval(stt);

#python method
def getDictionary(str1):
    #strFile = "/home/heshan/workspace/IdeaProjects/PYtest/src/pythonScripts/annotationScript.py"
    #fh = open(strFile,"r")
    fh = open(str1,"r")
    igot = fh.readlines()
    Dictionary = {}
    for line in igot:
        #store the necessary data to Dictionary        
    print Dictionary
    return Dictionary

StackTrace
Exception in thread "main" Traceback (innermost last):
  File "<string>", line 1, in ?
  File "/home/heshan/workspace/IdeaProjects/PYtest/src/pythonScripts/Processor.py", line 20, in getDictionary
TypeError: org.python.core.PyFile(): 1st arg can't be coerced to java.io.OutputStream, java.io.InputStream, java.io.RandomAccessFile or java.io.Writer


2). Since the error was a casting error I thought of doing it like below. It gave an error as well.

//java code
        interp.exec("import Processor");
        String filePath = "/home/heshan/repo/scripts/annotationScript.py";
        String stt = "Processor.getDictionary(" + filePath +")";
        PyObject ob1 = interp.eval(stt);

StackTrace
Exception in thread "main" Traceback (innermost last):
  (no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 25, 'Processor.getDictionary(/home/heshan/repo/scripts/annotationScript.py)'))


Can anyone give me an idea of how to overcome this issue.


--
Regards,
Heshan Suriyaarachchi

http://heshans.blogspot.com/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Fabio Zadrozny | 23 Aug 04:50

Pydev 1.3.20 Released

Hi All,

Pydev and Pydev Extensions 1.3.20 have been released

Details on Pydev Extensions: http://www.fabioz.com/pydev
Details on Pydev: http://pydev.sf.net
Details on its development: http://pydev.blogspot.com

Release Highlights in Pydev Extensions:
-----------------------------------------------------------------

* Code Analysis: Show error if using token not defined in __all__ in wild import.
* Search: Working with eclipse 3.4.


Release Highlights in Pydev:
----------------------------------------------

* Pydev Package Explorer: Editor-link does not remove focus from current editor if it's already a match (bug when compare editor was opened)
* Pydev debugger: Showing set and frozenset contents
* Pydev debugger: Watch working in eclipse 3.4
* Pydev debugger: Breakpoint properties accept new lines and tabs
* Pydev debugger: Workaround for python bug when filenames don't have absolute paths correctly generated
* Pydev code-completion: Wild import will only show tokens defined in __all__ (if it's available)
* Interactive console: Fixed problem when more attempts to connect were needed
* Interactive console: Fixed console integration problem with other plugins because of interfaces not properly implemented
* Incremental find: Backspace works correctly
* Launch icons: Transparent background (thanks to Radim Kubacki)
* Code Formatter: Exponentials handled correctly
* Launching: Unit-test and code-coverage may launch multiple folders/files at once
* Code coverage: Number format exception no longer given when trying to show lines not executed in the editor and all lines are executed
* Auto-indent: Fixed issue when using tabs which could result in spaces being added



What is PyDev?
---------------------------

PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others.


Cheers,

--
Fabio Zadrozny
------------------------------------------------------
Software Developer

ESSS - Engineering Simulation and Scientific Software
http://www.esss.com.br

Pydev Extensions
http://www.fabioz.com/pydev

Pydev - Python Development Enviroment for Eclipse
http://pydev.sf.net
http://pydev.blogspot.com
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Kapil Sachdeva | 22 Aug 17:57

Django on jython - Some questions

Dear all,

First of all thanks for the excellent work done by Leo on making django work on jython (and hence the JVM, App Servers etc).

Let me first admit that django is the best web application framework that I have used in comparison to any other web framework on any platform (java, .net, php etc).

Seeing my favorite framework (django) running on a rich java platform (I am more interested in the java libraries that I could use now and not the java language) and using a very good dynamic langauge i.e python makes me think that it is the ideal combination but then some questions come up and the most difficult for me to get around are:

- Would django on Jython running on Java web platforms (Tomcat, Glassfish etc) would be a good choice for highly available and scablable web application ?
- Java AppServers/containers manage the HttpSession which can be clustered using various ways - Terracaotta or container provider clustering where as django does the session management by itself.
- Default choice for django to do caching would be memcache but does that work for Java web platforms or it is even a right direction ?

Would appreciate if you guys could help me with these questions.

Regards & thanks
Kapil


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
David Griffin | 21 Aug 13:14

Catching errors in a embedded script at runtime

My app executes scripts at runtime, taken from files.
Each script is in essence a class definition based on an abstract
class in my Java.

So whatever is in the script, I know it should have a some key methods
defined in the abstract base class, and these are called from my java
code.

I read the script into my interpreter
   myInterpreter.execfile(scriptStream);
and this is void with no exceptions so I cannot really tell at that
point if script is OK

Then I get a reference for the class
  PyObject cls = interpreter.get(nameOfMyClass);
If cls != null then I think can be reasonably sure it found a valid
class in the interpreter namespace

I try to instantiate the class
  PyObject cls_instance = cls.__call__();

Then I convert that into a java object
 Object o = cls_instance.__tojava__(myAbstractClass.class);

If  o != Py.NoConversion  then I presumably have a usable java object.

I then cast  o   to (myAbstractClass) and I can start treating it as
an instance of myAbstractClass and call the base class methods.

This works a treat.

But suppose one of the methods implemented in the script contain a
dodgy bit of Python code ?

Currently I find out at runtime when
- it does not work (not always apparent)
- a load of (admittedly quite informative) Jython error messages
appear on stderr

But how can I capture this programmatically in my calling Java code ?

As far as Java is concerned, I called a method called
"baseClassMethod()" on a normal instance of  myAbstractClass .

I guess what I would like to be able to do is say in my abstract Java
class definition something like

public abstract class myAbstractClass
{
    // This method will be implemented in my Jython script
    public abstract void baseMethod1(...)  throws SomeSortOfException;
}

and find a way to have the Jython Interpreter automatically throw this
SomeSortOfException  if it encountered a problem in my code at
runtime.  I would rather not have to add a load of code in the script
itself for this because my whole aim here is to make the scripts
themselves simple and hide any infrastructure details from the user
who might have to view and tweak the scripts.

Hope I have explained this clearly.

Thanks in advance.

David Griffin

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Melendez,Ulises | 21 Aug 07:28

removing DEBUG.class file

I’m using jython2.5a1, and it appears to be generating a file named DEBUG.class.  I’m assuming this is occurring because the alpha release has debug turned on.  What’s the best way to disable this behavior?

 

Thanks,

 

 

Ulises Melendez

ulises_melendez <at> securecomputing.com

954.375.3667

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Mike Hostetler | 20 Aug 22:01

Re: Controlling .$py.class compiling


On Wed, Aug 20, 2008 at 1:25 PM, Leo Soto M. <leo.soto <at> gmail.com> wrote:

How about pre-compiling all your.py files to $py.class before
installing on the production environment? Would that work?

That's my Plan B. Doing that means I have to move more files over to production (both the .py and the $py.class files).  And, if the JRE changes, would those files get recompiled again?  If so, then they would change and I would have the same problems I just talked about.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Mike Hostetler | 20 Aug 19:36

Controlling .$py.class compiling

The good news is -- I finally convinced the Powers That Be that Jython was the right job for a solution.  Maybe me saying "It would take me three weeks in Java, but only two in Jython" helped my argument. :)

One issue that I do have is the .$py.class that Jython generates from .py files that it imports.  Our production environment is monitored for file changes.  So if Jython generates a $py.class file, we will receive a nasty-gram saying that we have added files. etc.  Is there a way to turn off the $py.class compilation?  Or does anyone have any other suggestions?

--
Mike Hostetler
http://mike.hostetlerhome.com/


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Josh Juneau | 20 Aug 13:20

Jython Monthly - Issue #21 - August 20, 2008

============================================
Jython Monthly - Issue #21 - August 20, 2008
URL: http://wiki.python.org/jython/JythonMonthly/Newsletters/August2008
Please send articles and news to:  juneau001 <at> gmail.com
============================================

Please read the complete newsletter by visiting the URL above.

I plan to revamp the Jython Monthly newsletter over the next month or two.
I'd like to try and spruce up the newsletter a bit and include a more
formal news
section each month. I am going over some ideas at this time, and if you have any
suggestions or things you'd like to see included, please send them my way.
Any feedback is appreciated.

Summary of August 2008 Contents:

News
====

Interview with Jim Baker - Jython Monthly Extra
http://wiki.python.org/jython/JythonMonthly/Interviews/August2008/JimBaker

Jython and Django on Glassfish - Scripting Project
https://glassfish-scripting.dev.java.net/discover/jython.html

More on Django and Jython - Leo Soto's Speaking at DjangoCon
http://wiki.python.org/jython/DjangoOnJython

Nbpython Project Progressing Quickly
https://nbpython.dev.java.net/

The Java Posse Made It To 200!
http://www.javaposse.com

Articles
======

*New* Jython Basics - Decorators
Submitted By:  Josh Juneau
http://wiki.python.org/jython/JythonMonthly/Articles/August2008/1

Jython Reborn - Chris McAvoy
http://www.developer.com/java/other/article.php/3748556

The A-Z of Programming Languages: Python
http://www.techworld.com.au/article/255835/-z_programming_languages_python?pp=1

Blogs
=====

Django on Jython, it's Here
http://blog.leosoto.com/2008/08/django-on-jython-its-here.html

Code Review With Rietveld
http://fwierzbicki.blogspot.com/2008/08/code-review-with-rietveld.html

Playing with JSqueak
http://blogs.sun.com/sundararajan/entry/playing_with_jsqueak

Jython Import Logic
http://blog.leosoto.com/2008/07/jython-import-logic.html

Books
====

New Python Book: Expert Python Programming - Tarek Ziade
http://tarekziade.wordpress.com/2008/08/08/a-new-python-book-expert-python-programming/

IDE
===

NbPython
https://nbpython.dev.java.net

Pydev 1.3.19
http://pydev.sourceforge.net/

============================================

View the Newsletter:
http://wiki.python.org/jython/JythonMonthly/Newsletters/August2008

Join the jython-users mailing list (jython-users <at> lists.sourceforge.net)
to subscribe.

=============================================
This issue of Jython Monthly was distributed by Josh Juneau.
Email: juneau001 <at> gmail.com
Blog:   http://jj-blogger.blogspot.com
http://www.gathereventplanning.com
=============================================

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
JLIST | 14 Aug 23:52

Packaging and deployment

Hi all,

Similar to Python, it seems that Jython applications are not that easy
to deploy. Too many files and directories. I wonder if there is a
solution to package all the directories and .py/class files in a
zip or jar file so that I just need to provide a couple of jar files
for deployment?

Thanks,
Jack

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane