diff --git a/python/helicalscan.py b/python/helicalscan.py index d1f475f..a60a4d3 100755 --- a/python/helicalscan.py +++ b/python/helicalscan.py @@ -1001,77 +1001,6 @@ close if fnRec: np.savez_compressed(fnRec, rec=rec, points=self.points, param=self.param, meta=self.meta) - def download(self,prg=None,mode=0,file='/tmp/helicalscan.cfg'): - ''' - mode bits: - bit 0 (1): wait execution finished (P1000==1) - bit 1 (2): gather and save data - bit 2 (4): ... - ''' - host=self.host - if prg is not None and self.verbose & 4: - for ln in prg: - print(ln) - - if file is not None and prg is not None: - fh=open(file,'w') - fh.write('\n'.join(prg)) - fh.close() - if host is not None: - # ***download and start the program*** - cmd ='gpasciiCommander --host '+host+' '+ file - print(cmd) - p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT) - #res=p.stdout.readlines(); print res - retval = p.wait() - - if mode &1: - # ***wait program finished P1000=1*** - com=GpasciiCommunicator().connect(host,prompt='# ') - ack=GpasciiCommunicator.gpascii_ack - sys.stdout.write('wait execution...');sys.stdout.flush() - while(True): - #Gather.MaxLines calculates maximum numbewr of gathering into memory - com.write('P1000\n') - val=com.read_until(ack) - #print val - val=int(val[val.find('=')+1:].rstrip(ack)) - if val==1:break - #com.write('Gather.Index\n') - #val=com.read_until(ack) - #print val - time.sleep(.2) - sys.stdout.write('.');sys.stdout.flush() - if mode &2: - fnRmt = '/var/ftp/gather/out.txt' - fnLoc = '/tmp/gather.txt' - print('\ngather data to %s...' % fnRmt) - p = sprc.Popen(('ssh', 'root@' + host, 'gather ', '-u', fnRmt), shell=False, stdin=sprc.PIPE, stdout=sprc.PIPE, - stderr=sprc.PIPE) - res = p.wait() - if res: - print('ssh failed. ssh root@%s to open a session' % host) - return - - print('transfer data to %s...' % fnLoc) - p = sprc.Popen(('scp', 'root@' + host + ':' + fnRmt, fnLoc), shell=False, stdin=sprc.PIPE, stdout=sprc.PIPE, - stderr=sprc.PIPE) - res = p.wait() - self.rec = np.genfromtxt(fnLoc, delimiter=' ') - com=GpasciiCommunicator().connect(host,prompt='# ') - ack=GpasciiCommunicator.gpascii_ack - - channels=["Motor[4].HomePos","Motor[5].HomePos","Motor[3].HomePos","Motor[1].HomePos"] - ofs=np.ndarray(len(channels)) - for i,v in enumerate(channels): - com.write(v+'\n') - val=com.read_until(ack) - #print val - #regexp: https://docs.python.org/2/library/re.html -> %e, %E, %f, %g - ofs[i]=float(re.search('=([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)',val).group(1)) - self.rec-=ofs - self.save_rec() - if __name__=='__main__': def run_test(args):