Created
May 24, 2018 15:10
-
-
Save xrobin/cc6ccba8e2fa03bcf3f4f7851575cb40 to your computer and use it in GitHub Desktop.
Tests the verbosity levels of OST, with argparse magic. Pass -v, -vv, to increase verbosity, -q, -qq, -qqq to decrease.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import argparse | |
from ost import * | |
def testVerbosityLevel(): | |
print("Verbosity: %d" % GetVerbosityLevel()) | |
LogError("LogError") # >= 0 | |
LogWarning("LogWarning") # >= 1 | |
LogScript("LogScript") # >= 2 | |
LogInfo("LogInfo") # >= 3 | |
LogVerbose("LogVerbose") # >= 4 | |
LogDebug("LogDebug") # Needs debug symbols | |
LogTrace("LogTrace") # Needs debug symbols | |
def parseArgs(): | |
parser = argparse.ArgumentParser(description='Test OST verbosity levels.') | |
parser.add_argument('-v', '--verbose', dest='verbosity', action='append_const', | |
const=1, default = [2], | |
help = "Increase verbosity. Can be used multiple times.") | |
parser.add_argument('-q', '--quiet', dest='verbosity', action='append_const', | |
const = -1, | |
help = "Decrease verbosity. Can be used multiple times.") | |
args = parser.parse_args() | |
args.verbosity = sum(args.verbosity) | |
return args | |
if __name__ == "__main__": | |
args = parseArgs() | |
PushVerbosityLevel(args.verbosity) | |
testVerbosityLevel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment