popen

jruby IO.popen read hangs in action when requests are made to the local dev server

大城市里の小女人 提交于 2019-12-25 04:06:47
问题 I just want to send the output of wkhtmltopdf to the user. It shouldn't be so hard. def it send_pdf "file.pdf" end def send_pdf(file) url= url_for(params) # Example: http://localhost:3000/report/it webkit= Rails.root.join('app', 'bin', 'wkhtmltopdf', 'current') cmd= "#{webkit} -q \"#{url_for(params)}\" -" data= IO.popen(cmd).read ############### HANGS HERE ################### send_data(data, type: "application/pdf", filename: file) end Why does it hang and how to fix it? 回答1: I think the clue

Does Popen().stdout.close() return a value?

99封情书 提交于 2019-12-25 03:18:33
问题 I have in the code I maintain: app7z = dirs['mopy'].join('7z.exe').s # path to 7z.exe command = '"%s" a "%s" -y -r "%s\\*"' % (app7z, dstFile.temp.s, srcDir.s) ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error checking and progress feedback reCompressing = re.compile('Compressing\s+(.+)') regMatch = reCompressing.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] for line in ins: maCompressing = regMatch(line) if len(errorLine) or

C programming - execute another program with sudo privileges

回眸只為那壹抹淺笑 提交于 2019-12-25 02:46:40
问题 i have a C program that opens an mp3 and extract the jpg artwork in the same folder. If i execute this program with no root privileges i get a crash. If i execute it with sudo it works normally. Now, i need another C programs who launch the previous program when it needs a jpg artwork for the selected mp3. I tried to call popen("./firstProgram test.mp3" , "r") function or system("/(absolute path)/firstProgram test.mp3") function by calling them even with sudo in the command or not and either

python popen special characters not parsing file

女生的网名这么多〃 提交于 2019-12-25 02:01:36
问题 I am having issues with non ASCII characters. I am using python 2.7.3 python -V Python 2.7.3 I installed http://pymediainfo.readthedocs.org/en/latest/ via easy_install pymediainfo imported as below from pymediainfo import MediaInfo media_info = MediaInfo.parse(os.path.join(path, to, file)) using this with ascii characters is fine for debugging I printed the 'command' from: /usr/local/lib/python2.7/dist-packages/pymediainfo-1.3.5-py2.7.egg/pymediainfo/__init__.py the class that 'runs' the

How can I run an exe file from Python 3.x Windows Service?

点点圈 提交于 2019-12-24 23:12:22
问题 This is very frustrating. I am trying to launch any EXE from a WINDOWS SERVICE . I'm using Python 3.5 and Win10. I created the service inheriting from win32serviceutil.ServiceFramework as I have seen in many examples on the Internet I've tried it with os.startfile() , subprocess.call() , subprocess.Popen() and os.system() and always with the same result. The application's executable (that I launched from the service) is appearing as a subthread (subprocess) no like main process and you don't

Preserve colored output using php's popen

醉酒当歌 提交于 2019-12-24 17:15:24
问题 When using popen in php, is there a way to preserve the colored output a program might generate? Is there maybe a way I can tell the shell to print all color escape sequences, instead of resolving them? 回答1: That depends on the program you are calling. Usually, if a program supports coloured output, it would ask the OS, "am I running on a terminal?" If yes, then it outputs colour codes. If not, it won't. If you run that program through popen() , then the OS would say "no, you're not running

PyQt5界面上调用subprocess.Popen会闪命令窗口的问题

[亡魂溺海] 提交于 2019-12-24 15:48:02
最近再做一个界面开发,主要实现的点击一个按钮,会执行adb安装应用程序的功能,在调试阶段一切都正常,但打包成一个exe安装程序,安装之后运行,点击按钮会闪一下adb的命令窗口 先列出subprocess.Popen方法介绍,里面有很多关键字参数 一、subprocess.Popen subprocess模块定义了一个类: Popen class subprocess.Popen( args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) 划重点: cmd_test = "adb install xxx.apk" subprocess.Popen(cmd_test, shell=True) 这是因为它相当于 subprocess.Popen(["cmd.exe", "-c", cmd_test]) 在*nix下,当shell=False(默认)时,Popen使用os.execvp()来执行子程序 所以如果不设置shell这个参数时

进程间通信-管道

拜拜、爱过 提交于 2019-12-24 12:06:13
转自: 0giant 管道允许在进程之间按先进先出的方式传送数据,是进程间通信的一种常见方式。 管道是Linux 支持的最初Unix IPC形式之一,具有以下特点: 1) 管道是 半双工的 ,数据只能向一个方向流动; 需要双方通信时,需要建立起两个管道 ; 2) 匿名管道只能用于父子进程或者兄弟进程之间(具有亲缘关系的进程); 3) 单独构成一种独立的文件系统:管道对于管道两端的进程而言,就是一个文件,但它不是普通的文件,它不属于某种文件系统,而是自立门户,单独构成一种文件系统,并且只存在与内存中。 管道分为pipe(无名管道)和fifo(命名管道)两种,除了建立、打开、删除的方式不同外,这两种管道几乎是一样的。他们都是通过内核缓冲区实现数据传输。 pipe用于相关进程之间的通信,例如父进程和子进程,它通过pipe()系统调用来创建并打开,当最后一个使用它的进程关闭对他的引用时,pipe将自动撤销。 FIFO即命名管道, 在磁盘上有对应的节点,但没有数据块 ——换言之,只是拥有一个名字和相应的访问权限,通过mknode()系统调用或者mkfifo()函数来建立的。一旦建立,任何进程都可以通过文件名将其打开和进行读写,而不局限于父子进程,当然前提是进程对FIFO有适当的访问权。当不再被进程使用时,FIFO在内存中释放,但磁盘节点仍然存在。 管道的实质是一个内核缓冲区

Stay in directory with popen

最后都变了- 提交于 2019-12-24 11:35:17
问题 I want to make some C++ program and I'm using function popen here to send commands to command line in Unix. It works fine, but when I call cd directory , the directory doesn't change. I thing that it's same when I try to run cd directory in some script, after finishing script directory path change back. So, scripts I must run like . ./script.sh not ./sript.sh , but how to do that with popen function? I have tried to add ". " before first argument of popen , but running ". ls" makes error.

subprocess.Popen() doesn't redirect output to file

妖精的绣舞 提交于 2019-12-24 06:10:14
问题 Check.cpp int main(int argc, char** argv) { string file = ""; ifstream inFile; int x; file = argv[1]; inFile.open(file.c_str()); while (inFile >> x) cout << x << endl; return 0; } Print.py from __future__ import with_statement from shutil import copy import subprocess import filecmp import sys count = 0 f = open ("filename.txt","r") file1 = open ("file1.txt","w") file2 = open ("file2.txt","w") file3 = open("out1.txt","w") file4 = open("out2.txt","w") for line in range(1,2): firstline = f