当前位置: 首页>>代码示例>>Python>>正文


Python DiracAdmin.csSetOptionComment方法代码示例

本文整理汇总了Python中DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.csSetOptionComment方法的典型用法代码示例。如果您正苦于以下问题:Python DiracAdmin.csSetOptionComment方法的具体用法?Python DiracAdmin.csSetOptionComment怎么用?Python DiracAdmin.csSetOptionComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Interfaces.API.DiracAdmin.DiracAdmin的用法示例。


在下文中一共展示了DiracAdmin.csSetOptionComment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SoftwareAdder

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csSetOptionComment [as 别名]

#.........这里部分代码省略.........
    return appTar

  def notifyAboutNewSoftware(self):
    """Send an email to the mailing list if a new software version was defined"""

    #Only send email when something was actually added
    if not self.modifiedCS:
      return

    subject = '%s %s added to DIRAC CS' % (self.appName, self.appVersion)
    msg = 'New application %s %s declared into Configuration service\n %s' % (self.appName,
                                                                              self.appVersion,
                                                                              self.comment)
    from DIRAC.Core.Security.ProxyInfo import getProxyInfo
    from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getUserOption
    from DIRAC.FrameworkSystem.Client.NotificationClient       import NotificationClient

    notifyClient = NotificationClient()
    gLogger.notice('Sending mail for software installation to %s' % (self.mailadress))
    res = getProxyInfo()
    if not res['OK']:
      sender = '[email protected]'
    else:
      if 'username' in res['Value']:
        sender = getUserOption(res['Value']['username'],'Email')
      else:
        sender = '[email protected]'
    gLogger.info('*'*80)# surround email with stars
    res = notifyClient.sendMail(self.mailadress, subject, msg, sender, localAttempt = False)
    gLogger.info('*'*80)
    if not res[ 'OK' ]:
      gLogger.error('The mail could not be sent: %s' % res['Message'])



  def uploadTarBall(self):
    """get the tarballURL from the CS and upload the tarball there. Exits when error is encountered"""
    gLogger.notice("Uploading TarBall to the Grid")
    from ILCDIRAC.Core.Utilities.FileUtils import upload
    tarballurl = gConfig.getOption("%(softSec)s/%(platform)s/%(appname)s/TarBallURL" % self.parameter, "")
    if not tarballurl['OK'] or not tarballurl['Value']:
      gLogger.error('TarBallURL for application %(appname)s not defined' % self.parameter)
      dexit(255)
    res = upload(tarballurl['Value'], self.appTar)
    if not res['OK']:
      gLogger.error("Upload to %s failed" % tarballurl['Value'], res['Message'])
      dexit(255)


  def addVersionToCS(self):
    """adds the version of the application to the CS"""
    gLogger.notice("Adding version %(appVersion)s to the CS" % self.parameter)
    existingVersions = gConfig.getSections("%(softSec)s/%(platform)s/%(appname)s" % self.parameter, [])
    if not existingVersions['OK']:
      gLogger.error("Could not find all versions available in CS: %s" % existingVersions['Message'])
      dexit(255)
    if self.appVersion in existingVersions['Value']:
      gLogger.always('Application %s %s for %s already in CS, nothing to do' % (self.appName.lower(),
                                                                                self.appVersion,
                                                                                self.platform))
      dexit(0)

    result = self.diracAdmin.csSetOption("%(softSec)s/%(platform)s/%(appname)s/%(appVersion)s/TarBall" % self.parameter,
                                         self.parameter['appTar_name'])
    if result['OK']:
      self.modifiedCS = True
    else:
      gLogger.error ("Could not add version to CS")
      dexit(255)

  def addMD5SumToCS(self):
    """adds the MD5Sum of the Tarball fo the CS"""
    gLogger.notice("Adding MD5Sum to CS")
    md5sum = md5.md5(open(self.appTar).read()).hexdigest()
    result = self.diracAdmin.csSetOption("%(softSec)s/%(platform)s/%(appname)s/%(appVersion)s/Md5Sum" % self.parameter,
                                         md5sum)
    if result['OK']:
      self.modifiedCS = True
    else:
      gLogger.error("Could not add md5sum to CS")
      dexit(255)

  def addCommentToCS(self):
    """adds the comment for the TarBall to the CS"""
    gLogger.notice("Adding comment to CS: %s" % self.comment)
    result = self.diracAdmin.csSetOptionComment("%(softSec)s/%(platform)s/%(appname)s/%(appVersion)s/TarBall"% self.parameter,
                                                self.comment)
    if not result['OK']:
      gLogger.error("Error setting comment in CS")

  def addSoftware(self):
    """run all the steps to add software to grid and CS"""

    self.checkConsistency()
    self.addVersionToCS()
    self.addMD5SumToCS()
    self.addCommentToCS()
    self.uploadTarBall()
    self.commitToCS()
    self.notifyAboutNewSoftware()
开发者ID:andresailer,项目名称:ILCDIRAC,代码行数:104,代码来源:dirac-ilc-add-software.py

示例2: len

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csSetOptionComment [as 别名]
    else:
      result = diracAdmin.csSetOption("%s/%s/%s/%s/TarBall" % (softwareSection, platform, appName.lower(),
                                                             appVersion), appTar_name)
      if result['OK']:
        modifiedCS = True
        tarballurl = gConfig.getOption("%s/%s/%s/TarBallURL" % (softwareSection, platform, appName.lower()), "")
        if len(tarballurl['Value']) > 0:
          res = upload(tarballurl['Value'], appTar)
          if not res['OK']:
            gLogger.error("Upload to %s failed" % tarballurl['Value'], res['Value'])
            dexit(255)
      resutl = diracAdmin.csSetOption("%s/%s/%s/%s/Md5Sum" % (softwareSection, platform, appName.lower(),
                                                               appVersion), md5sum)
      if result['OK']:
        modifiedCS = True
      result = diracAdmin.csSetOptionComment("%s/%s/%s/%s/TarBall"%(softwareSection, platform,
                                                                    appName.lower(), appVersion), comment)
      if not result['OK']:
        gLogger.error("Error setting comment in CS")

  else:
    result = diracAdmin.csSetOption("%s/%s/%s/%s/TarBall"%(softwareSection, platform, appName.lower(), appVersion), 
                                    appTar_name)
    if result['OK']:  
      modifiedCS = True
      tarballurl = gConfig.getOption("%s/%s/%s/TarBallURL" % (softwareSection, platform, appName.lower()), "")
      if len(tarballurl['Value']) > 0:
        res = upload(tarballurl['Value'], appTar)
        if not res['OK']:
          gLogger.error("Upload to %s failed" % tarballurl['Value'], res['Value'])
          dexit(255)
    resutl = diracAdmin.csSetOption("%s/%s/%s/%s/Md5Sum" % (softwareSection, platform, appName.lower(), appVersion),   
开发者ID:LCDgit,项目名称:ILCDIRAC,代码行数:34,代码来源:dirac-ilc-add-software.py


注:本文中的DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.csSetOptionComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。