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