コード例 #1
0
def saveContext(browser):
   callerFonctionName = inspect.stack()[1][3]
   contexteDirectory = os.path.join('report', 'debug', callerFonctionName)
   print 'Save contexte to ', contexteDirectory
   if not os.path.exists(contexteDirectory):
      os.makedir(contexteDirectory)
      
   browser.save_screenshot(os.path.join(contexteDirectory, 'screenshot.png'))
   if os.path.exists(yadomsServer.databasePath()):
      shutil.copyfile(yadomsServer.databasePath(), os.path.join(contexteDirectory, os.path.basename(yadomsServer.databasePath())))
   if os.path.exists(yadomsServer.scriptsPath()):
      shutil.copytree(yadomsServer.scriptsPath(), os.path.join(contexteDirectory))
コード例 #2
0
def checkLocalRuleCodeById(id, expectedCode):
    """Check the local rule for expected code"""

    rulePath = os.path.join(yadomsServer.scriptsPath(), "locals",
                            "rule_" + str(id))
    if not os.path.isdir(rulePath):
        return False

    ruleFilePath = os.path.join(rulePath, "yadomsScript.py")
    if not os.path.isfile(ruleFilePath):
        return False

    readCode = []
    with open(ruleFilePath, 'r') as ruleFile:
        for line in ruleFile:
            readCode.append(line.rstrip())

    # Remove BOM
    if len(readCode) > 0 and readCode[0][0] == '\xef' and readCode[0][
            1] == '\xbb' and readCode[0][2] == '\xbf':
        readCode[0] = readCode[0][3:]

    if (readCode != expectedCode):
        print ">>>>>>>>>>> Read code : "
        print readCode
        print ">>>>>>>>>>> Expected code : "
        print expectedCode
        return False

    return True
コード例 #3
0
ファイル: scripts.py プロジェクト: Yadoms/yadoms
def checkLocalRuleCodeById(id, expectedCode):
   """Check the local rule for expected code"""
   
   rulePath = os.path.join(yadomsServer.scriptsPath(), "locals", "rule_" + str(id))
   if not os.path.isdir(rulePath):
      return False
   
   ruleFilePath = os.path.join(rulePath, "yadomsScript.py")
   if not os.path.isfile(ruleFilePath):
      return False
      
   readCode = []
   with open(ruleFilePath, 'r') as ruleFile:
      for line in ruleFile:
         readCode.append(line.rstrip())

   # Remove BOM
   if len(readCode) > 0 and readCode[0][0] == '\xef' and readCode[0][1] == '\xbb' and readCode[0][2] == '\xbf':
      readCode[0] = readCode[0][3:]
      
   if (readCode != expectedCode):
      print ">>>>>>>>>>> Read code : "
      print readCode
      print ">>>>>>>>>>> Expected code : "
      print expectedCode
      return False
      
   return True
コード例 #4
0
ファイル: scripts.py プロジェクト: Yadoms/yadoms
def deploy(scripts):
   
   deleteAll()
   print 'Deploy scripts ', scripts
   
   for index, script in enumerate(scripts):
      ruleTargetPath = os.path.join(yadomsServer.scriptsPath(), "locals", "rule_" + str(index + 1))
      os.makedirs(ruleTargetPath)
      shutil.copyfile(os.path.join("resources", "scripts", script + ".py"), os.path.join(ruleTargetPath, "yadomsScript.py"))
コード例 #5
0
def deploy(scripts):

    deleteAll()
    print 'Deploy scripts ', scripts

    for index, script in enumerate(scripts):
        ruleTargetPath = os.path.join(yadomsServer.scriptsPath(), "locals",
                                      "rule_" + str(index + 1))
        os.makedirs(ruleTargetPath)
        shutil.copyfile(os.path.join("resources", "scripts", script + ".py"),
                        os.path.join(ruleTargetPath, "yadomsScript.py"))
コード例 #6
0
def deleteAll():
    print 'Remove all scripts and associated logs'
    resources.deleteTree(yadomsServer.scriptsPath())
    resources.deleteTree(yadomsServer.scriptLogsPath())
コード例 #7
0
def ruleFullPath(id):
    """Get the rule full path for rule id"""
    rulePath = os.path.join(yadomsServer.scriptsPath(), "locals",
                            "rule_" + str(id))
    ruleFilePath = os.path.join(rulePath, "yadomsScript.py")
    return ruleFilePath
コード例 #8
0
ファイル: scripts.py プロジェクト: Yadoms/yadoms
def deleteAll():
   print 'Remove all scripts and associated logs'
   resources.deleteTree(yadomsServer.scriptsPath())
   resources.deleteTree(yadomsServer.scriptLogsPath())
コード例 #9
0
ファイル: scripts.py プロジェクト: Yadoms/yadoms
def ruleFullPath(id):
   """Get the rule full path for rule id"""
   rulePath = os.path.join(yadomsServer.scriptsPath(), "locals", "rule_" + str(id))
   ruleFilePath = os.path.join(rulePath, "yadomsScript.py")
   return ruleFilePath