Exemplo n.º 1
0
 def test_timenow(self):
     
     time='20121023401223'
     
     time_set=datetime.format_timedata(time)
     
     self.assertFalse(datetime.checkdatetime(time_set[0], time_set[1], time_set[2], time_set[3], time_set[4], time_set[5]))
     
     time='20121126231248'
     
     time_set=datetime.format_timedata(time)
     
     self.assertTrue(datetime.checkdatetime(time_set[0], time_set[1], time_set[2], time_set[3], time_set[4], time_set[5]))
     
     timestamp=datetime.obtain_timestamp(time)
     
     self.assertTrue(timestamp)
     
     datetime.timezone='Europe/Madrid'
     
     datetime.set_timezone()
     
     # Check conversions to gmt time
     
     gmtstamp=datetime.local_to_gmt(time)
     
     self.assertEqual(gmtstamp, '20121126221248')
     
     time_from_utc=datetime.format_time(time)
     
     self.assertEqual(time_from_utc, '00:12:48')
     
     date_from_utc=datetime.format_date(time)
     
     self.assertEqual(date_from_utc, '2012/11/27')
     
     time_summer='20120826231248'
     
     gmtstamp=datetime.local_to_gmt(time_summer)
     
     self.assertEqual(gmtstamp, '20120826211248')
     
     #today=datetime.now()
     
     #print(today)
     
     """
Exemplo n.º 2
0
    app.add_hook('after_request', save_session)
    #def 
    """
    app = SessionMiddleware(app, config.session_opts, environ_key=config.cookie_name)

# Clean last slash

@hook('before_request')
def strip_path():
    request.environ['PATH_INFO'] = request.environ['PATH_INFO'].rstrip('/')
    
# Set error screen if not debug setted

if config.debug==False:
    @error(404)
    def error404(error):
        return 'Error: page not found'

set_timezone()

def run_app(app):

    run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
"""
if __name__ == "__main__":
    run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
    #else:
        #return run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
"""