コード例 #1
0
ファイル: doLog.py プロジェクト: poyhsiao/betapyweb
    def syslog(self, **kwargs):
        '''
            Syslog getter and setter
            format:
            (True, {'server_ip': '192.168.0.1', 'facility': 'local0'})
        '''
        import libs.login
        if False == libs.login.cklogin():
            raise _.HTTPRedirect('/')

        import ml_w_syslog as wsl
        import json
        import libs.tools
        _.response.headers["Content-Type"] = "application/json"
        if "facility" in kwargs:
            # syslog setter
            libs.tools.v(kwargs)
            res = wsl.set(user = self.getUser(), cfg = kwargs)
            if False == res[0]:
                return json.dumps([res[0], libs.tools.translateMessage(res[1])])
            else:
                return json.dumps(res)
            # return json.dumps(wsl.set(user = self.getUser(), cfg = kwargs))
        else:
            # syslog getter
            return json.dumps(wsl.get())
コード例 #2
0
	def test_syslog_g02(self):
		""" syslog_g02 """
		syslog = {
			"server_ip": "192.168.0.1",
			"facility": "local0"
		}
		self.maxDiff = None
		e = ml_w_syslog.set(None, syslog)
		self.assertTrue(e[0], e[1])
		f = open(os.path.join("running", "syslog.txt"), "r")
		e = f.readlines()
		f.close()
		if "json" == ml_system.CFG_TYPE:
			self.assertEqual(e, ['{"server_ip": "192.168.0.1", "facility": "local0"}'])
		if "jcfg" == ml_system.CFG_TYPE:
			self.assertEqual(e, ['syslog {\n', '    server_ip 192.168.0.1\n', '}\n'])
コード例 #3
0
			def run(self):
				e = ml_w_syslog.set(None, syslog, threading.RLock())