Exemplo n.º 1
0
    def process_path(self, rootdir):
        count_files = 0
        for _, _, files in os.walk(rootdir):
            count_files += len(files)
        prog = ProgressBar(0, count_files, 77, mode='fixed')

        processed = 0
        errors = 0
        for root, subfolders, files in os.walk(rootdir):
            for f in files:
                filename = os.path.join(root, f)
                try:
                    if self.process_file(filename):
                        processed += 1
                except:
                    print 'ERROR with %s' % filename
                    print 'Exception', sys.exc_info()[0]
                    errors += 1
                prog.increment_amount()
                print prog, "\r",
                sys.stdout.flush()
        print "\n"
        print "total files: %d, added: %d, errors: %d \n" % (count_files, processed, errors)
Exemplo n.º 2
0
import entries
from mongoengine import *
import os
import sys
import Image
from mprogress import ProgressBar

connect("cassad")

root = sys.argv[1]
size = 250

allpictures = entries.Picture.objects.all()

limit = allpictures.count()
prog = ProgressBar(0, limit, 77, mode='fixed')
oldprog = str(prog)

for pic in allpictures:
    try:
        if pic.thumbnail:
            if os.path.exists(pic.thumbnail):
                prog.increment_amount()
                print prog, "\r",
                sys.stdout.flush()
                continue
        filename = os.path.basename(pic.path)
        name, ext = os.path.splitext(filename)
        name = str(pic.id)
        filename = os.path.join(root, name + ext)