本文整理汇总了Python中lib.GlobalData类的典型用法代码示例。如果您正苦于以下问题:Python GlobalData类的具体用法?Python GlobalData怎么用?Python GlobalData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GlobalData类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ValueError
elif ruleElement.type == "second":
logString = ("%s second " % spaceString
+ "(start=%d, " % ruleElement.element.start
+ "end=%d)") % ruleElement.element.end
logging.info("[%s]: %s" % (fileName, logString))
else:
raise ValueError("Rule has invalid type: '%s'." % ruleElement.type)
if __name__ == '__main__':
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
# parse config file, get logfile configurations
# and initialize logging
try:
configRoot = xml.etree.ElementTree.parse(
globalData.configFile).getroot()
logfile = str(configRoot.find("general").find("log").attrib["file"])
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
tempLoglevel = tempLoglevel.upper()
示例2: GlobalData
from lib import ServerCommunication, ConnectionWatchdog
from lib import SMTPAlert
from lib import LightningmapSensor, LightningmapDataCollector, SensorExecuter
from lib import UpdateChecker
from lib import GlobalData
import logging
import time
import socket
import random
import xml.etree.ElementTree
if __name__ == '__main__':
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
# parse config file, get logfile configurations
# and initialize logging
try:
configRoot = xml.etree.ElementTree.parse(
globalData.configFile).getroot()
logfile = str(configRoot.find("general").find("log").attrib["file"])
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
tempLoglevel = tempLoglevel.upper()
示例3: print
# Do nothing if the given location is an absolute path.
if inputLocation[0] == "/":
return inputLocation
# Replace ~ with the home directory.
elif inputLocation[0] == "~":
return os.environ["HOME"] + inputLocation[1:]
# Assume we have a given relative path.
return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation
if __name__ == '__main__':
print(asciiLogo)
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
# parse config file, get logfile configurations
# and initialize logging
try:
configRoot = xml.etree.ElementTree.parse(
globalData.configFile).getroot()
logfile = makePath(
str(configRoot.find("general").find("log").attrib["file"]))
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
示例4: makePath
# Function creates a path location for the given user input.
def makePath(inputLocation):
# Do nothing if the given location is an absolute path.
if inputLocation[0] == "/":
return inputLocation
# Replace ~ with the home directory.
elif inputLocation[0] == "~":
return os.environ["HOME"] + inputLocation[1:]
# Assume we have a given relative path.
return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation
if __name__ == '__main__':
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
# parse config file, get logfile configurations
# and initialize logging
try:
configRoot = xml.etree.ElementTree.parse(
globalData.configFile).getroot()
logfile = makePath(
str(configRoot.find("general").find("log").attrib["file"]))
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
示例5: ValueError
elif ruleElement.type == "second":
logString = ("%s second " % spaceString
+ "(start=%d, " % ruleElement.element.start
+ "end=%d)") % ruleElement.element.end
logging.info("[%s]: %s" % (fileName, logString))
else:
raise ValueError("Rule has invalid type: '%s'." % ruleElement.type)
if __name__ == '__main__':
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
# parse config file, get logfile configurations
# and initialize logging
try:
configRoot = xml.etree.ElementTree.parse(
globalData.configFile).getroot()
globalData.logdir = makePath(str(configRoot.find("general").find(
"log").attrib["dir"]))
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
示例6: print
+ "(Optional)",
default=False)
parser.add_option_group(optGroup)
(options, args) = parser.parse_args()
showHelp = (options.add
or options.delete
or options.modify
or options.list)
if showHelp is False:
print("Use --help to get all available options.")
sys.exit(0)
# Generate object of the global needed data.
globalData = GlobalData()
fileName = os.path.basename(__file__)
instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"
validNodeTypes = ["sensor", "manager", "alert"]
# Parse config file.
try:
configRoot = xml.etree.ElementTree.parse(instanceLocation +
"/config/config.xml").getroot()
# Parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
tempLoglevel = tempLoglevel.upper()
示例7: GlobalData
default=False)
parser.add_option("-f", "--force", dest="force", action="store_true",
help="Do not check the version. Just update all files.",
default=False)
(options, args) = parser.parse_args()
if options.update is False:
print "Use --help to get all available options."
sys.exit(0)
protocolUpdate = False
configUpdate = False
# generate object of the global needed data
globalData = GlobalData()
fileName = os.path.basename(__file__)
instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"
try:
# parse config file
configRoot = xml.etree.ElementTree.parse(instanceLocation +
"/config/config.xml").getroot()
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
tempLoglevel = tempLoglevel.upper()
if tempLoglevel == "DEBUG":
loglevel = logging.DEBUG
示例8: GlobalData
if inputLocation[0] == "/":
return inputLocation
# Replace ~ with the home directory.
elif inputLocation[0] == "~":
return os.environ["HOME"] + inputLocation[1:]
# Assume we have a given relative path.
return os.path.dirname(os.path.abspath(__file__)) + "/" + inputLocation
if __name__ == '__main__':
fileName = os.path.basename(__file__)
instanceLocation = os.path.dirname(os.path.abspath(__file__)) + "/"
# generate object of the global needed data
globalData = GlobalData()
try:
# parse config file
configRoot = xml.etree.ElementTree.parse(instanceLocation +
"/config/config.xml").getroot()
# parse chosen log level
tempLoglevel = str(
configRoot.find("general").find("log").attrib["level"])
tempLoglevel = tempLoglevel.upper()
if tempLoglevel == "DEBUG":
loglevel = logging.DEBUG
elif tempLoglevel == "INFO":
loglevel = logging.INFO
elif tempLoglevel == "WARNING":