1 | # -*- coding: utf-8 -*- |
---|
2 | """ |
---|
3 | Created on Sun Mar 5 18:55:27 2017 |
---|
4 | |
---|
5 | Process the latest data file |
---|
6 | |
---|
7 | @author: delerue |
---|
8 | """ |
---|
9 | import glob |
---|
10 | import time |
---|
11 | |
---|
12 | |
---|
13 | global basedir |
---|
14 | global FILE_STOP |
---|
15 | global FILE_PAUSE |
---|
16 | global data_directory |
---|
17 | |
---|
18 | from clio_constants import * |
---|
19 | from read_plot_data import * |
---|
20 | |
---|
21 | from motor_function import * |
---|
22 | |
---|
23 | #import os |
---|
24 | |
---|
25 | #FILE_STOP='/home/etalon-admin/acquisition_data/stop_acquisition'; |
---|
26 | |
---|
27 | filemask='data_CLIO*.txt' |
---|
28 | list_of_files = glob.glob(data_directory+filemask) |
---|
29 | |
---|
30 | #print repr(list_of_files) |
---|
31 | |
---|
32 | while (len(glob.glob(FILE_STOP))==0): |
---|
33 | list_of_files = glob.glob(data_directory+filemask) |
---|
34 | ifile=0 |
---|
35 | for filename in sorted(list_of_files, reverse=True): |
---|
36 | # if ifile<5: |
---|
37 | # print filename |
---|
38 | if (len(glob.glob(filename.replace(".txt",".png")))==0): |
---|
39 | statinfo=os.stat(filename) |
---|
40 | if statinfo.st_size>0: |
---|
41 | print filename |
---|
42 | read_plot_data(filename) |
---|
43 | break |
---|
44 | # else: |
---|
45 | # if ifile<5: |
---|
46 | # print "Already processed" |
---|
47 | ifile=ifile+1 |
---|
48 | |
---|
49 | # |
---|
50 | |
---|
51 | |
---|
52 | # filetime=os.path.getctime(filename) |
---|
53 | # print filetime |
---|
54 | |
---|
55 | #filetuple=[ (os.path.getctime(filename) , filename) for filename in list_of_files ] |
---|
56 | #print repr(filetuple) |
---|
57 | #sorted(student_tuples, key=lambda student: student[2]) |
---|
58 | |
---|
59 | |
---|
60 | #sorted_filenames=[ ] |
---|
61 | |
---|
62 | #sorted([5, 2, 3, 1, 4]) |
---|
63 | #mylist=['a','b','c','d','e'] |
---|
64 | #myorder=[3,2,0,1,4] |
---|
65 | #mylist = [ mylist[i] for i in myorder] |
---|
66 | #print mylist |
---|
67 | |
---|
68 | # if (len(list_of_files_with_signal)>0): |
---|
69 | # latest_file_with_signal = max(list_of_files_with_signal, key=os.path.getctime) |
---|
70 | # filetime=os.path.getctime(latest_file_with_signal) |
---|
71 | |
---|
72 | |
---|
73 | |
---|