def __init__(self): self.versionsDB = Versions.Versions(mongodb) self.toolDB = Tool.Tool(mongodb) self.tagDB = Tags.Tags() self.toolsetdb = ToolSet.ToolSet(mongodb) self.deploymentunitsetdb = DeploymentUnitSet.DeploymentUnitSet() self.deploymentunitdb = DeploymentUnit.DeploymentUnit() self.teamDB = Teams.Teams(mongodb) self.machineDB = Machine.Machine(mongodb) self.machinegroupsDB = MachineGroups.MachineGroups(mongodb) self.toolsetdb = ToolSet.ToolSet(mongodb) self.userdb = Users.Users(mongodb) self.roledb = Role.Role(mongodb)
def __init__(self): self.db = mongodb self.current_import_path = import_full_path if self.current_import_path in [None, ""]: raise ValueError("Import path was not provided") if not os.path.exists(self.current_import_path): os.makedirs(self.current_import_path) if not os.access(os.path.dirname(self.current_import_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_import_path) self.current_export_path = export_full_path if self.current_export_path in [None, ""]: raise ValueError("Export path was not provided") if not os.path.exists(self.current_export_path): os.makedirs(self.current_export_path) if not os.access(os.path.dirname(self.current_export_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_export_path) self.configdb = Config.Config(self.db) self.versionsDB = Versions.Versions(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentFieldsDB = DeploymentFields.DeploymentFields(self.db) self.machineDB = Machine.Machine(self.db) self.syncDb = Sync.Sync(self.db) self.mailer = Mailer.Mailer() self.syncRequestDb = SyncRequest.SyncRequest(self.db) self.buildsDB = Build.Build() self.documentsDB = Documents.Documents(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentunitDB = DeploymentUnit.DeploymentUnit() self.deploymentunitsetDB = DeploymentUnitSet.DeploymentUnitSet() self.mediaFilesDB = MediaFiles.MediaFiles(self.db) self.tagsDB = Tags.Tags() self.preRequisitesDB = PreRequisites.PreRequisites(self.db) self.logo_path = logo_path self.full_logo_path = logo_full_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.systemDetailsDb = SystemDetails.SystemDetails(self.db) self.systemDetail = self.systemDetailsDb.get_system_details_single() self.statedb = State.State(self.db) if not self.systemDetail: raise Exception("systemDeatils not found") self.config_id = 9 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.flexAttrDB = FlexibleAttributes.FlexibleAttributes()
from DBUtil import Tags from Services import TeamService, TagHelperService, HelperServices from Services.AppInitServices import authService from settings import mongodb from flask_restplus import Resource from modules.apimodels import TagModel from modules.apimodels.Restplus import api, header_parser from modules.apimodels.GenericReponseModel import generic_response_model tagAPI = Blueprint('TagAPI', __name__) tagAPINs = api.namespace('tag', description='Tag Operations') # get global db connection db = mongodb tagDB = Tags.Tags() teamService = TeamService.TeamService() @tagAPINs.route('/all', methods=['GET']) class getalltag(Resource): @api.expect(header_parser, validate=True) @api.marshal_with(TagModel.get_all_tags_response_model) @authService.authorized def get(self): return {"result": "success", "data": list(tagDB.get_tags())}, 200 @tagAPINs.route('/view/<id>', methods=['GET']) @api.doc(params={'id': 'Tag ID'}) class getTagbyID(Resource):
import TeamService from DBUtil import Teams, Machine, Users, Role, DeploymentRequest, DeploymentUnitSet, DeploymentUnit, MachineGroups, Tool, ToolSet, Tags from settings import mongodb from bson.objectid import ObjectId teamsdb = Teams.Teams(mongodb) machinedb = Machine.Machine(mongodb) userdb = Users.Users(mongodb) roledb = Role.Role(mongodb) teamService = TeamService.TeamService() deploymentrequestdb = DeploymentRequest.DeploymentRequest(mongodb) deploymentunitsetdb = DeploymentUnitSet.DeploymentUnitSet() deploymentunitdb = DeploymentUnit.DeploymentUnit() machinegroupdb = MachineGroups.MachineGroups(mongodb) toolsetdb = ToolSet.ToolSet(mongodb) tooldb = Tool.Tool(mongodb) tagdb = Tags.Tags() def delete_tag(uid): """Start Tag Deletion""" if ObjectId(uid) in teamService.get_active_tags(): raise Exception("This tag cannot be removed as it is in use") dus = deploymentunitdb.GetAllDeploymentUnits(None, None, False, {"tag": { "$in": [str(uid)] }}) present_in_du = [] for du in dus: if du.get("name") not in present_in_du: present_in_du.append(du.get("name"))