當前位置: 首頁>>代碼示例>>Python>>正文


Python Modificator.rollbackToVersion方法代碼示例

本文整理匯總了Python中DIRAC.ConfigurationSystem.private.Modificator.Modificator.rollbackToVersion方法的典型用法代碼示例。如果您正苦於以下問題:Python Modificator.rollbackToVersion方法的具體用法?Python Modificator.rollbackToVersion怎麽用?Python Modificator.rollbackToVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DIRAC.ConfigurationSystem.private.Modificator.Modificator的用法示例。


在下文中一共展示了Modificator.rollbackToVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: CSCLI

# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import rollbackToVersion [as 別名]

#.........這裏部分代碼省略.........
      argsList = args.split()
      limit = 100
      if len( argsList ) > 0:
        limit = int( argsList[0] )
      history = self.modificator.getHistory( limit )
      print "%s recent commits:" % limit
      for entry in history:
        self.printPair( entry[0], entry[1], "@" )
    except:
      _showTraceback()

  def do_showDiffWithServer( self, dummy ):
    """
    Shows diff with lastest version in server
    Usage: showDiffWithServer
    """
    try:
      diffData = self.modificator.showCurrentDiff()
      print "Diff with latest from server ( + local - remote )"
      for line in diffData:
        if line[0] in ( '-' ):
          print colorize( line, "red" )
        elif line[0] in ( '+' ):
          print colorize( line, "green" )
        elif line[0] in ( '?' ):
          print colorize( line, "yellow" ),
        else:
          print line
    except:
      _showTraceback()

  def do_showDiffBetweenVersions( self, args ):
    """
    Shows diff between two versions
    Usage: showDiffBetweenVersions <version 1 with spaces> <version 2 with spaces>
    """
    try:
      argsList = args.split()
      if len( argsList ) < 4:
        print "What are the two versions to compare?"
        return
      v1 = " ".join ( argsList[0:2] )
      v2 = " ".join ( argsList[2:4] )
      print "Comparing '%s' with '%s' " % ( v1, v2 )
      diffData = self.modificator.getVersionDiff( v1, v2 )
      print "Diff with latest from server ( + %s - %s )" % ( v2, v1 )
      for line in diffData:
        if line[0] in ( '-' ):
          print colorize( line, "red" )
        elif line[0] in ( '+' ):
          print colorize( line, "green" )
        elif line[0] in ( '?' ):
          print colorize( line, "yellow" ),
        else:
          print line
    except:
      _showTraceback()

  def do_rollbackToVersion( self, args ):
    """
    rolls back to user selected version of the configuration
    Usage: rollbackToVersion <version with spaces>>
    """
    try:
      argsList = args.split()
      if len( argsList ) < 2:
        print "What version to rollback?"
        return
      version = " ".join ( argsList[0:2] )
      choice = raw_input( "Do you really want to rollback to version %s? yes/no [no]: " % version )
      choice = choice.lower()
      if choice in ( "yes", "y" ):
        response = self.modificator.rollbackToVersion( version )
        if response[ 'OK' ]:
          self.modifiedData = False
          print "Rolled back."
          self.modificator.loadFromRemote()
        else:
          print "Error sending data, server said: %s" % response['Message']
    except:
      _showTraceback()

  def do_mergeWithServer( self, dummy ):
    """
    Shows diff with lastest version in server
    Usage: diffWithServer
    """
    try:
      choice = raw_input( "Do you want to merge with server configuration? yes/no [no]: " )
      choice = choice.lower()
      if choice in ( "yes", "y" ):
        retVal = self.modificator.mergeWithServer()
        if retVal[ 'OK' ]:
          print "Merged"
        else:
          print "There was an error: ", retVal[ 'Message' ]
      else:
        print "Merge aborted"
    except:
      _showTraceback()
開發者ID:ahaupt,項目名稱:DIRAC,代碼行數:104,代碼來源:CSCLI.py

示例2: __rollback

# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import rollbackToVersion [as 別名]
    processedData = self.__generateHTMLDiff( diffGen )
    return self.write_message( json.dumps( {"success":1, "op":"showDiff", "lines":processedData["lines"], "totalLines": processedData["totalLines"], "html":self.render_string( "ConfigurationManager/diffConfig.tpl",
                                                                                                         titles = ( "From version %s" % fromDate, "To version %s" % toDate ),
                                                                                                         diffList = processedData["diff"] )} ) )

  def __rollback( self, params ):
    rollbackVersion = ""
    if not self.__authorizeAction():
      raise WErr( 500, "You are not authorized to get diff's!! Bad boy!" )
    try:
      rollbackVersion = str( params[ 'rollbackToVersion' ] )
    except Exception, e:
      raise WErr( 500, "Can't decode params: %s" % e )
    rpcClient = RPCClient( gConfig.getValue( "/DIRAC/Configuration/MasterServer", "Configuration/Server" ) )
    modCfg = Modificator( rpcClient )
    retVal = modCfg.rollbackToVersion( rollbackVersion )
    if retVal[ 'OK' ]:
      return {"success":1, "op":"rollback", "version":rollbackVersion}
    else:
      return {"success":0, "op":"rollback", "message":retVal['Value']}


  def __setCommiter( self ):

    sessionData = self.getSessionData()

    commiter = "%[email protected]%s - %s" % ( sessionData["user"]["username"],
                                sessionData["user"]["group"],
                                Time.dateTime().strftime( "%Y-%m-%d %H:%M:%S" ) )
    self.__configData[ 'cfgData' ].commiterId = commiter
開發者ID:zmathe,項目名稱:WebAppDIRAC,代碼行數:32,代碼來源:ConfigurationManagerHandler.py


注:本文中的DIRAC.ConfigurationSystem.private.Modificator.Modificator.rollbackToVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。