本文整理匯總了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":