Ejemplo n.º 1
0
def checkLocalRuleLogById(id, expectedLog):
    """Check the local rule for expected log"""

    ruleLogPath = os.path.join(yadomsServer.scriptLogsPath(), str(id))
    if not os.path.isdir(ruleLogPath):
        return False

    ruleLogFilePath = os.path.join(ruleLogPath, "rule.log")
    if not os.path.isfile(ruleLogFilePath):
        return False

    readLog = []
    with open(ruleLogFilePath, 'r') as ruleFile:
        # Skip first line (containing something like "# Log file created/rotated Monday, 23 Jan 17 13:54:56 GMT")
        next(ruleFile)
        for line in ruleFile:
            # Remove date/time for comparison
            readLog.append(re.sub("\w{3}, \d{2}:\d{2}:\d{2} : ", "", line))

    if (readLog != expectedLog):
        print ">>>>>>>>>>> Read log     :", readLog
        print ">>>>>>>>>>> Expected log :", expectedLog
        return False

    return True
Ejemplo n.º 2
0
def checkLocalRuleLogById(id, expectedLog):
   """Check the local rule for expected log"""
   
   ruleLogPath = os.path.join(yadomsServer.scriptLogsPath(), str(id))
   if not os.path.isdir(ruleLogPath):
      return False
   
   ruleLogFilePath = os.path.join(ruleLogPath, "rule.log")
   if not os.path.isfile(ruleLogFilePath):
      return False
   
   readLog = []
   with open(ruleLogFilePath, 'r') as ruleFile:
      for line in ruleFile:
         # Remove date/time for comparison
         readLog.append(re.sub("\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2} : ", "", line))
         
   if (readLog != expectedLog):
      print ">>>>>>>>>>> Read log : "
      print readLog
      print ">>>>>>>>>>> Expected log : "
      print expectedLog
      return False         

   return True
   
Ejemplo n.º 3
0
def checkLocalRuleLogById(id, expectedLog):
    """Check the local rule for expected log"""

    ruleLogPath = os.path.join(yadomsServer.scriptLogsPath(), str(id))
    if not os.path.isdir(ruleLogPath):
        return False

    ruleLogFilePath = os.path.join(ruleLogPath, "rule.log")
    if not os.path.isfile(ruleLogFilePath):
        return False

    readLog = []
    with open(ruleLogFilePath, 'r') as ruleFile:
        for line in ruleFile:
            # Remove date/time for comparison
            readLog.append(
                re.sub("\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2} : ", "",
                       line))

    if (readLog != expectedLog):
        print ">>>>>>>>>>> Read log : "
        print readLog
        print ">>>>>>>>>>> Expected log : "
        print expectedLog
        return False

    return True
Ejemplo n.º 4
0
def deleteAll():
    print 'Remove all scripts and associated logs'
    resources.deleteTree(yadomsServer.scriptsPath())
    resources.deleteTree(yadomsServer.scriptLogsPath())
Ejemplo n.º 5
0
def deleteAll():
   print 'Remove all scripts and associated logs'
   resources.deleteTree(yadomsServer.scriptsPath())
   resources.deleteTree(yadomsServer.scriptLogsPath())