예제 #1
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            "check if user should have totals calculated"
            if ('format' in environ['pylons.routes_dict'] and
                    environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        if (self.identity is not None and 'user' in self.identity
                and environ['pylons.routes_dict']['controller'] != 'error'
                and check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()

                tzinfo = self.identity['user'].timezone or UTC
                c.tzinfo = make_tz(tzinfo)
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
예제 #2
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            if ('format' in environ['pylons.routes_dict'] and
                    environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        # raise ValueError(self.identity)
        # if 'baruwa.auth.plugin' in self.identity:
        #     session['baruwa.auth.plugin'] = self.identity['baruwa.auth.plugin']
        #     session.save()
        if (not self.identity is None and 'user' in self.identity
                and environ['pylons.routes_dict']['controller'] != 'error'
                and check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
예제 #3
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            "check if user should have totals calculated"
            if ('format' in environ['pylons.routes_dict'] and
                environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        if (self.identity is not None and 'user' in self.identity and
            environ['pylons.routes_dict']['controller'] != 'error' and
            check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()

                tzinfo = self.identity['user'].timezone or UTC
                c.tzinfo = make_tz(tzinfo)
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
예제 #4
0
파일: base.py 프로젝트: aureg/baruwa2
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            if ('format' in environ['pylons.routes_dict'] and
                environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        # raise ValueError(self.identity)
        # if 'baruwa.auth.plugin' in self.identity:
        #     session['baruwa.auth.plugin'] = self.identity['baruwa.auth.plugin']
        #     session.save()
        if (not self.identity is None and 'user' in self.identity and
            environ['pylons.routes_dict']['controller'] != 'error' and
            check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
예제 #5
0
    def server_status(self, serverid):
        "Display server status"
        server = self._get_server(serverid)
        if not server:
            abort(404)

        totals = DailyTotals(Session, c.user)
        mailq = MailQueue(Session, c.user)
        totals = totals.get(server.hostname)
        inbound = mailq.get(1, server.hostname)[0]
        outbound = mailq.get(2, server.hostname)[0]

        statusdict = dict(total=totals.total,
                          mta=0,
                          scanners=0,
                          av=0,
                          clean_mail=totals.clean,
                          high_spam=totals.highspam,
                          virii=totals.virii,
                          spam_mail=totals.lowspam,
                          inq=inbound,
                          outq=outbound,
                          otherinfected=totals.infected,
                          uptime='Unknown',
                          time=None,
                          load=(0, 0, 0),
                          mem=dict(free=0, used=0, total=0, percent=0),
                          partitions=[],
                          net={},
                          cpu=0)
        try:
            task = systemstatus.apply_async(routing_key=server.hostname)
            task.wait(30)
            hoststatus = task.result
            statusdict.update(hoststatus)
            info = HOSTSTATUS_MSG % dict(n=server.hostname)
            audit_log(c.user.username, 1, unicode(info), request.host,
                      request.remote_addr,
                      arrow.utcnow().datetime)
        except (TimeoutError, QueueNotFound):
            pass

        jsondata = [
            dict(tooltip=LABELS[attr],
                 y=getattr(totals, attr),
                 stroke='black',
                 color=PIE_COLORS[attr])
            for attr in ['clean', 'highspam', 'lowspam', 'virii', 'infected']
            if getattr(totals, attr)
        ]
        c.chart_data = json.dumps(jsondata)
        c.server = server
        c.status = statusdict
        return self.render('/status/serverstatus.html')
예제 #6
0
    def server_status(self, serverid):
        "Display server status"
        server = self._get_server(serverid)
        if not server:
            abort(404)

        totals = DailyTotals(Session, c.user)
        mailq = MailQueue(Session, c.user)
        totals = totals.get(server.hostname)
        inbound = mailq.get(1, server.hostname)[0]
        outbound = mailq.get(2, server.hostname)[0]

        statusdict = dict(total=totals.total,
                        mta=0,
                        scanners=0,
                        av=0,
                        clean_mail=totals.clean,
                        high_spam=totals.highspam,
                        virii=totals.virii,
                        spam_mail=totals.lowspam,
                        inq=inbound,
                        outq=outbound,
                        otherinfected=totals.infected,
                        uptime='Unknown',
                        time=None,
                        load=(0, 0, 0),
                        mem=dict(free=0, used=0, total=0,
                                percent=0),
                        partitions=[],
                        net={},
                        cpu=0)
        try:
            task = systemstatus.apply_async(routing_key=server.hostname)
            task.wait(30)
            hoststatus = task.result
            statusdict.update(hoststatus)
            info = HOSTSTATUS_MSG % dict(n=server.hostname)
            audit_log(c.user.username,
                    1, unicode(info), request.host,
                    request.remote_addr, arrow.utcnow().datetime)
        except (TimeoutError, QueueNotFound):
            pass

        jsondata = [dict(tooltip=LABELS[attr],
                    y=getattr(totals, attr),
                    stroke='black',
                    color=PIE_COLORS[attr])
                    for attr in ['clean', 'highspam', 'lowspam', 'virii',
                    'infected'] if getattr(totals, attr)]
        c.chart_data = json.dumps(jsondata)
        c.server = server
        c.status = statusdict
        return self.render('/status/serverstatus.html')
예제 #7
0
파일: status.py 프로젝트: haugvald/baruwa2
    def server_status(self, serverid):
        "Display server status"
        server = self._get_server(serverid)
        if not server:
            abort(404)

        totals = DailyTotals(Session, c.user)
        mailq = MailQueue(Session, c.user)
        totals = totals.get(server.hostname)
        inbound = mailq.get(1, server.hostname)[0]
        outbound = mailq.get(2, server.hostname)[0]

        statusdict = dict(total=totals.total,
                        mta=0,
                        scanners=0,
                        av=0,
                        clean_mail=totals.clean,
                        high_spam=totals.highspam,
                        virii=totals.virii,
                        spam_mail=totals.lowspam,
                        inq=inbound,
                        outq=outbound,
                        otherinfected=totals.infected,
                        uptime='Unknown',
                        time=None,
                        load=(0, 0, 0),
                        mem=dict(free=0, used=0, total=0,
                                percent=0),
                        partitions=[],
                        net={},
                        cpu=0)
        try:
            task = systemstatus.apply_async(queue=server.hostname)
            task.wait(30)
            hoststatus = task.result
            statusdict.update(hoststatus)
            info = HOSTSTATUS_MSG % dict(n=server.hostname)
            audit_log(c.user.username,
                    1, info, request.host,
                    request.remote_addr, now())
        except (TimeoutError, QueueNotFound):
            pass

        c.server = server
        c.status = statusdict
        return render('/status/serverstatus.html')
예제 #8
0
    def server_status(self, serverid):
        "Display server status"
        server = self._get_server(serverid)
        if not server:
            abort(404)

        totals = DailyTotals(Session, c.user)
        mailq = MailQueue(Session, c.user)
        totals = totals.get(server.hostname)
        inbound = mailq.get(1, server.hostname)[0]
        outbound = mailq.get(2, server.hostname)[0]

        statusdict = dict(total=totals.total,
                        mta=0,
                        scanners=0,
                        av=0,
                        clean_mail=totals.clean,
                        high_spam=totals.highspam,
                        virii=totals.virii,
                        spam_mail=totals.lowspam,
                        inq=inbound,
                        outq=outbound,
                        otherinfected=totals.infected,
                        uptime='Unknown',
                        load=(0, 0, 0),
                        mem=dict(free=0, used=0, total=0,
                                percent=0),
                        partitions=[],
                        net={},
                        cpu=0)
        try:
            task = systemstatus.apply_async(queue=server.hostname)
            task.wait(30)
            hoststatus = task.result
            statusdict.update(hoststatus)
            info = HOSTSTATUS_MSG % dict(n=server.hostname)
            audit_log(c.user.username,
                    1, info, request.host,
                    request.remote_addr, datetime.now())
        except (TimeoutError, QueueNotFound):
            pass

        c.server = server
        c.status = statusdict
        return render('/status/serverstatus.html')