3 HCE project, Python bindings, DC dependencies 4 The join tools research tests. 7 @author Alexander Vybornyh <alexander.hce.cluster@gmail.com> 8 @link: http://hierarchical-cluster-engine.com/ 9 @copyright: Copyright © 2013-2016 IOIX Ukraine 10 @license: http://hierarchical-cluster-engine.com/license/ 18 from subprocess
import Popen, PIPE
19 from tempfile
import SpooledTemporaryFile
as tempfile
20 from subprocess
import Popen
21 from subprocess
import PIPE
25 testDataDir =
'./join-convertor-data' 26 testOutputFile =
'/tmp/join_output_file.json' 29 delimiterTemplate =
"--delimiter='%s'" 30 firstCmdTemplate =
"cd ~/hce-node-bundle/api/python/bin && ./join.py --files='%s' --output_file='%s'" 31 secondCmdTemplate =
"cd ~/hce-node-bundle/api/python/bin && ./join.py --files='%s'" 35 process = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=
True, close_fds=
True)
36 output, err = process.communicate()
37 exitCode = process.wait()
38 return output, err, exitCode
45 if os.path.isdir(dataDir):
46 filesList = [os.path.abspath(os.path.join(dataDir, f))
for f
in os.listdir(dataDir)
if os.path.isfile(os.path.join(dataDir, f))]
51 ret = delimiter.join(filesList)
57 print (
"cmd: " + str(cmd))
59 output, err, exitCode =
execute(cmd)
60 print (
"exitCode: " + str(exitCode))
61 print (
"error: " + str(err))
62 print (
"output: " + str(output))
65 if __name__ ==
"__main__":
67 print (
"files: " + str(files))
69 cmd = (firstCmdTemplate % (files, testOutputFile)) +
' ' + (delimiterTemplate % testDelimiter)
72 files = files.split(testDelimiter)[0]
73 print (
"files: " + str(files))
74 cmd = (firstCmdTemplate % (files, testOutputFile)) +
' ' + (delimiterTemplate % testDelimiter)
77 cmd = (firstCmdTemplate % (files, testOutputFile)) +
' ' + (delimiterTemplate % testDelimiter)
80 cmd = secondCmdTemplate % files
def testExecute(cmd, files)
def makeInputFileList(dataDir, delimiter=None)