def ShareTool(self, tool_id, user_name, permissions): tool = self.GetTool(tool_id) user = User.objects.get(username=user_name) Tools.ShareTool(self.user, tool, user, Run=permissions["Run"], Export=permissions["Export"], Publish=permissions["Publish"], Edit=permissions["Edit"], Admin=permissions["Admin"] )
def AddTool(self, tool): with transaction.atomic(): #create the tool tool = Tools.AddTool(self.user, tool["ToolName"], tool["Category"], tool["ToolDescription"], False) #create the development tool version toolversion = ToolVersions.AddToolVersion(self.user, tool, "dev", tool.ToolDescription, "") self.make_tool_directory(tool.ToolID, toolversion.ToolVersionNum) return toolversion
def UpdateTool(self, tool_id, version): tool = self.GetTool(tool_id) with transaction.atomic(): #update tool details tool_details = version["Tool"] tool = Tools.UpdateTool(self.user, tool, ToolName=tool_details["ToolName"], CategoryID=tool_details["CategoryID"], ToolDescription=version["ShortDescription"] ) #update version details tool_version = self.GetToolVersion(tool, "dev") tool_version = ToolVersions.UpdateToolVersion(self.user, tool_version, version["ShortDescription"], version["LongDescription"], version["Command"] ) #update parameters for i, p in enumerate(version["Parameters"]): parameter = self.UpdateParameter(p, i) #update/add expected outputs for o in version["ExpectedOutputs"]: if o["ExpectedOutputID"]: self.UpdateExpectedOutput(o) else: self.AddExpectedOutput(tool, o) #update/add default resources Resources.UpdateResources(self.user, tool_version, settings.JMS_SETTINGS["resource_manager"]["name"], version["Resources"] ) return tool
def UnshareTool(self, tool_id, user_name): tool = self.GetTool(tool_id) user = User.objects.get(username=user_name) Tools.UnshareTool(self.user, tool, user)
def DeleteToolFile(self, tool_id, filename): path = os.path.join(self.base_dir, "tools/%s/dev/%s" % (tool_id, filename)) Tools.DeleteFile(self.user, tool_id, path)
def ReadToolFile(self, tool_id, filename): path = os.path.join(self.base_dir, "tools/%s/dev/%s" % (tool_id, filename)) return Tools.ReadFile(self.user, tool_id, path)
def SaveToolFile(self, tool_id, filename, content): tool_dir = self.make_tool_directory(int(tool_id), "dev") path = os.path.join(tool_dir, filename) Tools.SaveFile(self.user, tool_id, path, content)
def UploadToolFiles(self, tool_id, file_dict): path = self.make_tool_directory(int(tool_id), "dev") return Tools.UploadFiles(self.user, tool_id, path, file_dict)
def GetToolFiles(self, tool_id): path = self.make_tool_directory(int(tool_id), "dev") return Tools.GetFileList(self.user, tool_id, path)
def AddParameter(self, tool_id, parameter_name, parent_id=None): tool = Tools.GetTool(self.user, tool_id) return Parameters.AddParameter(self.user, tool, parameter_name, parent_id)
def UpdateToolAvailability(self, tool_id, publicInd): tool = self.GetTool(tool_id) return Tools.UpdateAvailability(self.user, tool, publicInd)
def DeleteTool(self, tool_id): Tools.DeleteTool(self.user, tool_id)
def GetTool(self, tool_id): return Tools.GetTool(self.user, tool_id)
def GetTools(self): tools = Tools.GetTools(self.user) return tools