Exemple #1
0
    def collect(self):
        self.app.log.debug("Inside SysChangeMonBaseController.collect()")

        db = self.app.storage.db
        assert isinstance(db, Model)

        session = db.new_session()
        session['start_time'] = datetime.now(tz=get_localzone())
        session.save()

        plugins = self.plugins

        urls = []
        for plugin in plugins.values():
            urls += plugin.list_urls()

        for plugin in plugins.values():
            urls = plugin.process_urls(urls)

        for label, plugin in plugins.items():
            with db.transaction():
                for url in urls:
                    try:
                        statedict = plugin.get_state(url)
                        if statedict is not None:
                            state = session.new_state(url=url,
                                                      plugin=label,
                                                      **statedict)
                            #self.app.log.debug("read state: %s" % state)
                            state.save()
                    except UnsupportedException:
                        pass

        with db.transaction():
            for state in session.find_states():
                for plugin in plugins.values():
                    old = state.copy()
                    new = plugin.process_state(state)
                    if old != new:
                        state.save()
                        #self.app.log.debug("updated state: %s" % state)

        for res in hook.run('enumerate', self.app):
            self.app.log.debug('enumerate result: %s' % res)

        session['hostname'] = socket.gethostbyaddr(socket.gethostname())[0]
        session['item_count'] = len(urls)
        session['closed'] = True
        session['end_time'] = datetime.now(tz=get_localzone())
        session.save()

        print("session " + session['uuid'] + " saved")

        self.app.exit_code = 0
        return
Exemple #2
0
    def collect(self):
        self.app.log.debug("Inside SysChangeMonBaseController.collect()")

        db = self.app.storage.db
        assert isinstance(db, Model)

        session = db.new_session()
        session['start_time'] = datetime.now(tz=get_localzone())
        session.save()

        plugins = self.plugins

        urls = []
        for plugin in plugins.values():
            urls += plugin.list_urls()

        for plugin in plugins.values():
            urls = plugin.process_urls(urls)

        for label, plugin in plugins.items():
            with db.transaction():
                for url in urls:
                    try:
                        statedict = plugin.get_state(url)
                        if statedict is not None:
                            state = session.new_state(url=url, plugin=label, **statedict)
                            #self.app.log.debug("read state: %s" % state)
                            state.save()
                    except UnsupportedException:
                        pass

        with db.transaction():
            for state in session.find_states():
                for plugin in plugins.values():
                    old = state.copy()
                    new = plugin.process_state(state)
                    if old != new:
                        state.save()
                        #self.app.log.debug("updated state: %s" % state)

        for res in hook.run('enumerate', self.app):
            self.app.log.debug('enumerate result: %s' % res)

        session['hostname'] = socket.gethostbyaddr(socket.gethostname())[0]
        session['item_count'] = len(urls)
        session['closed'] = True
        session['end_time'] = datetime.now(tz=get_localzone())
        session.save()

        print("session " + session['uuid'] + " saved")

        self.app.exit_code = 0
        return
Exemple #3
0
 def __init__(self, **kw):
     super().__init__(**kw)
     self.include = []
     self.exclude = []
     self.include_pats = []
     self.exclude_pats = []
     self.assume_nochange = []
     self.assume_change = []
     self.last_session = None
     self.tz = get_localzone()
Exemple #4
0
 def __init__(self, **kw):
     super().__init__(**kw)
     self.include = []
     self.exclude = []
     self.include_pats = []
     self.exclude_pats = []
     self.assume_nochange = []
     self.assume_change = []
     self.last_session = None
     self.tz = get_localzone()
Exemple #5
0
 def __init__(self, model, uuid=None, stamp=None, **kwargs):
     for k, v in kwargs.items():
         self[k] = v
     self._model = model
     if uuid is None:
         uuid = str(uuid4())
     if stamp is None:
         stamp = datetime.now(tz=get_localzone())
     self['uuid'] = uuid
     self['stamp'] = stamp
Exemple #6
0
 def __init__(self, model, uuid=None, stamp=None, **kwargs):
     for k, v in kwargs.items():
         self[k] = v
     self._model = model
     if uuid is None:
         uuid = str(uuid4())
     if stamp is None:
         stamp = datetime.now(tz=get_localzone())
     self['uuid'] = uuid
     self['stamp'] = stamp
Exemple #7
0
    def __init__(self):
        super(WtmpPlugin, self).__init__()

        self.tz = get_localzone()
        self.wtmp_sessions = []
"""Module with absolute import"""
from __future__ import absolute_import
from __future__ import print_function

from tzlocal import unix
print(unix.get_localzone())
Exemple #9
0
    def setup(self, app):
        super(SysInfoPlugin, self).setup(app)

        c = app.config

        self.tz = get_localzone()
Exemple #10
0
    def setup(self, app):
        super(SysInfoPlugin, self).setup(app)

        c = app.config

        self.tz = get_localzone()
Exemple #11
0
    def __init__(self):
        super(WtmpPlugin, self).__init__()

        self.tz = get_localzone()
        self.wtmp_sessions = []