def update_server(project): log = task.logger conf = task.conf project_id = project["id"] log.info("--- [{0}] --------------------------------------------".format(project_id)) projects_list = conf.get("website.projects_list") if projects_list is None: log.warn( "The project can not be registered on the website server as the configuration 'website.projects_list' is not defined" ) return user_id = conf.get("website.user_id") if user_id is None: log.warn( "The project can not be registered on the website server as the 'user_id' was not found in the configuration" ) return website_path = project["website"] onexus = Onexus(projects_list, logger=log) onexus.add_project(user_id, project_id, website_path)
def case_removed(case): case_path = case.properties["path"] case_temp_path = case.properties["temp_path"] user = case.owner onexus_projects = wok_server.conf.get("website.projects_list") if onexus_projects is not None and os.path.exists(os.path.join(case_path, "website")): wok_server.logger.info("[{}] Removing Onexus project {} ...".format(user.nick, case.name)) onexus = Onexus(onexus_projects) onexus.remove_project(user.nick, case.name) wok_server.logger.info("[{}] Removing case files {} ...".format(user.nick, case.name)) if os.path.exists(case_path): shutil.rmtree(case_path) if os.path.exists(case_temp_path): shutil.rmtree(case_temp_path)
def case_removed(case, **kwargs): conf = wok_server.engine.projects.project_conf(PROJECT_NAME, platform_name=DEFAULT_PLATFORM_NAME) conf["user_id"] = case.owner.nick conf["workspace"] = DEFAULT_WORKSPACE results_path = get_results_path(conf) project_path = os.path.join(results_path, case.properties["path"]) user = case.owner onexus_projects = conf.get("website.projects_list") if onexus_projects is not None and os.path.exists(os.path.join(project_path, "website")): wok_server.logger.info("[{}] Removing Onexus project {} ...".format(user.nick, case.name)) onexus = Onexus(onexus_projects) onexus.remove_project(user.nick, case.name) wok_server.logger.info("[{}] Removing case files {} ...".format(user.nick, case.name)) if os.path.exists(project_path): shutil.rmtree(project_path)
def remove_project(self, conn, user_id, proj_id): project = self.get_project(conn, user_id, proj_id) if project is None: return c = conn.cursor() c.execute("DELETE FROM projects WHERE user_id = ? AND proj_id = ?", (user_id, proj_id)) c.close() if self.onexus_projects is not None and os.path.exists(os.path.join(project.path, "website")): onexus = Onexus(self.onexus_projects) onexus.remove_project(user_id, proj_id) if os.path.exists(project.path): shutil.rmtree(project.path) if os.path.exists(project.temp_path): shutil.rmtree(project.temp_path)