Ejemplo n.º 1
0
def for_each_scene(script, prefix='L8/'):

    dirs_for_prefix = {}

    count = 0
    for path in pusher.list(prefix):
        if path.endswith('_MTL.txt'):
            os.system('%s %s' % (script, os.path.dirname(path)))
            count += 1

    print 'Processed %d scenes.' % count
Ejemplo n.º 2
0
def make_index(s3_path='L8', verbose=False):

    dirs_for_prefix = {}

    for path in pusher.list(s3_path):
        components = path.split('/')[:4]

        rpath = components[0]
        for c in components[1:]:
            if c == 'index.html':
                continue

            l = dirs_for_prefix.get(rpath,[])
            if c not in l:
                l.append(c)
            dirs_for_prefix[rpath] = l
            rpath += '/' + c

    index_updates = 0
    for path in dirs_for_prefix.keys():
        files = ''
        for filename in dirs_for_prefix[path]:
            files += '<li><a href="%s/index.html">%s</a></li>\n' % (filename, filename)
        
        src_dir = os.path.dirname(__file__)
        doc = open(src_dir + '/tree_index_template.html').read()
        doc = doc.replace('@@@TITLE@@@', path)
        doc = doc.replace('@@@FILES@@@', files)

        open('index.html','w').write(doc)
        
        index_path = path + '/index.html'
        if verbose:
            print 'Update %s with %d files.' % (
                index_path, len(dirs_for_prefix[path]))

        pusher.push_file('index.html', index_path, overwrite=True)
        index_updates += 1

    print 'Updated %d index.html files under %s.' % (index_updates, s3_path)