def upgrade(self): print("[Upgrader]: Starting update: Changing from GWT to new Non-GWT client") # UPGRADE ACTION 1: Old 'dummy' type experiments are now 'js' experiments. connection_url = self.db_conf.build_url() engine = create_engine(connection_url, echo=False, convert_unicode=True) Session = sessionmaker(bind=engine) session = Session() try: db_experiments = session.query(model.DbExperiment).filter_by(client='dummy').all() for db_exp in db_experiments: db_exp.client = 'js' # Add html.file db_param = model.DbExperimentClientParameter() db_param.experiment_id = db_exp.id db_param.parameter_name = 'html.file' db_param.value = 'nativelabs/dummy.html' db_param.parameter_type = 'string' session.add(db_exp) session.add(db_param) print("Experiment {0} had client 'dummy' and now has client 'js'".format(db_exp.name)) session.commit() finally: session.close() print("[Upgrader]: DONE: Changed Dummy experiments to type JS") # UPGRADE ACTION 2: JS experiments should have builtin set to true (all of them are builtin for now). session = Session() try: db_experiments = session.query(model.DbExperiment).filter_by(client='js').all() for db_exp in db_experiments: db_builtin_param = session.query(model.DbExperimentClientParameter).filter_by(experiment_id=db_exp.id, parameter_name='builtin').first() if db_builtin_param is None: db_builtin_param = model.DbExperimentClientParameter() db_builtin_param.experiment = db_exp db_builtin_param.parameter_name = 'builtin' db_builtin_param.parameter_type = 'bool' db_builtin_param.value = "True" session.add(db_builtin_param) session.commit() finally: session.close() print("[Upgrader]: DONE: All JS experiments now have a builtin parameter set to True") # UPGRADE ACTION 3: Call httpd-config-generate script. httpd_config_generate(self.directory) print("[Upgrader]: DONE: Called http-config-generate to upgrade Apache configuration files") print("[Upgrader]: UPGRADE FINISHED.")
def upgrade(self): os.mkdir(self.pub_dir) httpd_config_generate(self.directory)