Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def manageProxies(self):
if not authorizeAction():
return render("/login.mako")
c.select = self.__getSelectionData()
return render( "/systems/framework/manageProxies.mako" )
@jsonify
def newWF(self):
if not authorizeAction():
return S_ERROR("You are not authorised to create workflows")
Name = request.params.get('name','')
Type = request.params.get('type','')
if not Name:
return S_ERROR("You have to specify valid unique workflow name");
try:
wf = Workflow(name=Name)
wf.setType(Type)
wfxml = wf.toXML()
RPC = getRPCClient("ProductionManagement/ProductionManager")
result = RPC.publishWorkflow(str(wfxml),False)
except Exception,msg:
return S_ERROR(msg)
if not result['OK']:
return result
return S_OK("Created")
def saveWFLocal(self,id):
if not authorizeAction():
return self.__authError()
wf = request.params.get('JSONStr','')
if wf != '':
result = _JSToWorkflow(wf)
if self.__servError(result):
return render("/error.mako")
response.headers['Content-type'] = "application/workflow"
return result['Value'].toXML()
else:
result = self.__getWorkflow(id)
if self.__servError(result):
return render("/error.mako")
response.headers['Content-type'] = "application/workflow"
return result['Value'];
@jsonify
def getProxiesList(self):
if not authorizeAction():
return {"success":"false","error":"You are not authorize to access these data"}
start, limit, sort, req = self.__request()
rpcClient = getRPCClient( "Framework/ProxyManager" )
retVal = rpcClient.getContents( req, sort, start, limit )
if not retVal[ 'OK' ]:
return {"success":"false","error":retVal["Message"]}
svcData = retVal[ 'Value' ]
proxies = []
dnMap = {}
gLogger.info("!!! RESULT: %s" % str(svcData) )
for record in svcData[ 'Records' ]:
proxies.append( { 'proxyid': "%s@%s" % ( record[1], record[2] ),
'username' : str( record[0] ),
'UserDN' : record[1],
'UserGroup' : record[2],
'ExpirationTime' : str( record[3] ),
def deleteActivity( self ):
"""
Delete an activity
"""
if not authorizeAction():
return render( "/error.mako" )
if not 'sid' in request.params or not 'aid' in request.params:
c.error = "Missing ids to delete!"
return render( "/error.mako" )
try:
sid = int( request.params[ 'sid' ] )
aid = int( request.params[ 'aid' ] )
except Exception, e:
c.error = "id is not valid"
return render( "/error.mako" )
rpcClient = getRPCClient( "Monitoring/Server" )
retVal = rpcClient.deleteActivity( sid, aid )
if not retVal[ 'OK' ]:
c.error = "Error while deleting activity %s" % retVal[ 'Message' ]
return render( "/error.mako" )
return redirect_to( 'manageActivities' )
def manageActivities( self ):
"""
Return template for managing views
"""
if not authorizeAction():
return render( "/error.mako" )
rpcClient = getRPCClient( "Monitoring/Server" )
retVal = rpcClient.getActivities()
if not retVal[ 'OK' ]:
c.error = retVal[ 'Message' ]
return render( "/error.mako" )
c.activitiesDict = retVal[ 'Value' ]
return render( "/systems/monitoring/manageActivities.mako" )
@jsonify
def copyWF(self):
if not authorizeAction():
return S_ERROR("You are not authorised to copy workflows")
reqjs = request.params.get('JSONStr','')
try:
req = simplejson.loads(reqjs)
name = req["Name"]
new_name = req["NewName"]
path = req["Path"]
except Exception,msg:
return S_ERROR(msg)
if name == new_name:
return S_ERROR("You can't use the same workflow name")
result = self.__getWorkflow(name)
if not result["OK"]:
return result
wf = fromXMLString(result['Value'])
wf.setName(new_name)
@jsonify
def moveWF(self):
if not authorizeAction():
return S_ERROR("You are not authorised to move workflows")
reqjs = request.params.get('JSONStr','')
try:
req = simplejson.loads(reqjs)
name = req["Name"]
new_name = req["NewName"]
path = req["Path"]
except Exception,msg:
return S_ERROR(msg)
result = self.__getWorkflow(name)
if not result["OK"]:
return result
wf = fromXMLString(result['Value'])
wf.setName(new_name)
wf.setType(path)
try:
def showHistory( self ):
if not authorizeAction():
return render( "/error.mako" )
rpcClient = getRPCClient( gConfig.getValue( "/DIRAC/Configuration/MasterServer", "Configuration/Server" ) )
retVal = rpcClient.getCommitHistory()
if retVal[ 'OK' ]:
cDict = { 'numVersions' : 0, 'versions' : [] }
for entry in retVal[ 'Value' ]:
cDict[ 'numVersions' ] += 1
cDict[ 'versions' ].append( { 'version' : entry[1], 'commiter' : entry[0] } )
c.versions = simplejson.dumps( cDict )
return render( "/systems/configuration/showHistory.mako" )
else:
c.error = retVal[ 'Message' ]
return render( "/error.mako" )
def manageViews( self ):
"""
Return template for managing views
"""
if not authorizeAction():
return render( "/error.mako" )
rpcClient = getRPCClient( "Monitoring/Server" )
retVal = rpcClient.getViews( False )
if not retVal[ 'OK' ]:
c.error = retVal[ 'Message' ]
return render( "/error.mako" )
c.viewsList = retVal[ 'Value' ]
return render( "/systems/monitoring/manageViews.mako" )