コード例 #1
0
ファイル: models.py プロジェクト: gypsymauro/almir
 def render_logtext(self, request):
     d = {}
     # sanitize logs
     log = self.logtext.strip('\\').strip().strip('\n')
     d['text'] = Markup(nl2br(log))
     if 'ERR' in self.logtext or 'Fatal error' in self.logtext or 'Backup Error' in self.logtext:
         d['cssclass'] = 'error'
     return d
コード例 #2
0
ファイル: models.py プロジェクト: weaselshit/almir
 def render_logtext(self, request):
     d = {}
     # sanitize logs
     log = self.logtext.strip('\\').strip().strip('\n')
     d['text'] = Markup(nl2br(log))
     if 'ERR' in self.logtext or 'Fatal error' in self.logtext or 'Backup Error' in self.logtext:
         d['cssclass'] = 'error'
     return d
コード例 #3
0
ファイル: models.py プロジェクト: redguy-p2pu/almir
 def render_logtext(self, request):
     d = {}
     # sanitize logs
     log = self.logtext.strip("\\").strip().strip("\n")
     d["text"] = Markup(nl2br(log))
     if "ERR" in self.logtext or "Fatal error" in self.logtext or "Backup Error" in self.logtext:
         d["cssclass"] = "error"
     return d
コード例 #4
0
ファイル: bconsole.py プロジェクト: weaselshit/almir
    def send_command_by_polling(self, command, process=None):
        """"""
        if command == 'quit':
            return process, {'commands': ['Try harder.']}

        # start bconsole session if it's not initialized
        if process is None:
            process = self.start_process()

        poll = process.poll()
        if poll is not None:
            process = None
            return process, {
                'error':
                'Connection to director terminated with status %d. Refresh to reconnect.'
                % poll
            }

        # send bconsole command
        if command:
            process.stdin.write(command.strip().encode('utf-8') + '\n')

        # make stdout fileobject nonblockable
        fp = process.stdout.fileno()
        flags = fcntl.fcntl(fp, fcntl.F_GETFL)
        fcntl.fcntl(fp, fcntl.F_SETFL, flags | os.O_NONBLOCK)

        output = ''

        while 1:
            # wait for data or timeout
            [i, o, e] = select.select([fp], [], [], 1)
            if i:
                # we have more data
                output += process.stdout.read(1000)
            else:
                # we have a timeout
                output = nl2br(output)

                return process, {"commands": [output]}
コード例 #5
0
ファイル: bconsole.py プロジェクト: redguy-p2pu/almir
    def send_command_by_polling(self, command, process=None):
        """"""
        if command == "quit":
            return process, {"commands": ["Try harder."]}

        # start bconsole session if it's not initialized
        if process is None:
            process = self.start_process()

        poll = process.poll()
        if poll is not None:
            process = None
            return process, {"error": "Connection to director terminated with status %d. Refresh to reconnect." % poll}

        # send bconsole command
        if command:
            process.stdin.write(command.strip() + "\n")

        # make stdout fileobject nonblockable
        fp = process.stdout.fileno()
        flags = fcntl.fcntl(fp, fcntl.F_GETFL)
        fcntl.fcntl(fp, fcntl.F_SETFL, flags | os.O_NONBLOCK)

        output = ""

        while 1:
            # wait for data or timeout
            [i, o, e] = select.select([fp], [], [], 1)
            if i:
                # we have more data
                output += process.stdout.read(1000)
            else:
                # we have a timeout
                output = nl2br(output)

                return process, {"commands": [output]}