@@ -30,24 +30,29 PLOT_CODES = { | |||
|
30 | 30 | 'coh': 3, # Coherence map. |
|
31 | 31 | 'base': 4, # Base lines graphic. |
|
32 | 32 | 'row': 5, # Row Spectra. |
|
33 |
'total' |
|
|
34 |
'drift' |
|
|
35 |
'height' |
|
|
36 |
'phase' |
|
|
37 |
'power' |
|
|
38 |
'noise' |
|
|
39 |
'beacon' |
|
|
40 |
'wind' |
|
|
41 |
'skymap' |
|
|
42 |
' |
|
|
43 | 'Z-E' : 26, | |
|
44 | 'V-A' : 27, | |
|
45 | 'Z-A' : 28, | |
|
33 | 'total': 6, # Total Power. | |
|
34 | 'drift': 7, # Drifts graphics. | |
|
35 | 'height': 8, # Height profile. | |
|
36 | 'phase': 9, # Signal Phase. | |
|
37 | 'power': 16, | |
|
38 | 'noise': 17, | |
|
39 | 'beacon': 18, | |
|
40 | 'wind': 22, | |
|
41 | 'skymap': 23, | |
|
42 | 'Unknown': 24, | |
|
43 | 'V-E': 25, # PIP Velocity. | |
|
44 | 'Z-E': 26, # PIP Reflectivity. | |
|
45 | 'V-A': 27, # RHI Velocity. | |
|
46 | 'Z-A': 28, # RHI Reflectivity. | |
|
46 | 47 | } |
|
47 | 48 | |
|
48 | class PrettyFloat(float): | |
|
49 | def __repr__(self): | |
|
50 | return '%.2f' % self | |
|
49 | def get_plot_code(s): | |
|
50 | label = s.split('_')[0] | |
|
51 | codes = [key for key in PLOT_CODES if key in label] | |
|
52 | if codes: | |
|
53 | return PLOT_CODES[codes[0]] | |
|
54 | else: | |
|
55 | return 24 | |
|
51 | 56 | |
|
52 | 57 | def roundFloats(obj): |
|
53 | 58 | if isinstance(obj, list): |
@@ -753,7 +758,7 class SendToFTP(Operation, Process): | |||
|
753 | 758 | DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday |
|
754 | 759 | exp_code = '%3.3d'%exp_code |
|
755 | 760 | sub_exp_code = '%2.2d'%sub_exp_code |
|
756 |
plot_code = '%2.2d'% |
|
|
761 | plot_code = '%2.2d'% get_plot_code(filename) | |
|
757 | 762 | name = YEAR_STR + DOY_STR + '00' + exp_code + sub_exp_code + plot_code + '00.png' |
|
758 | 763 | return name |
|
759 | 764 | |
@@ -766,54 +771,52 class SendToFTP(Operation, Process): | |||
|
766 | 771 | |
|
767 | 772 | try: |
|
768 | 773 | self.ftp.storbinary(command, fp, blocksize=1024) |
|
769 |
except |
|
|
774 | except Exception, e: | |
|
770 | 775 | log.error('{}'.format(e), self.name) |
|
771 | 776 | if self.ftp is not None: |
|
772 | 777 | self.ftp.close() |
|
773 | 778 | self.ftp = None |
|
774 | return | |
|
779 | return 0 | |
|
775 | 780 | |
|
776 | 781 | try: |
|
777 | 782 | self.ftp.sendcmd('SITE CHMOD 755 {}'.format(dst)) |
|
778 |
except |
|
|
783 | except Exception, e: | |
|
779 | 784 | log.error('{}'.format(e), self.name) |
|
780 | 785 | if self.ftp is not None: |
|
781 | 786 | self.ftp.close() |
|
782 | 787 | self.ftp = None |
|
788 | return 0 | |
|
783 | 789 | |
|
784 | 790 | fp.close() |
|
785 | ||
|
786 | 791 | log.success('OK', tag='') |
|
792 | return 1 | |
|
787 | 793 | |
|
788 | 794 | def send_files(self): |
|
789 | 795 | |
|
790 | 796 | for x, pattern in enumerate(self.patterns): |
|
791 | 797 | local, remote, ext, delay, exp_code, sub_exp_code = pattern |
|
792 | 798 | if time.time()-self.times[x] >= delay: |
|
793 | srcname = self.find_files(local, ext) | |
|
794 | ||
|
799 | srcname = self.find_files(local, ext) | |
|
800 | src = os.path.join(local, srcname) | |
|
801 | if os.path.getmtime(src) < time.time() - 30*60: | |
|
802 | continue | |
|
803 | ||
|
795 | 804 | if srcname is None or srcname == self.latest[x]: |
|
796 | 805 | continue |
|
797 | 806 | |
|
798 | 807 | if 'png' in ext: |
|
799 | 808 | dstname = self.getftpname(srcname, exp_code, sub_exp_code) |
|
800 | 809 | else: |
|
801 | dstname = srcname | |
|
802 | ||
|
803 | src = os.path.join(local, srcname) | |
|
804 | ||
|
805 | if os.path.getmtime(src) < time.time() - 30*60: | |
|
806 | continue | |
|
810 | dstname = srcname | |
|
807 | 811 | |
|
808 | 812 | dst = os.path.join(remote, dstname) |
|
809 | 813 | |
|
810 |
if self. |
|
|
811 |
|
|
|
812 | ||
|
813 | self.upload(src, dst) | |
|
814 | ||
|
815 | self.times[x] = time.time() | |
|
816 | self.latest[x] = srcname | |
|
814 | if self.upload(src, dst): | |
|
815 | self.times[x] = time.time() | |
|
816 | self.latest[x] = srcname | |
|
817 | else: | |
|
818 | self.isConfig = False | |
|
819 | break | |
|
817 | 820 | |
|
818 | 821 | def run(self): |
|
819 | 822 | |
@@ -822,7 +825,7 class SendToFTP(Operation, Process): | |||
|
822 | 825 | self.setup() |
|
823 | 826 | if self.ftp is not None: |
|
824 | 827 | self.check() |
|
825 | self.send_files() | |
|
828 | self.send_files() | |
|
826 | 829 | time.sleep(10) |
|
827 | 830 | |
|
828 | 831 | def close(): |
General Comments 0
You need to be logged in to leave comments.
Login now