spinPrint might behave strangely for longer strings

Charles_Rose at Dell.com Charles_Rose at Dell.com
Tue Mar 4 06:48:47 CST 2008


Here you go:

diff -Nru firmware-tools-2.0.10/firmwaretools/pycompat.py firmware-tools-2.0.10-new/firmwaretools/pycompat.py
--- firmware-tools-2.0.10/firmwaretools/pycompat.py	2008-02-20 22:04:15.000000000 +0530
+++ firmware-tools-2.0.10-new/firmwaretools/pycompat.py	2008-03-04 18:14:38.000000000 +0530
@@ -40,9 +40,16 @@
     # ESC codes for clear line and position cursor at horizontal pos 0
     return step
 
+def pad(strn, pad_width=67):
+    # truncate strn to pad_width so spinPrint does not scroll
+    if len(strn) > pad_width:
+        return strn[:pad_width] + ' ...'
+    else:
+        return strn
+
 def spinPrint(strn, outFd=sys.stderr):
     outFd.write(clearLine())
-    outFd.write("%s\t%s" % (spinner(), strn))
+    outFd.write("%s\t%s" % (spinner(), pad(strn)))
     outFd.flush()
 
 def timedSpinPrint( strn, start ):

---

-Charles

-----Original Message-----
From: firmware-tools-devel-bounces at lists.us.dell.com on behalf of Michael_E_Brown at dell.com
Sent: Fri 2/29/2008 9:47 PM
To: Rose, Charles; firmware-tools-devel at lists.us.dell.com
Subject: RE: spinPrint might behave strangely for longer strings
 
I think the better way would most likely be to just truncate the string we are printing.

def pad(s, n):
    return s[:n] + ' ' * (n-len(s))

Pad it to 50 or so chars. You want to send a patch?
--
Michael

-----Original Message-----
From: firmware-tools-devel-bounces at lists.us.dell.com on behalf of Charles_Rose at dell.com
Sent: Fri 2/29/2008 5:27 AM
To: firmware-tools-devel at lists.us.dell.com
Subject: spinPrint might behave strangely for longer strings
 

Hello,

I ran into this cosmetic issue while in the text console. At first, was not able to see this in xterm or gnome-terminal. And then I started seeing this on gnome-terminal and xterm when I resized the window. Looks like when the string output by firmwaretools.pycompat.spinPrint is larger than the column width of the terminal, it has a scrolling effect on the string as the string wraps around - clearline() tries to clear only the last line. I ended up having screen-full of the animation below:

---
[root at PE1750 ~]# update_firmware --yes

Running system inventory...

Searching storage directory for available BIOS updates...
Checking PowerEdge Expandable RAID controller 4/Di Firmware - 422a
        Available: pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x014a) - 422d
        Found Update: pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x014a) - 422d
Checking System BIOS for PowerEdge 1750 - a12
        Available: system_bios(ven_0x1028_dev_0x014a) - a12
        Did not find a newer package to install that meets all installation checks.

Found firmware which needs to be updated.

Running updates...
\       Installing pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x01
|       Installing pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x01
/       Installing pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x01
-       Installing pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x01
\       Installing pci_firmware(ven_0x1028_dev_0x000f_subven_0x1028_subdev_0x01
---

The wrapping messes up logic. We could print the string once and cycle through the progress animation in the next line by itself.

Thanks,
Charles

_______________________________________________
firmware-tools-devel mailing list
firmware-tools-devel at lists.us.dell.com
http://lists.us.dell.com/mailman/listinfo/firmware-tools-devel


_______________________________________________
firmware-tools-devel mailing list
firmware-tools-devel at lists.us.dell.com
http://lists.us.dell.com/mailman/listinfo/firmware-tools-devel




More information about the firmware-tools-devel mailing list