예제 #1
0
    def start(self, result=None, arduino=None):
        global in_session

        logger.debug('start new session')

        if in_session:
            defer.returnValue(None)

        in_session = True

        if arduino:
            arduino.sendCommand(0x82, 0)
            arduino.sendCommand(0x82, 1)
            arduino.sendCommand(0x82, 2)
            arduino.sendCommand(0x82, 3)

        countdown_delay = Config.getint('camera', 'countdown-delay')
        needed_captures = template.needed_captures(self.template)
        captures = 0
        errors = 0

        # PLUGINS
        p = self.plugins
        fc0 = p['FileCopy'].new(originals_path)
        fc1 = p['FileCopy'].new(composites_path)
        #fc3 = p['FileCopy'].new(thumbs_path)
        #fc4 = p['FileCopy'].new(details_path)
        #fc5 = p['FileCopy'].new(template_path)
        spool = p['FileCopy'].new(shared_path)

        #th0 = p['ImageThumb'].new(size='256x256', destination='thumbnail.png')
        #th1 = p['ImageThumb'].new(size='1024x1024', destination='thumbnail.png')

        cm = p['Composer'].new(self.template)
        #fd0 = p['FileDelete'].new()
        #fd1 = p['FileDelete'].new()

        filenames = list()

        while captures < needed_captures and errors < 3:
            try:
                filename = yield task.deferLater(reactor, countdown_delay,
                                                 self.capture)
            except:
                traceback.print_exc(file=sys.stdout)
                errors += 1
                logger.debug('failed capture %s/3', errors)
                task.deferLater(reactor, 0, error.play)
                task.deferLater(reactor, .15, error.play)
                task.deferLater(reactor, .30, error.play)
                continue

            captures += 1
            errors = 0
            logger.debug('successful capture (%s/%s)',
                         captures, needed_captures)

            if captures < needed_captures:
                finished.play()
            else:
                bell1.play()

            # C A L L B A C K S
            fn = filename
            original = yield fc0.process(fn)
            filenames.append(original)

            #thumb = yield th0.process(original)
            #thumb = yield fc3.process(thumb)
            #detail = yield th1.process(original)
            #detail = yield fc4.process(detail)

        if arduino:
            arduino.sendCommand(0x81, 0)
            arduino.sendCommand(0x81, 1)
            arduino.sendCommand(0x81, 2)
            arduino.sendCommand(0x81, 3)

        # composite
        d = cm.process(filenames.pop(0))
        d.addCallback(fc1.process)
        if Config.getboolean('kiosk', 'print'):
            d.addCallback(spool.process)
        for fn in filenames:
            cm.process(fn)

        in_session = False
        logger.debug('finished the session')
예제 #2
0
all_images_path = Config.get('paths', 'images')
shared_path = Config.get('paths', 'shared')
plugins_path = Config.get('paths', 'plugins')

# event paths
event_name = Config.get('event', 'name')
template_path = jpath(all_templates_path, Config.get('event', 'template'))
event_images_path = jpath(all_images_path, event_name)
thumbs_path = jpath(event_images_path, 'thumbnails')
details_path = jpath(event_images_path, 'detail')
originals_path = jpath(event_images_path, 'originals')
composites_path = jpath(event_images_path, 'composites')
paths = ('thumbnails', 'detail', 'originals', 'composites')

# make sure directory structure is usuable
if Config.getboolean('paths', 'make-images-path'):
    for d in (thumbs_path, details_path, originals_path, composites_path):
        try:
            isdir = os.path.isdir(d)
        except:
            raise
        if not isdir:
            os.makedirs(d, 0755)

# mixer must be initialized before sounds will play
pygame.mixer.init(frequency=Config.getint('sound', 'mixer-frequency'),
                  buffer=Config.getint('sound', 'mixer-buffer'))

# load all the stuff
resources.load()