Ejemplo n.º 1
0
    def __reginit__(self, *args, **kw):
        conf = get_config('ttyrpl')
        if not os.path.isdir(conf['logdir']):
            os.makedirs(conf['logdir'])
        
        self.logdir = conf['logdir']

        ProxyShell.__reginit__(self, *args, **kw)

        user = self.ipc_chan.call('get_ns_tag', namespace='client',
                                                tag='username')
        path = os.path.join(self.logdir, user)
        if not os.path.isdir(path):
            os.makedirs(path)

        site_login = self.ipc_chan.call('get_ns_tag', namespace='site',
                                                tag='login')
        site_name = self.ipc_chan.call('get_ns_tag', namespace='site',
                                                tag='name')
        site = '%s@%s' % (site_login, site_name)
        path = os.path.join(path, site)
        if not os.path.isdir(path):
            os.makedirs(path)

        date = datetime.datetime.now().isoformat()
        logfile = os.path.join(path, date)
        self.log = TTYrplLogger(logfile)
        self.log.log_user("%s->%s" % (user, site))
Ejemplo n.º 2
0
    def __reginit__(self, *args, **kw):
        conf = get_config("logusers")
        if not os.path.isdir(conf["logdir"]):
            os.makedirs(conf["logdir"])

        self.logdir = conf["logdir"]

        # fill our translation table
        for key in dir(keys):
            if key[0] == "_" or not isinstance(getattr(keys, key), str):
                continue
            self.tr_table[getattr(keys, key)] = "<%s>" % key

        for key, value in self._tr_table.items():
            self.tr_table[key] = value

        ProxyShell.__reginit__(self, *args, **kw)

        user = self.ipc_chan.call("get_ns_tag", namespace="client", tag="username")
        path = os.path.join(self.logdir, user)
        if not os.path.isdir(path):
            os.makedirs(path)

        site_login = self.ipc_chan.call("get_ns_tag", namespace="site", tag="login")
        site_name = self.ipc_chan.call("get_ns_tag", namespace="site", tag="name")
        site = "%s@%s" % (site_login, site_name)
        logfile = os.path.join(path, site)
        self.log = open(logfile, "a")
Ejemplo n.º 3
0
    def __reginit__(self, *args, **kw):
        conf = get_config('logusers')
        if not os.path.isdir(conf['logdir']):
            os.makedirs(conf['logdir'])

        self.logdir = conf['logdir']

        # fill our translation table
        for key in dir(keys):
            if key[0] == '_' or not isinstance(getattr(keys, key), str):
                continue
            self.tr_table[getattr(keys, key)] = '<%s>' % key

        for key, value in self._tr_table.items():
            self.tr_table[key] = value

        ProxyShell.__reginit__(self, *args, **kw)

        user = self.ipc_chan.call('get_ns_tag',
                                  namespace='client',
                                  tag='username')
        path = os.path.join(self.logdir, user)
        if not os.path.isdir(path):
            os.makedirs(path)

        site_login = self.ipc_chan.call('get_ns_tag',
                                        namespace='site',
                                        tag='login')
        site_name = self.ipc_chan.call('get_ns_tag',
                                       namespace='site',
                                       tag='name')
        site = '%s@%s' % (site_login, site_name)
        logfile = os.path.join(path, site)
        self.log = open(logfile, 'a')
Ejemplo n.º 4
0
 def client_recv_data(self, source, name):
     data = ProxyShell.recv_data(self, source, name)
     # if name == 'client_chan':
     if True:
         for x in data:
             self.log.write(self.translate(x))
         self.log.flush()
     return data
Ejemplo n.º 5
0
 def client_recv_data(self, source, name):
     data = ProxyShell.recv_data(self, source, name)
     #if name == 'client_chan':
     if True:
         for x in data:
             self.log.write(self.translate(x))
         self.log.flush()
     return data
Ejemplo n.º 6
0
 def __del__(self):
     self.log.close()
     ProxyShell.__del__(self)
Ejemplo n.º 7
0
 def site_recv_data(self, source, name):
     data = ProxyShell.recv_data(self, source, name)
     self.log.write(data)
     return data
Ejemplo n.º 8
0
 def client_recv_data(self, source, name):
     data = ProxyShell.recv_data(self, source, name)
     self.log.read(data)
     return data
Ejemplo n.º 9
0
 def __del__(self):
     self.log.close()
     ProxyShell.__del__(self)