@@ -39,15 +39,20 PLOT_CODES = { | |||
|
39 | 39 |
'beacon' |
|
40 | 40 |
'wind' |
|
41 | 41 |
'skymap' |
|
42 |
' |
|
|
43 | 'Z-E' : 26, | |
|
44 | 'V-A' : 27, | |
|
45 | 'Z-A' : 28, | |
|
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,24 +771,25 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 | |
@@ -791,6 +797,9 class SendToFTP(Operation, Process): | |||
|
791 | 797 | local, remote, ext, delay, exp_code, sub_exp_code = pattern |
|
792 | 798 | if time.time()-self.times[x] >= delay: |
|
793 | 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 | |
|
794 | 803 | |
|
795 | 804 | if srcname is None or srcname == self.latest[x]: |
|
796 | 805 | continue |
@@ -800,20 +809,14 class SendToFTP(Operation, Process): | |||
|
800 | 809 | else: |
|
801 | 810 | dstname = srcname |
|
802 | 811 | |
|
803 | src = os.path.join(local, srcname) | |
|
804 | ||
|
805 | if os.path.getmtime(src) < time.time() - 30*60: | |
|
806 | continue | |
|
807 | ||
|
808 | 812 | dst = os.path.join(remote, dstname) |
|
809 | 813 | |
|
810 |
if self. |
|
|
811 | continue | |
|
812 | ||
|
813 | self.upload(src, dst) | |
|
814 | ||
|
814 | if self.upload(src, dst): | |
|
815 | 815 | self.times[x] = time.time() |
|
816 | 816 | self.latest[x] = srcname |
|
817 | else: | |
|
818 | self.isConfig = False | |
|
819 | break | |
|
817 | 820 | |
|
818 | 821 | def run(self): |
|
819 | 822 |
General Comments 0
You need to be logged in to leave comments.
Login now