def __init__(self,
                 log_level=LOG_LEVEL.WARNING,
                 timestamp_format="%X"):
        Printer.__init__(self)
        LogPrinter.__init__(self, self, log_level, timestamp_format)

        self.logs = []
Exemple #2
0
    def __init__(self, print_colored=True):
        """
        Creates a new ColorPrinter.

        :param print_colored: Can be set to False to use uncolored printing
                              only.
        """
        Printer.__init__(self)

        self.print_colored = print_colored
Exemple #3
0
    def __init__(self, log_level=LOG_LEVEL.WARNING, timestamp_format="%X"):
        """
        Creates a new log printer. The log printer adds logging capabilities to any normal printer, just derive from
        this class and you should have this logging capabilities for free. (Note: LogPrinter itself is abstract.)

        :param log_level: The minimum log level, everything below will not be logged.
        :param timestamp_format: The format string for the datetime.today().strftime(format) method.
        """
        Printer.__init__(self)

        self.log_level = log_level
        self.timestamp_format = timestamp_format
Exemple #4
0
    def __init__(self, filename):
        """
        Creates a new FilePrinter. If the directory of the given file doesn't
        exist or if there's any access problems, an exception will be thrown.

        :param filename: the name of the file to put the data into (string).
        """
        Printer.__init__(self)
        ClosableObject.__init__(self)
        self.file = None
        if not isinstance(filename, str):
            raise TypeError("filename must be a string.")

        self.file = open(filename, 'a+')
Exemple #5
0
    def __init__(self,
                 section,
                 message_queue,
                 timeout=0):
        Printer.__init__(self)
        LogPrinter.__init__(self, self)

        if not isinstance(section, Section):
            raise TypeError("section has to be of type Section.")
        if not hasattr(message_queue, "put") and message_queue is not None:
            raise TypeError("message_queue has to be a Queue or None.")

        self.section = section
        self.message_queue = message_queue
        self.timeout = timeout
Exemple #6
0
    def __init__(self, log_level=LOG_LEVEL.WARNING, timestamp_format="%X"):
        """
        Creates a new log printer. The log printer adds logging capabilities to
        any normal printer, just derive from this class and you should have
        this logging capabilities for free. (Note: LogPrinter itself is
        abstract.)

        :param log_level: The minimum log level, everything below will not be
        logged.
        :param timestamp_format: The format string for the
        datetime.today().strftime(format) method.
        """
        Printer.__init__(self)

        self.log_level = log_level
        self.timestamp_format = timestamp_format
    def __init__(self):
        """
        Raises EnvironmentError if VoiceOutput is impossible.
        """
        Printer.__init__(self)
        # TODO retrieve language from get_locale and select appropriate voice

        try:
            self.espeak = subprocess.Popen(['espeak'], stdin=subprocess.PIPE)
        except OSError:  # pragma: no cover
            print(_("eSpeak doesn't seem to be installed. You cannot use the voice output feature without eSpeak. "
                    "It can be downloaded from http://espeak.sourceforge.net/ or installed via your usual package "
                    "repositories."))
            raise EnvironmentError
        except:  # pragma: no cover
            print(_("Failed to execute eSpeak. An unknown error occurred."), StringConstants.THIS_IS_A_BUG)
            raise EnvironmentError
Exemple #8
0
    def __init__(self):
        """
        Raises EnvironmentError if VoiceOutput is impossible.
        """
        Printer.__init__(self)
        # TODO retrieve language from get_locale and select appropriate voice

        try:
            self.espeak = subprocess.Popen(['espeak'], stdin=subprocess.PIPE)
        except OSError:  # pragma: no cover
            print(
                _("eSpeak doesn't seem to be installed. You cannot use the voice output feature without eSpeak. "
                  "It can be downloaded from http://espeak.sourceforge.net/ or installed via your usual package "
                  "repositories."))
            raise EnvironmentError
        except:  # pragma: no cover
            print(_("Failed to execute eSpeak. An unknown error occurred."),
                  StringConstants.THIS_IS_A_BUG)
            raise EnvironmentError
Exemple #9
0
 def test_printer_interface(self):
     self.uut = Printer()
     self.assertRaises(NotImplementedError, self.uut.print, "test")
Exemple #10
0
 def __init__(self):
     Printer.__init__(self)
Exemple #11
0
 def __init__(self):
     Printer.__init__(self)
Exemple #12
0
 def __init__(self):
     """
     Instantiates a new NullPrinter.
     """
     Printer.__init__(self)