示例#1
0
 def render(self, template_name=None, **kwds):
     print css, js
     if not self._finished:
         current_user = self.current_user
         kwds['request'] = self.request
         kwds['this'] = self
         kwds['css'] = css
         kwds['js'] = js
         kwds['_xsrf'] = self._xsrf
         kwds['current_user'] = self.current_user
         kwds['current_user_id'] = self.current_user_id
         self.finish(render(template_name, **kwds))
示例#2
0
    def render(self, template_name=None, **kwds):
        if template_name is None:
            if not hasattr(self, 'template'):
                self.template = '%s/%s.htm' % (self.__module__[5:].replace(
                    '.', '/'), lower_name(self.__class__.__name__))
            template_name = self.template

        current_user = self.current_user
        kwds['current_user'] = current_user
        kwds['request'] = self.request
        kwds['this'] = self
        #kwds.update(RENDER_KWDS)
        if not self._finished:
            self.finish(render(template_name, **kwds))
示例#3
0
    def render(self, template_name=None, **kwds):
        if template_name is None:
            if not hasattr(self, 'template'):
                self.template = '%s/%s.htm' % (
                    self.__module__.replace('.', '/'),
                    lower_name(self.__class__.__name__)
                )
            template_name = self.template

        current_user = self.current_user
        kwds['current_user'] = current_user
        kwds['current_user_id'] = self.current_user_id
        kwds['request'] = self.request
        kwds['this'] = self
        kwds.update(RENDER_KWDS)
        if not self._finished:
            self.finish(render(template_name, **kwds))
示例#4
0
def render_template(uri, **kwds):
    txt = render(uri, **kwds).strip()
    return txt
示例#5
0
def render_template(uri, **kwds):
    txt = render(uri, **kwds).strip()
    return txt
示例#6
0
def main():
    if not os.path.exists(config.montagedir):
        os.makedirs(config.montagedir)

    initGPIO()

    blank7Segments()

    logging.basicConfig(format='%(levelname)s: %(name)s: %(message)s', level=logging.ERROR)

    print('Start')
    
    try:
        gp.check_result(gp.use_python_logging())
    except:
        raise

    #create camera object
    camera = gp.check_result(gp.gp_camera_new())

    # Handle SIGTERM and SIGINT to properly reset and exit camera before dying
    signal.signal(signal.SIGTERM, partial(handle_signal,camera))
    signal.signal(signal.SIGINT, partial(handle_signal,camera))
    
    # Wait for camera to connect before continuing
    while True:
        try:
            gp.check_result(gp.gp_camera_init(camera))
        except gp.GPhoto2Error as ex:
            if ex.code == gp.GP_ERROR_MODEL_NOT_FOUND:
                print ('camera not detected, retrying in 2 seconds')
                time.sleep(2)
                continue
            if ex.code == gp.GP_ERROR_IO:
                print ('I/O error. Restart camera, retrying in 5 seconds')
                time.sleep(5)
                continue
            #if ex.code == gp.GP_ERROR_BAD_PARAMETERS:
            #    break
            blank7Segments()
            raise
        except:
            blank7Segments()
            raise
        break

    print('Camera connected')
 
    try:
        configurecamera(camera)
    except:
        blank7Segments()
        raise

    #Capture frame endlessly
    while True:
        if config.withleds:
            displayNumOn7Segments(int(config.counter/10),tensleds)
            displayNumOn7Segments(config.counter%10,unitsleds)
            displayNumOn7Segments(config.frames,frameleds)

        if config.pressbutton:
            switchLed(buttonled)
            wairForButtonPressed()

        #define current time to timestamp frame name
        now = time.strftime("%Y%m%d_%Hh%Mm%Ss")
        
        capturedirectory = captureFrame(camera,now)
        
        try:
            #Call rendering method from config module with source file list and destination file path
            source = os.path.join(capturedirectory,'*.jpg')
            destination = os.path.join(config.montagedir,'%s.jpg'%now)
            config.render(source, destination)
            if not GPIO.input(printswitch):
                print('Print mode detected. Printing...')
                printFile(destination)
                print('Done')
        except:
            raise
        
        if config.knock:
            for knockserver in config.knockservers:
                knock(knockserver, 10000)