Ejemplo n.º 1
0
    def make_valid_file_name(name):
        if name == None or name == "":
            raise FormatError("Blank or null file name was provided")

        # Replace invalid characters
        replacedName = name
        try:
            replacedName = name.replaceAll("[^a-zA-Z0-9\\._\\- ]+", "~")
        except Error as e:
            console = ConsoleLogger()
            console.logMessage(
                MessageType.ERROR,
                StringProcessor.safeFormatter(
                    "Failed to Replace Invalid Characters because: " + e.args))
        return replacedName
Ejemplo n.º 2
0
    def log_message(self, messageType, message, args):
        # If the message level is greater that the current log level then do not log it.
        if (self.should_message_be_logged(messageType)):
            try:
                '''
                 (FileWriter fw = new FileWriter(this.filePath, true);
                BufferedWriter bw = new BufferedWriter(fw);
                PrintWriter writer = new PrintWriter(bw)) 
                writer.println(
                StringProcessor.safeFormatter("%s%s", Config.NEW_LINE, System.currentTimeMillis()));
                writer.print(StringProcessor.safeFormatter("%s:\t", messageType.toString()));

                writer.println(StringProcessor.safeFormatter(message, args));
                writer.flush();
                '''
            except Error as e:
                # Failed to write to the event log, write error to the console instead
                console = ConsoleLogger()
                console.logMessage(
                    MessageType.ERROR,
                    StringProcessor.safeFormatter(
                        "Failed to write to event log because: " + e.args))
                console.logMessage(messageType, message, args)
 def consoleLoggerLogMessage(self):
     console = ConsoleLogger()
     console.logMessage("Test String %s %s", "args1", "args2")
 def consoleLoggerLogMessageSelectType(self):
     console = ConsoleLogger()
     console.logMessage(MessageType.GENERIC, "Test String %s", "args1")