def migrate(event, context): prod = '-dev-' not in context.function_name reset = event.get('reset') if prod and reset: reset = False LOGGER.warn('Cannot reset the prod environment') with psql_connection(SECRETS['DB_PASSWORD']) as psql: result = migrations.run_migrations(psql, reset_db=reset) psql.commit() return api_response(200, result)
def setup_tables(): db.create_all() if Config.get() is None: logger.info("Creating Config single instance") Config.query.delete() c = Config( version=VERSION, login=DEFAULT_LOGIN, password=Config.hash(DEFAULT_PASSWORD), default_refresh_interval=DEFAULT_REFRESH_INTERVAL, default_max_entries=DEFAULT_MAX_ENTRIES, default_highlight_news=DEFAULT_HIGHLIGHT_NEWS, default_entries_per_page=DEFAULT_ENTRIES_PER_PAGE, ) db.session.add(c) db.session.commit() Config.refresh_instance() elif Config.get().version != VERSION: run_migrations(from_version=Config.get().version) db.engine.echo = app.config['SQL_DEBUG']
def migrate(event, context): prod = "-dev-" not in context.function_name reset = event.get("reset") if prod and reset: reset = False LOGGER.warn("Cannot reset the prod environment") with psql_connection(SECRETS["DB_PASSWORD"], SECRETS["DB_USERNAME"]) as psql: result = migrations.run_migrations(psql, reset_db=reset) psql.commit() return api_response(200, result)
def migrate(event, context): production = "-development-" not in context.function_name reset = event.get("reset") if production and reset: reset = False LOGGER.warn("Cannot reset the production environment") if reset: with psql_connection(DB_PASSWORD, "scoreboard", reset=True) as psql: migrations.reset(psql) with psql_connection(DB_PASSWORD, "scoreboard") as psql: result = migrations.run_migrations(psql) psql.commit() return api_response(200, result)
def run(self): # pylint: disable=W0221 """ Overrides DPY's event loop initialization logic allowing for more fine control. """ try: self.loop.run_until_complete(migrations.run_migrations()) self.loop.run_until_complete(self.start(self.config["token"])) except KeyboardInterrupt: print("\nKeyboard Interrupt Detected") self.loop.run_until_complete(self.close()) return except Exception: # pylint: disable=W0703 traceback.print_exc(file=sys.stderr) return # Perform a graceful shutdown self.loop.run_until_complete(self.close()) print("\nConnection Closed")
logging.basicConfig(level=logging.WARNING) app = Flask(__name__) CORS(app, supports_credentials=True) # app.config['SECRET_KEY'] = 'secret!' socketio = SocketIO(app) ALLOWED_EXTENSIONS = ["apk"] EV_PACKAGE_PUSHED = "update_push" EV_APP_STARTED = "appStarted" EV_APP_DEPLOYED = "appDeployed" EV_APP_DEPLOYING = "appDeploying" EV_APP_INSTALLED = "appInstalled" # Notification events EV_NOTIFY_DEPLOYING = "deploymentNotification" migrations.run_migrations() @app.route('/') def hello_world(): return 'Hello World!' def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS def broadcast_creation(pkginfo): ev = 'package_creation' if pkginfo['is_new'] else 'package_updated' payload = {