def setup_app(command, conf, vars): """Place any commands to setup fplan here""" load_environment(conf.global_conf, conf.local_conf) # Create the tables if they don't already exist meta.metadata.create_all(bind=meta.engine) if len(meta.Session.query(User).all())==0: user1 = User(u"anders.musikka", u"password") meta.Session.add(user1) meta.Session.flush() meta.Session.commit()
def setup_app(command, conf, vars): """Place any commands to setup fplan here""" load_environment(conf.global_conf, conf.local_conf) # Create the tables if they don't already exist meta.metadata.create_all(bind=meta.engine) if len(meta.Session.query(User).all()) == 0: user1 = User(u"anders.musikka", u"password") meta.Session.add(user1) meta.Session.flush() meta.Session.commit()
def ensure_loaded(): global loaded global loading if not loaded: assert not loading loading=True try: conf = appconfig('config:%s'%(os.path.join(os.getenv("SWFP_ROOT"),"development.ini"),)) load_environment(conf.global_conf, conf.local_conf) except Exception: loading=False raise loaded=True
def ensure_loaded(): global loaded global loading if not loaded: assert not loading loading = True try: conf = appconfig( 'config:%s' % (os.path.join(os.getenv("SWFP_ROOT"), "development.ini"), )) load_environment(conf.global_conf, conf.local_conf) except Exception: loading = False raise loaded = True
if what=='METAR': return "https://www.aro.lfv.se/Links/Link/ViewLink?TorLinkId=300&type=MET" print "Geturl uhandled:",what,area raise #def test_get_metar(): if __name__=='__main__': from sqlalchemy import engine_from_config from paste.deploy import appconfig from fplan.config.environment import load_environment conf = appconfig('config:%s'%(os.path.join(os.getcwd(),"development.ini"),)) load_environment(conf.global_conf, conf.local_conf) print "Running" print "Shared:",meta.Session.query(SharedTrip).filter(SharedTrip.user=="hej").all() print get_some(*sys.argv[1:]) meta.Session.flush() meta.Session.commit() def test_metar_age(): class Taf():pass t=Taf() t.text="312020Z akdsjfal dfkj" age=get_data_age(t,lambda:datetime(2013,1,1,0,20)) #print age assert age==timedelta(0,3600*4) def test_metar_age2(): class Taf():pass
fplan.lib.purge_temp_dirs.purge_all_old_basic() if debug: print "Yes exit" sys.exit() else: print "Chose to not update aipdata. Cur hour: %d, last_update: %s, now: %s" % ( d.hour, last_update, datetime.utcnow()) pass # No longer constantly re-rendering #os.system("nice python fplan/lib/tilegen_unithread.py 9") except Exception, cause: print "aipdata-update, Exception:", repr(cause) raise if __name__ == '__main__': from sqlalchemy import engine_from_config from paste.deploy import appconfig from fplan.config.environment import load_environment conf = appconfig('config:%s' % (os.path.join(os.getcwd(), "development.ini"), )) load_environment(conf.global_conf, conf.local_conf) print sys.argv if not ("debug" in sys.argv): debug = False print "Debug:", debug time.sleep(2) if len(sys.argv) > 1 and sys.argv[1]: single_force = True #while True: run_update_iteration()
def make_app(global_conf, full_stack=True, static_files=True, **app_conf): """Create a Pylons WSGI application and return it ``global_conf`` The inherited configuration for this application. Normally from the [DEFAULT] section of the Paste ini file. ``full_stack`` Whether this application provides a full WSGI stack (by default, meaning it handles its own exceptions and errors). Disable full_stack when this application is "managed" by another WSGI middleware. ``static_files`` Whether this application serves its own static files; disable when another web server is responsible for serving them. ``app_conf`` The application's local configuration. Normally specified in the [app:<name>] section of the Paste ini file (where <name> defaults to main). """ # Configure the Pylons environment load_environment(global_conf, app_conf) # The Pylons WSGI app app = PylonsApp() # Routing/Session/Cache Middleware app = RoutesMiddleware(app, config['routes.map']) app = SessionMiddleware(app, config) app = CacheMiddleware(app, config) # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) if asbool(full_stack): # Handle Python exceptions app = ErrorHandler(app, global_conf, **config['pylons.errorware']) # Display error documents for 401, 403, 404 status codes (and # 500 when debug is disabled) if asbool(config['debug']): app = StatusCodeRedirect(app) else: app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) # Establish the Registry for this application app = RegistryManager(app) if asbool(static_files): # Serve static files print "Serving static content from ",config['pylons.paths']['static_files'] static_app = StaticURLParser(config['pylons.paths']['static_files']) #tile_dir=config['tile_dir'] #assert tile_dir.endswith("/") #if not os.path.exists(tile_dir+"tiles/"): # raise Exception("%s must exist, and be a directory with map tiles"%(tile_dir+"tiles/")) #static_app_tiles = StaticURLParser( # tile_dir, # root_directory=tile_dir+"tiles/") app = Cascade([static_app, app]) return app