import sys import os import code import readline import rlcompleter import atexit from TellClient import TellClient tell = TellClient("http://PC12288:8080") def info(): tell.print_info() def help(): print ("Commands: \n\thelp()\n\tinfo()\n\tmount(segment, puck, sample)\n\tunmount() \n\tdry() " \ "\n\tscan(segment, puck, sample=None) \n\tmove_cold() \n\ttrash() \n\tabort() " \ "\n\tset_pin_offset(value)") def assert_transfer_allowed(): if not tell.is_in_mount_position(): raise Exception("Gonio is not in mount position") def mount(segment, puck, sample): assert_transfer_allowed() cmd = tell.mount(segment, puck, sample, True, True, True) print (tell.wait_cmd(cmd)) def unmount(): assert_transfer_allowed() cmd=tell.unmount(force=True) print (tell.wait_cmd(cmd)) def move_cold(): cmd=tell.move_cold() print (tell.wait_cmd(cmd)) def trash(): cmd=tell.trash() print (tell.wait_cmd(cmd)) def dry(): cmd=tell.dry() print (tell.wait_cmd(cmd)) def scan(segment, puck, sample=None): if sample is None: cmd=tell.scan_puck(segment, puck, True) else: cmd=tell.scan_pin(segment, puck, sample, True) print (tell.wait_cmd(cmd)) def abort(): tell.abort_cmd() def set_pin_offset(value): tell.set_pin_offset(value) info() help() #for line in sys.stdin: # tell.print_info() #print ("", end='\r> ') historyPath = os.path.expanduser("./.history") def save_history(historyPath=historyPath): readline.write_history_file(historyPath) if os.path.exists(historyPath): readline.read_history_file(historyPath) atexit.register(save_history) #vars = globals(); vars.update(locals()) vars =locals() readline.set_completer(rlcompleter.Completer(vars).complete) readline.parse_and_bind("tab: complete") code.interact(banner = "", local=vars)