示例#1
0
 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"), end=' ')
             else:
                 print(line)
     except Exception:
         _showTraceback()
示例#2
0
 def update_prompt(self):
     if self.connected:
         self.prompt = "[" + colorize(self.serverName,
                                      "green") + ":" + self.root + " ]% "
     else:
         self.prompt = "[" + colorize("disconnected",
                                      "red") + ":" + self.root + " ]% "
示例#3
0
 def _setConnected(self, connected, writeEnabled):
     self.connected = connected
     self.modifiedData = False
     self.writeEnabled = writeEnabled
     if connected:
         if writeEnabled:
             self.prompt = "(%s)-%s> " % (self.masterURL, colorize("Connected", "green"))
         else:
             self.prompt = "(%s)-%s> " % (self.masterURL, colorize("Connected (RO)", "yellow"))
     else:
         self.prompt = "(%s)-%s> " % (self.masterURL, colorize("Disconnected", "red"))
示例#4
0
文件: CSCLI.py 项目: JanEbbing/DIRAC
 def _setConnected( self, connected, writeEnabled ):
   self.connected = connected
   self.modifiedData = False
   self.writeEnabled = writeEnabled
   if connected:
     if writeEnabled:
       self.prompt = "(%s)-%s> " % ( self.masterURL, colorize( "Connected", "green" ) )
     else:
       self.prompt = "(%s)-%s> " % ( self.masterURL, colorize( "Connected (RO)", "yellow" ) )
   else:
     self.prompt = "(%s)-%s> " % ( self.masterURL, colorize( "Disconnected", "red" ) )
示例#5
0
 def do_connect(self, args):
     """
 Tries to connect to the server
     Usage: connect
 """
     gLogger.info("Trying to connect to server")
     self.connected = False
     self.prompt = "(%s)> " % colorize("Not connected", "red")
     retVal = ReportsClient().ping()
     if retVal['OK']:
         self.prompt = "(%s)> " % colorize("Connected", "green")
         self.connected = True
示例#6
0
 def do_connect( self, args ):
   """
   Tries to connect to the server
       Usage: connect
   """
   gLogger.info( "Trying to connect to server" )
   self.connected = False
   self.prompt = "(%s)> " % colorize( "Not connected", "red" )
   retVal = ReportsClient().pingService()
   if retVal[ 'OK' ]:
     self.prompt = "(%s)> " % colorize( "Connected", "green" )
     self.connected = True
示例#7
0
 def do_connect(self, args):
   """
   Tries to connect to the server
       Usage: connect
   """
   gLogger.info("Trying to connect to server")
   self.connected = False
   self.prompt = "(%s)> " % colorize("Not connected", "red")
   acClient = RPCClient("Accounting/DataStore")
   retVal = acClient.ping()
   if retVal['OK']:
     self.prompt = "(%s)> " % colorize("Connected", "green")
     self.connected = True
示例#8
0
 def do_connect(self, args):
     """
     Tries to connect to the server
         Usage: connect
     """
     gLogger.info("Trying to connect to server")
     self.connected = False
     self.prompt = "(%s)> " % colorize("Not connected", "red")
     acClient = DataStoreClient()
     retVal = acClient.ping()
     if retVal["OK"]:
         self.prompt = "(%s)> " % colorize("Connected", "green")
         self.connected = True
 def __setHost( self, host ):
   hostList = host.split( ':' )
   self.host = hostList[0]
   if len( hostList ) == 2:
     self.port = hostList[1]
   else:
     self.port = None
   gLogger.notice( "Pinging %s..." % self.host )
   result = self.__getClient().ping()
   if result[ 'OK' ]:
     colorHost = colorize( host, "green" )
   else:
     self._errMsg( "Could not connect to %s: %s" % ( self.host, result[ 'Message' ] ) )
     colorHost = colorize( host, "red" )
   self.prompt = '[%s]> ' % colorHost
 def __setHost( self, host ):
   hostList = host.split( ':' )
   self.host = hostList[0]
   if len( hostList ) == 2:
     self.port = hostList[1]
   else:
     self.port = None
   gLogger.notice( "Pinging %s..." % self.host )
   result = self.__getClient().ping()
   if result[ 'OK' ]:
     colorHost = colorize( host, "green" )
   else:
     self._errMsg( "Could not connect to %s: %s" % ( self.host, result[ 'Message' ] ) )
     colorHost = colorize( host, "red" )
   self.prompt = '[%s]> ' % colorHost
示例#11
0
 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"), end=' ')
     except Exception:
         _showTraceback()
示例#12
0
 def do_ls(self, line):
     """ls
 List the sections and options of CS of the current root"""
     if self.connected:
         secs = self.modificator.getSections(self.root)
         opts = self.modificator.getOptions(self.root)
         if line.startswith("-") and "l" in line:
             for i in secs:
                 print colorize(i, "blue") + "  "
             for i in opts:
                 print i + " "
         else:
             for i in secs:
                 print colorize(i, "blue") + "  ",
             for i in opts:
                 print i + " ",
             print ""
示例#13
0
 def do_ls(self, line):
     """ls
 List the sections and options of CS of the current root"""
     if self.connected:
         secs = self.modificator.getSections(self.root)
         opts = self.modificator.getOptions(self.root)
         if line.startswith("-") and "l" in line:
             for i in secs:
                 print colorize(i, "blue") + "  "
             for i in opts:
                 print i + " "
         else:
             for i in secs:
                 print colorize(i, "blue") + "  ",
             for i in opts:
                 print i + " ",
             print ""
示例#14
0
文件: CSCLI.py 项目: JanEbbing/DIRAC
 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 __init__( self, host = None ):

    CLI.__init__( self )
    # Check if Port is given
    self.host = None
    self.port = None
    self.prompt = '[%s]> ' % colorize( "no host", "yellow" )
    if host:
      self.__setHost( host )
    self.cwd = ''
    self.previous_cwd = ''
    self.homeDir = ''
    self.runitComponents = [ "service", "agent", "executor", "consumer" ]

    # store history
    histfilename = os.path.basename(sys.argv[0])
    historyFile = os.path.expanduser( "~/.dirac/%s.history" % histfilename[0:-3])
    mkDir(os.path.dirname(historyFile))
    if os.path.isfile( historyFile ):
      readline.read_history_file( historyFile )
    readline.set_history_length(1000)
    atexit.register( readline.write_history_file, historyFile )
  def __init__( self, host = None ):

    CLI.__init__( self )
    # Check if Port is given
    self.host = None
    self.port = None
    self.prompt = '[%s]> ' % colorize( "no host", "yellow" )
    if host:
      self.__setHost( host )
    self.cwd = ''
    self.previous_cwd = ''
    self.homeDir = ''
    self.runitComponents = [ "service", "agent", "executor", "consumer" ]

    # store history
    histfilename = os.path.basename(sys.argv[0])
    historyFile = os.path.expanduser( "~/.dirac/%s.history" % histfilename[0:-3])
    mkDir(os.path.dirname(historyFile))
    if os.path.isfile( historyFile ):
      readline.read_history_file( historyFile )
    readline.set_history_length(1000)
    atexit.register( readline.write_history_file, historyFile )
示例#17
0
 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" ),
   except:
     _showTraceback()
示例#18
0
 def update_prompt(self):
     if self.connected:
         self.prompt = "[" + colorize(self.serverName, "green") + ":" + self.root + " ]% "
     else:
         self.prompt = "[" + colorize("disconnected", "red") + ":" + self.root + " ]% "