Beispiel #1
0
    def __init__(self):
        """
        Constructor.
        """
        try:
            self.term = TerminalController()
        except:
            self.term = None

        if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL):
            self.term = None

        self.bar = BAR
        if self.term:
            self.bar = self.term.render(BAR)
        self.cleared = 1 #: true if we haven't drawn the self.bar yet.
        self.percent = 0
        self.text    = ""
Beispiel #2
0
class TextProgress:
    """
    @authors: Brigitte Bigi
    @contact: brigitte.bigi((AATT))lpl-aix.fr
    @license: GPL
    @summary: A 3-lines progress self.bar.

    It looks like::

                            Header
    20% [===========----------------------------------]
                       progress message

    The progress self.bar is colored, if the terminal supports color
    output; and adjusts to the width of the terminal.

    """


    def __init__(self):
        """
        Constructor.
        """
        try:
            self.term = TerminalController()
        except:
            self.term = None

        if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL):
            self.term = None

        self.bar = BAR
        if self.term:
            self.bar = self.term.render(BAR)
        self.cleared = 1 #: true if we haven't drawn the self.bar yet.
        self.percent = 0
        self.text    = ""

    # End __init__
    # ------------------------------------------------------------------


    def update(self, percent, message):
        """
        Update the progress.

        @param text:     progress self.bar text  (default: None)
        @param fraction: progress self.bar value (default: 0)

        """
        n = int((WIDTH-10)*percent)

        if self.term:
            sys.stdout.write(
                self.term.BOL + self.term.UP + self.term.CLEAR_EOL +
                (self.bar % (100*percent, '='*n, '-'*(WIDTH-10-n))) +
                self.term.CLEAR_EOL + message.center(WIDTH))
        else:
            sys.stdout.write( '  => ' + message + " \n")

        self.percent = percent
        self.text    = message

    # End update
    # ------------------------------------------------------------------


    def clear(self):
        """
        Clear.
        """
        if not self.cleared:
            if self.term:
                sys.stdout.write(self.term.BOL + self.term.CLEAR_EOL +
                                 self.term.UP + self.term.CLEAR_EOL +
                                 self.term.UP + self.term.CLEAR_EOL)
            else:
                sys.stdout.write('\n'*50)
            self.cleared = 1

    # End clear
    # ------------------------------------------------------------------


    def set_fraction(self, percent):
        """
        Set a new progress value.

        @param fraction: new progress value

        """
        self.update(percent,self.text)

    # End set_fraction
    # ------------------------------------------------------------------


    def set_text(self,text):
        """
        Set a new progress text.

        @param text: new progress text

        """
        self.update(self.percent,text)

    # End set_text
    # ------------------------------------------------------------------


    def set_header(self,header):
        """
        Set a new progress label.

        @param label: new progress label

        """
        if self.term:
            self.header = self.term.render(HEADER % header.center(WIDTH))
        else:
            self.header = "          " + header

        sys.stdout.write(self.header)

    # End set_header
    # ------------------------------------------------------------------


    def set_new(self):
        """
        Initialize a new progress line.

        """
        sys.stdout.write('\n')
        self.clear()
        self.text = ""
        self.percent = 0
Beispiel #3
0
    :license: GPLv3+, see COPYING file
'''

from time import sleep
from optparse import OptionParser
import sys
import math
import serial

import roslib
roslib.load_manifest('ltxbee')
import rospy
from ltserver.msg import Map, Robots

from terminalcontroller import TerminalController
term = TerminalController()

TOP = 0
BOTTOM = 1
LEFT = 2
RIGHT = 3

robots = []
fields = []
debug = False
robot_name = None
serialport = None
newdata = False


class bcolors: