WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Remove semicolons from Console.py. It's a habit.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Remove semicolons from Console.py. It's a habit.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Nov 2005 17:06:10 +0000
Delivery-date: Thu, 10 Nov 2005 17:06:51 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User danms@xxxxxxxxxx
# Node ID 3920df5da25e3b032ca6b27ca20254b09fea3b2b
# Parent  8a5dca8c1e8f18440f6b02c8fe53a8ab6708ce90
Remove semicolons from Console.py.  It's a habit.

diff -r 8a5dca8c1e8f -r 3920df5da25e tools/xm-test/lib/XmTestLib/Console.py
--- a/tools/xm-test/lib/XmTestLib/Console.py    Thu Nov 10 10:43:26 2005
+++ b/tools/xm-test/lib/XmTestLib/Console.py    Thu Nov 10 10:47:27 2005
@@ -23,13 +23,13 @@
      a _very_ specific value, set in the PROMPT
      variable of this script
 """
-import sys;
-import os;
-import pty;
-import tty;
-import termios;
-import fcntl;
-import select;
+import sys
+import os
+import pty
+import tty
+import termios
+import fcntl
+import select
 
 from Test import *
 
@@ -52,15 +52,15 @@
                             are included in the history buffer
         """
 
-        self.TIMEOUT          = 30;
-        self.PROMPT           = "@%@%> ";
-        self.domain           = domain;
-        self.historyBuffer    = [];
-        self.historyLines     = 0;
-        self.historyLimit     = historyLimit;
-        self.historySaveAll   = historySaveAll;
-        self.historySaveCmds  = historySaveCmds;
-        self.debugMe          = False;
+        self.TIMEOUT          = 30
+        self.PROMPT           = "@%@%> "
+        self.domain           = domain
+        self.historyBuffer    = []
+        self.historyLines     = 0
+        self.historyLimit     = historyLimit
+        self.historySaveAll   = historySaveAll
+        self.historySaveCmds  = historySaveCmds
+        self.debugMe          = False
         self.limit            = None
 
         consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
@@ -68,62 +68,62 @@
         if verbose:
             print "Console executing: " + str(consoleCmd)
 
-        pid, fd = pty.fork();
+        pid, fd = pty.fork()
 
         if pid == 0:
-            os.execvp("/usr/sbin/xm", consoleCmd[1:]);
-
-        self.consolePid = pid;
-        self.consoleFd  = fd;
-
-        tty.setraw(self.consoleFd, termios.TCSANOW);
+            os.execvp("/usr/sbin/xm", consoleCmd[1:])
+
+        self.consolePid = pid
+        self.consoleFd  = fd
+
+        tty.setraw(self.consoleFd, termios.TCSANOW)
             
         bytes = self.__chewall(self.consoleFd)
         if bytes < 0:
             raise ConsoleError("Console didn't respond")
 
     def __addToHistory(self, line):
-        self.historyBuffer.append(line);
-        self.historyLines += 1;
+        self.historyBuffer.append(line)
+        self.historyLines += 1
         if self.historyLines > self.historyLimit:
-            self.historyBuffer = self.historyBuffer[1:];
-            self.historyLines -= 1;
+            self.historyBuffer = self.historyBuffer[1:]
+            self.historyLines -= 1
 
 
     def clearHistory(self):
         """Clear the history buffer"""
-        self.historyBuffer = [];
-        self.historyLines = 0;
+        self.historyBuffer = []
+        self.historyLines = 0
 
 
     def getHistory(self):
         """Returns a string containing the entire history buffer"""
-        output = "";
+        output = ""
 
         for line in self.historyBuffer:
-            output += line + "\n";
-
-        return output;
+            output += line + "\n"
+
+        return output
 
 
     def setTimeout(self, timeout):
         """Sets the timeout used to determine if a remote command
         has blocked"""
-        self.TIMEOUT = timeout;
+        self.TIMEOUT = timeout
 
 
     def setPrompt(self, prompt):
         """Sets the string key used to delimit the end of command
         output"""
