2012年5月25日金曜日

xselect from python

see also uchiyama's blog

#!/usr/bin/env python

"""
2012-05-25
test
http://aidememoirehu.blogspot.jp/search/label/Python
"""

MY_NAME = "run_xselect2"

import sys
import os
import subprocess

out_name = 'test' + MY_NAME
out_com = out_name+'.com'

# if out_com is already present

# overwrite
com = open (out_com, 'w')

ev_file = "test_evlist.txt"

print >> com, """
clear all proceed=yes
set mission suzaku
set datadir /Volumes/Macintosh_HD_2/Nobackup/aepipeline//801040010/
"""
print >> com, "read events @"+ev_file+'¥n'
print >> com, """
ext image
save image test1.xy
"""
print out_com, "is created¥n"

com.close

# open file into string
com = open(out_com, 'r')
# com_list = com.readlines()
# TypeError: must be string or buffer, not list
# to list

com_str = com.read()
xsp = subprocess.Popen( 'xselect', stdin = subprocess.PIPE )
xsp.stdin.write( '¥n¥n' )
xsp.stdin.write( com_str )
xsp.stdin.write( 'quit ¥n ¥n' )
xsp.wait()









0 件のコメント:

コメントを投稿