HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
ftest_popen.py
Go to the documentation of this file.
1 #coding: utf-8
2 '''
3 HCE project, Python bindings, DC dependencies
4 The popen research tests.
5 
6 @package: drce
7 @author bgv bgv.hce@gmail.com
8 @link: http://hierarchical-cluster-engine.com/
9 @copyright: Copyright © 2015 IOIX Ukraine
10 @license: http://hierarchical-cluster-engine.com/license/
11 @since: 0.1
12 '''
13 
14 import time
15 
16 stdinStr = 'one\ntwo\nthree\nfour\nfive\nsix\n'
17 
18 from subprocess import Popen, PIPE
19 from tempfile import SpooledTemporaryFile as tempfile
20 from subprocess import Popen
21 from subprocess import PIPE
22 
23 s = time.time()
24 
25 #cmd = '/bin/grep f'
26 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./processor-task.py'
27 #md = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./processor-task.py --config=../ini/processor-task.ini'
28 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin' #0.00332117080688
29 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./processor-task.py' #0.369460105896
30 #cmd = 'python --version' #0.00488090515137
31 #cmd = 'python -c \'print "Hello!"\'' #0.0166239738464
32 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./processor_feed_parser.py'
33 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./processor_feed_parser.py --config=../ini/processor_feed_parser.ini'
34 #cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./scraper.py'
35 cmd = 'cd /home/bgv/hce-node-bundle/api/python/bin && ./scraper.py --config=../ini/scraper.ini'
36 
37 process = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True, close_fds=True)
38 (output, err) = process.communicate(input=stdinStr)
39 print "error: " + str(err)
40 exit_code = process.wait()
41 print "exit_code: " + str(exit_code)
42 print output
43 
44 print (time.time() - s)