-        self.PROMPT = prompt;
+        self.PROMPT = prompt
 
 
     def __chewall(self, fd):
-        timeout = 0;
-        bytes   = 0;
+        timeout = 0
+        bytes   = 0
         
         while timeout < 3:
-            i, o, e = select.select([fd], [], [], 1);
+            i, o, e = select.select([fd], [], [], 1)
             if fd in i:
                 try:
                     foo = os.read(fd, 1)
@@ -143,7 +143,7 @@
         if self.debugMe:
             print "Ignored %i bytes of miscellaneous console output" % bytes
         
-        return bytes;
+        return bytes
 
 
     def __runCmd(self, command, saveHistory=True):
@@ -152,15 +152,15 @@
         lines  = 0
         bytes  = 0
 
-        self.__chewall(self.consoleFd);
+        self.__chewall(self.consoleFd)
 
         if verbose:
             print "[%s] Sending `%s'" % (self.domain, command)
 
-        os.write(self.consoleFd, "%s\n" % command);
+        os.write(self.consoleFd, "%s\n" % command)
 
         while 1==1:
-            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT);
+            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT)
 
             if self.consoleFd in i:
                 try:
@@ -182,59 +182,59 @@
                 if lines > 0:
                     output += line + "\n"
                     if saveHistory:
-                        self.__addToHistory(line);
+                        self.__addToHistory(line)
                 elif self.historySaveCmds and saveHistory:
-                    self.__addToHistory("*" + line);
-                lines += 1;
-                line = "";
+                    self.__addToHistory("*" + line)
+                lines += 1
+                line = ""
             elif str == "\r":
                 pass # ignore \r's
             else:
-                line += str;
+                line += str
 
             if line == self.PROMPT:
-                break;
-
-        return output;
+                break
+
+        return output
 
 
     def runCmd(self, command):
         """Runs a command on the remote terminal and returns the output
         as well as the return code.  For example:
         
-        ret = c.runCmd("ls");
-        print ret["output"];
-        sys.exit(run["return"]);
+        ret = c.runCmd("ls")
+        print ret["output"]
+        sys.exit(run["return"])
         
         """
 
         # Allow exceptions to bubble up
-        realOutput = self.__runCmd(command);
-        retOutput  = self.__runCmd("echo $?", saveHistory=False);
+        realOutput = self.__runCmd(command)
+        retOutput  = self.__runCmd("echo $?", saveHistory=False)
 
         try:
-            retCode =  int(retOutput);
+            retCode =  int(retOutput)
         except:
-            retCode = 255;
+            retCode = 255
         return {
             "output": realOutput,
             "return": retCode,
-            };
+            }
 
     def sendInput(self, input):
         """Sends input to the remote terminal, but doesn't check
         for a return code"""
-        realOutput = self.__runCmd(input);
+        realOutput = self.__runCmd(input)
         return {
             "output": realOutput,
             "return": 0,
-            };
+            }
 
     def closeConsole(self):
         """Closes the console connection and ensures that the console
         process is killed"""
-        os.close(self.consoleFd);
-        os.kill(self.consolePid, 2);
+        os.close(self.consoleFd)
+        os.kill(self.consolePid, 2)
 
 
     def setLimit(self, limit):
@@ -254,23 +254,23 @@
     code as the domU command.
     """
 
-    verbose = True;
+    verbose = True
     
     try:
-        t = XmConsole(sys.argv[1]);
+        t = XmConsole(sys.argv[1])
     except ConsoleError, e:
         print "Failed to attach to console (%s)" % str(e)
         sys.exit(255)
 
     try:
-        run = t.runCmd(sys.argv[2]);
+        run = t.runCmd(sys.argv[2])
     except ConsoleError, e:
         print "Console failed (%)" % str(e)
         sys.exit(255)
         
-    t.closeConsole();
+    t.closeConsole()
     
-    print run["output"],;
-    sys.exit(run["return"]);
+    print run["output"],
+    sys.exit(run["return"])
     
         

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Remove semicolons from Console.py. It's a habit., Xen patchbot -unstable <=