def update_prompt(self):
     if self.connected:
         self.prompt = "[" + colorize(self.serverName,
                                      "green") + ":" + self.root + " ]% "
     else:
         self.prompt = "[" + colorize("disconnected",
                                      "red") + ":" + self.root + " ]% "
示例#2
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" ) )
 def __setHost( self, host ):
   hostList = host.split( ':' )
   self.host = hostList[0]
   if len( hostList ) == 2:
     self.port = hostList[1]
   else:
     self.port = None
   print "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
示例#4
0
 def __setHost( self, host ):
   hostList = host.split( ':' )
   self.host = hostList[0]
   if len( hostList ) == 2:
     self.port = hostList[1]
   else:
     self.port = None
   print "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 __init__(self, host=None):
     cmd.Cmd.__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)
 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 ""
 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 ""
示例#8
0
 def __init__( self, host = None ):
   cmd.Cmd.__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 )
 def __init__( self, host = None ):
   cmd.Cmd.__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 = ''
 def __init__(self, host=None):
     cmd.Cmd.__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 = ''
示例#11
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" ),
       else:
         print line
   except:
     _showTraceback()
示例#12
0
文件: CSCLI.py 项目: Sbalbp/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 ):
   cmd.Cmd.__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 = ''
   # store history
   histfilename = os.path.basename(sys.argv[0])
   historyFile = os.path.expanduser( "~/.dirac/%s.history" % histfilename[0:-3])
   if not os.path.exists( os.path.dirname(historyFile) ):
     os.makedirs( 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):
     cmd.Cmd.__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 = ''
     # store history
     histfilename = os.path.basename(sys.argv[0])
     historyFile = os.path.expanduser("~/.dirac/%s.history" %
                                      histfilename[0:-3])
     if not os.path.exists(os.path.dirname(historyFile)):
         os.makedirs(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)
示例#15
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" ),
       else:
         print line
   except:
     _showTraceback()
示例#16
0
文件: CSCLI.py 项目: Sbalbp/DIRAC
 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 __errMsg(self, errMsg):
     print "%s %s" % (colorize("[ERROR]", "red"), errMsg)
 def update_prompt(self):
   if self.connected:
     self.prompt = "[" + colorize(self.serverName, "green") + ":" + self.root + " ]% "
   else:
     self.prompt = "[" + colorize("disconnected", "red") + ":" + self.root + " ]% "
 def __errMsg( self, errMsg ):
   print "%s %s" % ( colorize( "[ERROR]", "red" ), errMsg )
 def __errMsg( self, errMsg ):
   gLogger.error( "%s %s" % ( colorize( "[ERROR]", "red" ), errMsg ) )
示例#21
0
 def __errMsg( self, errMsg ):
   gLogger.error( "%s %s" % ( colorize( "[ERROR]", "red" ), errMsg ) )