#!/usr/bin/python from PyTango import * import sys, time, termios init = 0 def inkey(): global init if( not init): init = 1 fd = sys.stdin.fileno() old = termios.tcgetattr( fd) new = termios.tcgetattr( fd) new[3] = new[3] & ~termios.ICANON & ~termios.ECHO # # VMIN - the minimum number of characters to be read # new[6] [termios.VMIN] = 0 # # VTIME - how long the driver waits for VMIN characters, unit 0.1s # new[6] [termios.VTIME] = 1 termios.tcsetattr( fd, termios.TCSADRAIN, new) sys.exitfunc = lambda: termios.tcsetattr( fd, termios.TCSADRAIN, old) key = sys.stdin.read(1) if( len( key) == 0): key = -1 else: key = ord( key) return key # # main # try : sps = DeviceProxy( "//haso107tk:10000/p08/i404/exp.01") while (1): print " x ",sps.read_attribute( "Read_position_x").value, print " y ",sps.read_attribute( "Read_position_y").value time.sleep( 0.2) if inkey() == 32: break except Exception, inst : print "Failed with exception !" print sys.exc_info()[0] print type(inst) # the exception instance print inst.args # arguments stored in .args