jython

Python subprocess call cannot take grep

≯℡__Kan透↙ 提交于 2019-12-04 05:11:37
问题 Python subprocess call is supposed to run as command as is, but it is complaining if there is a pipe in it. Here is my code: #!/usr/bin/python import sys import subprocess import time service_name= "mysrvc" state ="STOPPED" mycmd ="sc query " + service_name + " " + "|" + " findstr" + " " + state print(mycmd) if subprocess.call(mycmd)==0: print("Service stopped successfully") The Error I get is : ERROR: Invalid Option; Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]:

How to update line with modified data in Jython?

蓝咒 提交于 2019-12-04 05:05:33
问题 I'm have a csv file which contains hundred thousands of rows and below are some sample lines.., 1,Ni,23,28-02-2015 12:22:33.2212-02 2,Fi,21,28-02-2015 12:22:34.3212-02 3,Us,33,30-03-2015 12:23:35-01 4,Uk,34,31-03-2015 12:24:36.332211-02 I need to get the last column of csv data which is in wrong datetime format. So I need to get default datetimeformat( "YYYY-MM-DD hh:mm:ss[.nnn]" ) from last column of the data. I have tried the following script to get lines from it and write into flow file.

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

安稳与你 提交于 2019-12-04 04:47:57
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 pollute the internet with this winmail.dat, so that means i need to support winmail.dat. Thus my program

Using ctypes with jython

非 Y 不嫁゛ 提交于 2019-12-04 04:00:19
问题 I have a trouble with using ctypes lib in my python script. Here is my code (found on the Internet): if __name__ == "__main__": from ctypes import * user32 = windll.user32 kernel32 = windll.kernel32 class RECT(Structure): _fields_ = [ ("left", c_ulong), ("top", c_ulong), ("right", c_ulong), ("bottom", c_ulong)]; class GUITHREADINFO(Structure): _fields_ = [ ("cbSize", c_ulong), ("flags", c_ulong), ("hwndActive", c_ulong), ("hwndFocus", c_ulong), ("hwndCapture", c_ulong), ("hwndMenuOwner", c

Beginner python programming help to crossfade sounds

…衆ロ難τιáo~ 提交于 2019-12-03 20:45:30
Hello I am taking a programming class and I am completely lost with a question. We need to take two sounds and add them together. But the first sound starts of at full volume and the second starts silent and then slowing shifting the balance till the first sound is silent and the second is at full volume. So I was able to put the sounds together but i am not sure how to make them get louder over the course of the sound. def mergeSounds(s1, s2): sr = int(getSamplingRate(s1)) newSound = makeEmptySound(getLength(s1), sr) for t in range(getLength(newSound)): sv1 = getSampleValueAt(s1, t) sv2 =

Importing jars from Jython

白昼怎懂夜的黑 提交于 2019-12-03 17:29:05
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? 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/','/different/path/to/more/jars/'] for directory in directories: for jar in glob.glob(os.path.join(directory,'*.jar'))

setting import module path in Jython - strange behavior

人盡茶涼 提交于 2019-12-03 16:21:24
I'm building Java to Jython bridge class. The task I'm trying to solve is to make Jython to look for python modules in my application working directory (also known as program execution directory). I'm doing so by appending System.getProperty("user.dir") value to the sys.path: pySysState = new PySystemState(); //add working directory into sys.path pySysState.path.append(new PyString(System.getProperty("user.dir"))); log_.info("Jython sys state initialized. sys.path: " + this.pySysState.path); I get ImportError exception: python module 'user_module' was not found. sys.path: ['<other jars>\\Lib',

What is the best way to use python code from Scala (or Java)? [duplicate]

微笑、不失礼 提交于 2019-12-03 15:40:40
This question already has answers here : Possible Duplicate: Java Python Integration There is some code written in Python and I need to use it from Scala. The code uses some native C. Is it possible to use this from Scala or Java without having to rewrite much? I intend to use the code as a black-box without understanding, so I prefer not to look into it but rather to somehow generate a jar that I can import in my code. Why not try Jython ?You directly compile python code to Java classes or call Python code from Java through interface. 来源: https://stackoverflow.com/questions/10882488/what-is

Email an attachment in R with gmail

烈酒焚心 提交于 2019-12-03 09:19:25
问题 I am desiring to send an email in R with an attachment using gmail. I have found that sendmailR does not work with gmail because it requires authentication (I couldn't get it to work with gmail so I assume this to be true unless someone tells me I'm wrong , in which case I'll post the R output and error message for that). I found a code snippet found here (LINK). As the site suggests the code is not formatted to send attachments but I have got it to send an email. I'd like to extend this code

Are CPython, IronPython, Jython scripts compatible with each other?

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am pretty sure that python scripts will work in all three, but I want to make sure. I have read here and there about editors that can write CPython, Jython, IronPython and I am hoping that I am looking to much into the distinction. My situation is I have 3 different api's that I want to test. Each api performs the same functionality code wise, but they are different in implementation. I am writing wrappers around each language's apis. Each wrapper should expose the exact same functionality and implementation to python using Boost::python,