jython

how to tell if a string is base64 or not

时光毁灭记忆、已成空白 提交于 2019-12-30 04:46:05
问题 I have many emails coming in from different sources. they all have attachments, many of them have attachment names in chinese, so these names are converted to base64 by their email clients. When I receive these emails, I wish to decode the name. but there are other names which are not base64. How can I differentiate whether a string is base64 or not, using the jython programming language? Ie. First attachment: ------=_NextPart_000_0091_01C940CC.EF5AC860 Content-Type: application/vnd.ms-excel;

Packaging a Jython program in an executable jar

落爺英雄遲暮 提交于 2019-12-29 19:14:42
问题 I am trying to package a jython program into an executable jar which the user can simply double-click to run without installing jython ahead of time. Ultimately, I would like to include an additional library which I wrote with the jar, but at the moment I am just trying to package a simple program and have it run from the jar. I have tried following the jar instructions in the "Using the Jar Method" section here: Jython FAQ: Using the Jar Method I have also looked at slides 25-28 here: Jython

Clojure Jython interop

﹥>﹥吖頭↗ 提交于 2019-12-29 03:30:07
问题 I was wondering if anyone has tried somehow calling Jython functions from within Clojure, and how you went about doing this if so. I have not used Jython, but I would imagine the Jython interpreter can be invoked in the same way as any other java code, and Python programs can be run within it. However I wonder if it would be possible to somehow call individual python functions from Clojure. Like I said, I have not tried this yet, so it might actually be straightforward and obvious. I'm just

Can I detect if my code is running on cPython or Jython?

喜你入骨 提交于 2019-12-28 06:59:47
问题 I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backends.zxjdbc.postgresql). Is there a simple way to do this? 回答1: if you're running Jython import platform platform.system() return 'Java' here has some discussion

How can I install various Python libraries in Jython?

て烟熏妆下的殇ゞ 提交于 2019-12-25 08:25:45
问题 I know that I can install Jython with Java and that I can use Jython where I use Python. The Jython shell is working fine. In Jython, how can I install libraries like lxml , Scrappy and BeautifulSoup that I'd normally install via pip or easy_install 回答1: Some Python modules, like lxml , have required components in C. These won't work in Jython. Most Python packages will work fine, and you can install them using the same tools as you use in CPython. This is described in Appendix A of Jython

Jython 2.7.0 “Final Release” on Windows - difficulty including jars

♀尐吖头ヾ 提交于 2019-12-25 05:37:29
问题 I have a few projects which run using Jython 2.7b1 where I add the jars (in fact all the jars in a directory) by doing this: set CLASSPATH=.;"%SYSADMIN%\resources\java jar files/*" set JYTHONPATH=... C:\jython2.7b1\jython myproj\__main__.py But my latest project is using 2.7.0FR and this "set CLASSPATH" approach doesn't seem to work. I then tried this: D:\apps\jython2.7.0\bin\jython -Dpython.path="%SYSADMIN%\resources\java jar files/*" my_latest_proj\__main__.py ... but it didn't work. Then I

Python full path import not working across branches in package tree

和自甴很熟 提交于 2019-12-25 03:05:21
问题 I have the following project structure: Project - GUI - ...Modules - Data - Database - ...Modules - Files - ...Modules - Utilities - ...Modules And I am trying to do some imports over package borders, for example: in the file(Module) Project.Database.dbdriver I try to import Project.Utilities.Conversions . If I use a fully specified import like import Project.Utilities.Conversions this fails, it works with import Utilities.Conversions , i.e. I can not specify more off the path than those part

Java IO FileNotFoundException after converting file name toURL()

不羁的心 提交于 2019-12-25 01:40:25
问题 Here is the Jython code (although this may not be a Jython-specific issue)... file_name = "Manifest.ttl" file_url = File(file_name).toURL() f = File(file_url.toString()) java.io.FileNotFoundException: java.io.FileNotFoundException: file:/home/james/projects/wordnet/wordnet30/rdf/Manifest.ttl (No such file or directory) 回答1: Javadoc to the rescue: Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the

Java execute Embedded Python with parameters

让人想犯罪 __ 提交于 2019-12-24 15:33:12
问题 I want to execute Embedded python in Java. Python code #!/usr/bin/python import sys print 'Number of arguments:', len(sys.argv), 'arguments.' print 'Argument List:', str(sys.argv) Java Code StringWriter writer = new StringWriter(); // ouput will be stored here ScriptEngineManager manager = new ScriptEngineManager(); ScriptContext context = new SimpleScriptContext(); context.setWriter(writer); // configures output redirection ScriptEngine engine = manager.getEngineByName("python"); engine.eval

Jython - Configuring modules path into a jython script

旧巷老猫 提交于 2019-12-24 14:26:49
问题 Looks like function os.chdir() does not works for Jython, is there another way to switch of working directory in a Jython script ? (Get the following error while running my script: OSError: [Errno 0] chdir not supported in Java) Thanks in advance for any solution. EDIT: Question title updated to match the solution. Tags too. 回答1: What Grimmy asked make me think different about my original problem (thanks to you) My goal is (was) to define a path to find local jython modules. And so the