jython

How do I handle Microsoft outlook winmail.dat? Any other surprises?

冷暖自知 提交于 2020-01-01 09:35:27
问题 Ive decided that I really dont like microsoft and their ways. Please could you give me directions on how to handle winmail.dat in emails, is there a jython library or a java library that will allow me to handle this. Ive just completed a email processing program, written in jython 2.2.1 on java 5. During the final load test, I realised that attachments that should have been in a standard MIME email format is now tied up in some blasted winmail.dat, which means many different outlook clients

Importing jars from Jython

大兔子大兔子 提交于 2020-01-01 06:40:09
问题 I must admit that I'm slightly confused by the Jython import logic. I now that I can manually add the jars one by one to sys.path but I have a whole bunch of them and this is quite painful. Adding the directory containing the jars obviously doesn't work. What is the best way to do that? 回答1: The following code should do the trick for you and limit the amount of typing that you need to do while making use of the standard jython library. import os,glob,sys directories=['/path/to/jars/','

How can I make the PyDev editor selectively ignore errors?

天涯浪子 提交于 2020-01-01 01:29:16
问题 I'm using PyDev under Eclipse to write some Jython code. I've got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ISubInterface The problem is that PyDev will always flag this as an error and say "Unresolved import: ISubInterface". The code works just fine, it's just that I'd rather not have these little white/red X-marks next to my code and have my Problems tab littered with these errors. Is there a way I can add

Add .dll to java.library.path in Eclipse/PyDev Jython project

只愿长相守 提交于 2019-12-31 20:32:05
问题 I'm trying to use a compiled .jar Java library in my PyDev Jython project. I successfully added the .jar to the PYTHONPATH and was able to begin coding with auto complete working. The library requires a .dll extension as well, javaHeclib.dll , so I added that to the External Libs section of my project. I can import the library fine, but I get an error when I try to access any of its functions: java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: no javaHeclib in java.library.path I

how to pass arguments to python script in java using jython

て烟熏妆下的殇ゞ 提交于 2019-12-31 04:20:08
问题 I am trying to execute my python script in java using jython. The important thing is that I need to pass command line arguments to my script using jython, e.g. myscript.py arg1 arg2 arg3. There is a similar question here: Passing arguments to Python script in Java Which was not answered completely (none of the solutions work). My code now looks like this: String[] arguments = {"arg1", "arg2", "arg3"}; PythonInterpreter.initialize(props, System.getProperties(), arguments); org.python.util

Flip horizontally an image in Python (JES)

*爱你&永不变心* 提交于 2019-12-31 01:28:30
问题 I need to make a function that will copy an image, but mirrored. I created the code to mirror the image, but it isn't working and I don't know why because I traced the code and it should be mirroring the image. Here's the code: def invert(picture): width = getWidth(picture) height = getHeight(picture) for y in range(0, height): for x in range(0, width): sourcePixel = getPixel(picture, x, y) targetPixel = getPixel(picture, width - x - 1, height - y - 1) color = getColor(sourcePixel) setColor

CPython from Java?

你。 提交于 2019-12-30 10:37:33
问题 I need to call CPython code from Java. What tools/APIs/libraries exist out there to help me do this? Jython is not an option since the Python code is heavily dependent upon numpy . edit 1: The main() function should be Java, not Python (i.e. I need to embed CPython into Java, not vice versa.) edit 2: I should also mention that I'll be passing large numeric arrays between Java and Python and therefore a solution that brings the two into the same process space would be preferable (but not

Why sometimes Python subprocess failed to get the correct exit code after running a process?

回眸只為那壹抹淺笑 提交于 2019-12-30 10:09:36
问题 I am using Python subprocess to run external scripts on Windows 7. I am trying to get the exit code. In case 1, I run a python script test1.py . test1.py import sys sys.exit(24) <--exit code myscript1.py import subprocess process = subprocess.Popen(["python", "C:\\path\\to\\test1.py"], stdout=subprocess.PIPE) process.wait() print process.returncode In Windows command prompt, when I run the script, I get the following output: >python test1.py > >echo %errorlevel% >24 > >python myscript1.py >24

Scaling Part of a Picture

倖福魔咒の 提交于 2019-12-30 07:41:15
问题 I want to scale up a part of a picture, in this example, a nose. I have a function to select the part of the picture I want to enlarge. def copyAndPaste(picture): height = getHeight(picture) width = getWidth(picture) newPicture = makeEmptyPicture(width, height) for x in range(width): for y in range(height): pxl = getPixel(picture,x,y) if (x>48 and x<59) and (y>58 and y<71): newPxl =getPixel(newPicture, #?,#?) else: newPxl = getPixel(newPicture, x,y) color = getColor(pxl) setColor(newPxl,color

What's the difference between jython-standalone-2.7.0.jar and jython-2.7.0.jar

佐手、 提交于 2019-12-30 06:46:26
问题 I wrote a Java example, the code is: import org.python.core.PyObject; import org.python.util.PythonInterpreter; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import java.util.List; class JythonExample { public static void main(String args[]) throws ScriptException { listEngines(); ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine pyEngine = mgr.getEngineByName("python");