コード例 #1
0
    def __process(self, product_code):

        base_path = os.path.join(self.root, product_code.upper(), 'RAW')
        print os.path.join(self.root, product_code, 'RAW', '*')

        folders_years = glob.glob(os.path.join(base_path, '*'))

        print folders_years
        for folder_year in folders_years:
            folders_days = glob.glob(os.path.join(folder_year, '*'))
            # print folders_days
            for folder_day in folders_days:
                my_processing = copy.deepcopy(processing)
                my_processing[product_code][0]['source_path'] = None
                layers = glob.glob(os.path.join(folder_day, '*.hdf'))
                shutil.rmtree(folder_day + '/PROCESSED/')
                for l in layers:
                    try:
                        my_processing[product_code][0]['source_path'].append(l)
                    except AttributeError:
                        my_processing[product_code][0]['source_path'] = []
                        my_processing[product_code][0]['source_path'].append(l)

                for tmp_out in my_processing[product_code]:
                    tmp_out['output_path'] = folder_day + '/PROCESSED/'
                try:
                    for proc in my_processing[product_code]:
                        proc["source_path"] = proc["source_path"] if "source_path" in proc else result
                        result = processing_core.process_obj(proc)
                except Exception, e:
                    print '##################################################'
                    print e
                    print '##################################################'
                print 'Processing done.'
コード例 #2
0
    def __process2(self, product_code):
        if self.products is not None and self.years is not None and self.countries is not None:
            for p in self.products:
                for y in self.years:
                    days = c.list_days(p, y)
                    for d in days:
                        my_processing = copy.deepcopy(processing)
                        my_processing[product_code][0]['source_path'] = None
                        for tmp_out in my_processing[product_code]:
                            tmp_out['output_path'] = None
                        if os.path.isdir(self.root + p + '/' + y + '/' + d['code'] + '/PROCESSED/'):
                            shutil.rmtree(self.root + p + '/' + y + '/' + d['code'] + '/PROCESSED/')
                        layers = c.list_layers_countries_subset(p, y, d['code'], self.countries)
                        for l in layers:
                            try:
                                my_processing[product_code][0]['source_path'].append(self.root +
                                                                                     p + '/' +
                                                                                     y + '/' +
                                                                                     d['code'] + '/' +
                                                                                     l['file_name'])
                            except AttributeError:
                                my_processing[product_code][0]['source_path'] = []
                                my_processing[product_code][0]['source_path'].append(self.root +
                                                                                     p + '/' +
                                                                                     y + '/' +
                                                                                     d['code'] + '/' +
                                                                                     l['file_name'])

                        for tmp_out in my_processing[product_code]:
                            tmp_out['output_path'] = self.root + p + '/' + y + '/' + d['code'] + '/PROCESSED/'
                        try:
                            for proc in my_processing[product_code]:
                                proc["source_path"] = proc["source_path"] if "source_path" in proc else result
                                result = processing_core.process_obj(proc)
                        except Exception, e:
                            print '##################################################'
                            print e
                            print '##################################################'
                        print 'Processing done.'