コード例 #1
0
                        'Unable to find the server' in e.args[0] or \
                        'getaddrinfo failed' in e.args[0] or \
                        'connection attempt failed' in e.args[0]:

                    log.lprint('Waiting {} secs...'.format(str(wait)))
                    time.sleep(wait)
                    continue

                else:
                    log.lprint('Exiting...')
                    break

            # all extracted dictionaries to file
            if i == 0:
                Handler.write_to_csv(temp_dicts,
                                     header=True,
                                     append=False,
                                     outfile=OUTFILE)

            else:
                Handler.write_to_csv(temp_dicts,
                                     header=False,
                                     append=True,
                                     outfile=OUTFILE)

            time2 = datetime.datetime.now()

            log.lprint(
                'Time taken for site {s} ({ii} of {nn}): {t} seconds'.format(
                    s=str(temp_dicts[0]['site']),
                    ii=str(site_count + 1),
                    nn=str(n_samp),
コード例 #2
0
                       nn=str(n_fires),
                       t=str(round((time2 - time1).total_seconds(), 1))))

        out_list = list()
        for feat in temp_list:
            out_dict = dict()
            for key in all_bands:
                if key == 'EPA_DESIG':
                    out_dict[key] = str(int(feat['properties'][key]))
                elif key == 'id':
                    out_dict[key] = feat[key]
                elif key == 'tree_cover':
                    out_dict[key] = int(round(feat['properties'][key]))
                else:
                    out_dict[key] = feat['properties'][key]

            out_list.append(out_dict)

        # all extracted dictionaries to file
        if i == 0:
            Handler.write_to_csv(out_list,
                                 header=True,
                                 append=False,
                                 outfile=OUTFILE)

        else:
            Handler.write_to_csv(out_list,
                                 header=False,
                                 append=True,
                                 outfile=OUTFILE)
コード例 #3
0
            # write all the list items to the appropriate file
            # all lists should empty
            if count > ncheck:
                count = 0

                # find all the samples in the multiple and single lists
                for i in range(len(year_edges)):

                    if len(multiple_burns[i]) > 0:

                        # write to a new file if it doesnt exist
                        if Handler(outfile_multiple_list[i]).file_exists():
                            Opt.cprint('---- Writing {} samples to existing file {}'.format(str(len(multiple_burns[i])),
                                                                                       outfile_multiple_list[i]))
                            Handler.write_to_csv(multiple_burns[i],
                                                 outfile_multiple_list[i],
                                                 append=True)
                        else:
                            Opt.cprint('---- Writing {} samples to new file {}'.format(str(len(multiple_burns[i])),
                                                                                       outfile_multiple_list[i]))
                            Handler.write_to_csv(multiple_burns[i],
                                                 outfile_multiple_list[i])
                        multiple_burns[i] = list()

                    if len(single_burns[i]) > 0:
                        if Handler(outfile_single_list[i]).file_exists():
                            Opt.cprint('---- Writing {} samples to existing file {}'.format(str(len(single_burns[i])),
                                                                                       outfile_single_list[i]))
                            Handler.write_to_csv(single_burns[i],
                                                 outfile_single_list[i],
                                                 append=True)