本文整理汇总了Python中LogStream.exc方法的典型用法代码示例。如果您正苦于以下问题:Python LogStream.exc方法的具体用法?Python LogStream.exc怎么用?Python LogStream.exc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogStream
的用法示例。
在下文中一共展示了LogStream.exc方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _expandUGC
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def _expandUGC(self, ugcString):
#expand a UGC string into its individual UGC codes, returns the list.
ugc_list = [] #returned list of ugc codes
ugc_line = None
if ( self._hasDTG ):
ugc_line = ugcString[0:-8] #eliminate dtg at end of ugc string
else:
ugc_line = ugcString
#print "ugc_line is ", ugc_line
working_ugc_list = ugc_line.split('-') #individual parts
state = ''
code_type = ''
for ugc in working_ugc_list:
try:
# Case One (i.e., WIZ023)...
if len(ugc) == 6:
state, code_type, decUGCs = self._ugcCaseOne(ugc)
for d in decUGCs:
ugc_list.append(d)
# Case Two (i.e., 023)...
elif len(ugc) == 3:
decUGCs = self._ugcCaseTwo(ugc, state, code_type)
for d in decUGCs:
ugc_list.append(d)
# Case Three (ie. 044>067)
elif len(ugc) == 7:
decUGCs = self._ugcCaseThree(ugc, state, code_type)
for d in decUGCs:
ugc_list.append(d)
# Case Four (ie. WIZ044>067)
elif len(ugc) == 10:
state, code_type, decUGCs = self._ugcCaseFour(ugc)
for d in decUGCs:
ugc_list.append(d)
# Problem - malformed UGC
else:
raise Exception, "Malformed UGC Found"
except:
LogStream.logProblem("Failure to decode UGC [" + ugc + \
"] in [" + ugc_line + "]", `self._lines`, LogStream.exc())
raise Exception, "Failure to decode UGC"
#print "ugc_list is ", ugc_list
return ugc_list
示例2: purgeOldSavedTables
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def purgeOldSavedTables(self, purgeTime):
#purges old saved tables
if self._activeTableFilename is None:
raise Exception, "purgeOldSavedTables without filename"
#calculate purge time
purgeTime = time.time() - (purgeTime * 3600)
#directory and files
directory = os.path.join(os.path.dirname(self._activeTableFilename), "backup")
baseN = os.path.basename(self._activeTableFilename)
idx = baseN.find(".")
if idx != -1:
baseN = baseN[0:idx]
files = glob.glob(directory + "/*" + baseN + "*.gz")
#delete files older than purgeTime
for f in files:
try:
modTime = os.stat(f)[stat.ST_MTIME]
if modTime < purgeTime:
os.remove(f)
LogStream.logDebug("Removing old file: ", f)
except:
LogStream.logProblem("Problem Removing old backup file: ", f,
LogStream.exc())
示例3: main
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def main():
LogStream.logEvent("setupTextEA Starting")
try:
obj = setupTextEA()
obj.process()
except Exception, e:
LogStream.logProblem(LogStream.exc())
sys.exit(1)
示例4: executeFromJava
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def executeFromJava(databaseID):
LogStream.logEvent("PurgeAllGrids starting")
try:
process(databaseID)
LogStream.logEvent("PurgeAllGrids finished")
sys.exit(0)
except SystemExit:
pass
except:
LogStream.logProblem("Caught exception\n", LogStream.exc())
示例5: main
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def main():
LogStream.ttyLogOn();
LogStream.logEvent("getEditAreas Starting")
LogStream.logEvent(AFPS.DBSubsystem_getBuildDate(),
AFPS.DBSubsystem_getBuiltBy(),
AFPS.DBSubsystem_getBuiltOn(),
AFPS.DBSubsystem_getBuildVersion())
try:
obj = simpleFetch()
obj.SetIntersection()
except Exception, e:
LogStream.logBug(LogStream.exc())
sys.exit(1)
示例6: saveOldActiveTable
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def saveOldActiveTable(self, oldActiveTable):
#saves off the specified table and time stamps it
if self._activeTableFilename is None:
raise Exception, "saveOldActiveTable without filename"
#determine filename
directory = os.path.join(os.path.dirname(self._activeTableFilename), "backup")
try:
os.makedirs(directory)
except OSError as e:
if e.errno != errno.EEXIST:
LogStream.logProblem("Could not create active table backup directory:",
directory, LogStream.exc())
raise e
gmtime = time.gmtime(time.time())
format = "%Y%m%d_%H%M%S"
baseN = os.path.basename(self._activeTableFilename)
fn = time.strftime(format, gmtime) + "_" + baseN
filename = os.path.join(directory, fn + ".gz")
t = time.time()
try:
os.chmod(filename, 0666)
os.remove(filename)
except:
pass
#output file
#gzip it to save space
with gzip.GzipFile(filename, 'wb', 9) as fd:
buf = cPickle.dumps(oldActiveTable)
fd.write(buf)
os.chmod(filename, 0664)
t1 = time.time()
tstr = "%.3f" % (t1-t)
LogStream.logVerbose("Saved Previous Active Table: ", fn, "t=",
tstr, "sec.")
示例7: _getPilAndDTG
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def _getPilAndDTG(self):
#searches through the product (lines) and extracts out the product
#pil and date-time group. Returns (pil, issueTime, lineEnd, fullpil).
# The line end is how far the processing got for the PIL line.
count = 0
while 1:
dtg_search = re.search(r' ([0123][0-9][012][0-9][0-5][0-9])',
self._lines[count])
pil_search = re.search(r'^([A-Z]{3})(\w{3}|\w{2}|\w{1})',
self._lines[count+1])
if dtg_search and pil_search:
LogStream.logVerbose("Dtg=", dtg_search.group(0))
LogStream.logVerbose("Pil=", pil_search.group(0))
return (self._lines[count+1][0:3],
self._dtgFromDDHHMM(dtg_search.group(1)), count+2,
pil_search.group(0))
count = count + 1
if count >= len(self._lines)-1:
LogStream.logProblem("Did not find either the product DTG" +\
" or the pil: ", string.join(self._lines, sep='\n'),
LogStream.exc())
raise Exception, "Product DTG or Pil missing"
示例8: createComboFiles
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def createComboFiles(definitionDir, outputDir, mapDict):
#list of definition files
LogStream.logEvent("definitionDir", definitionDir)
files = glob.glob(definitionDir + '/*Definition.py')
for f in files:
LogStream.logEvent("File", f)
# read the file
fd = open(f, 'r')
buf = fd.read()
fd.close()
LogStream.logVerbose("Definition File:", f)
# attempt to read in the Definition dictionary
try:
exec buf
except:
LogStream.logProblem("Failure on Definition: ", f)
continue
if Definition.has_key("mapNameForCombinations") and \
Definition.has_key("defaultEditAreas") and \
type(Definition['defaultEditAreas']) is str:
srcDict = {} #keep track of what zones from what map
#determine if a single map or multiple maps
if type(Definition["mapNameForCombinations"]) is str:
maps = [Definition["mapNameForCombinations"]]
else:
maps = []
for m in Definition["mapNameForCombinations"]:
maps.append(m)
LogStream.logVerbose("mapNameForCombinations=", maps)
outName = Definition["defaultEditAreas"]
LogStream.logVerbose("Generating Combo File: ", outName)
#See if the definition limits the zones to subdomains
if Definition.has_key("subDomainUGCs") and \
Definition["subDomainUGCs"] is not None:
limitZones = Definition["subDomainUGCs"]
else:
limitZones = None
#pull out the EDITAREA attribute from all of the maps
eans = []
for m in maps:
names = mapDict.get(m)
if names is not None:
size = names.size()
LogStream.logVerbose("processing: ", m, "#recs=",
size)
for n in range(size):
ean = str(names.get(n))
if limitZones is None or ean in limitZones:
#tracking source map
if len(ean):
slist = srcDict.get(m, [])
if ean not in slist:
slist.append(ean)
srcDict[m] = slist
#combo file
if ean not in eans and len(ean):
eans.append(ean)
eans.sort()
LogStream.logVerbose("eans=", eans)
s = """
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# Combinations
# <comboName>
#
# Author: GFESuite Installation Script
# ----------------------------------------------------------------------------
# Format:
# Combinations = [
# ([ list of edit areas as named in the GFE ], label),
# ...
# ]
Combinations = [
"""
s = string.replace(s, "<comboName>",
Definition['defaultEditAreas'])
count = 1
for ean in eans:
s = s + ' (["' + ean + '"], "Region' + `count` + \
'"),\n'
#.........这里部分代码省略.........
示例9: _runTestScript
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def _runTestScript(self, index):
entry = self._testScript[index]
# Set defaults
database, user, checkMethod, checkStrings = self._setDefaults()
# Process entry
name = entry["name"]
productType = entry["productType"]
database = entry.get("database", database)
user = entry.get("user", user)
# gridsStartTime
self._gridsStartTime = entry.get("gridsStartTime", None)
if self._gridsStartTime is None:
self._gridsStartTime = self.getTimeRange("Today").startTime()
else:
if not isinstance(self._gridsStartTime, AbsTime.AbsTime):
self._gridsStartTime = self.getAbsTime(self._gridsStartTime)
#print "gridsStartTime", self._gridsStartTime
# drtTime
drtTime = entry.get("drtTime")
if drtTime is None:
drtTime = entry.get("gridsStartTime", None)
#print "\n*********drtTime", drtTime
if drtTime is not None:
if isinstance(drtTime, AbsTime.AbsTime):
drtTime = self.getTimeStr(drtTime)
drtStr = drtTime
self._drtString = drtTime
else:
drtStr = ""
self._drtString = None
#print "drtStr", drtStr
self._clearHazardsTable(entry)
self._createCombinationsFile(entry)
self._deleteGrids(entry)
self._createGrids(entry)
self._makeWritableCopy(entry)
#changed = self._fileChanges(entry)
runtimeModuleChanges = self._runTimeModuleChanges(entry)
if runtimeModuleChanges:
exec "changes = " + runtimeModuleChanges
for moduleName, chg in changes:
self._magicCodeChange(moduleName, chg)
cmdLineVars = self._getCmdLineVars(entry)
vtecMode = entry.get("vtecMode", None)
if productType is None:
return
#script = "runIFPText" +\
# " -t " + productType +\
# " -a PRACTICE" +\
# " -h " + host +\
# " -p " + port +\
# " -d " + database +\
# " -u " + user +\
# " -S " + \
# cmdLineVars +\
# drtStr +\
# vtecModeStr
#script = script.replace("<site>", self.getSiteID())
database = database.replace("<site>", self.getSiteID())
# Run the product
if self._reportingMode not in ["Pretty"]:
self.output("Running " + name, self._outFile)
message = "Running " + name
self.statusBarMsg(message, "R", category="GFE")
# this way goes through java in separate threads, debugging doesn't work with it cause each
# thread has its own interpreter....
#waiter = TextProductFinishWaiter()
#FormatterUtil.runFormatterScript(productType, vtecMode, database, cmdLineVars, "PRACTICE", drtTime, changes, waiter)
#fcst = waiter.waitAndGetProduct()
import FormatterRunner
try:
fcst = FormatterRunner.runFormatter(databaseID=database, site="TBW",
forecastList=[productType], cmdLineVarDict=cmdLineVars,
vtecMode=vtecMode, vtecActiveTable='PRACTICE', drtTime=drtTime,
username='GFETEST', dataMgr=self._dataMgr)
except:
fcst = ''
LogStream.logProblem("Error generating product: " + LogStream.exc())
self._doExecuteMsg(name, fcst, entry, drtTime)
示例10: createCityLocation
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def createCityLocation(outputDir, mapDict):
LogStream.logEvent("Generating CityLocation")
citydict = CityLocationDict
if dict != type(mapDict):
import JUtil
mapDict = JUtil.javaObjToPyVal(mapDict)
for mapname in mapDict.keys():
if mapname.find("Cities") == -1:
continue
attList = mapDict[mapname]
for att in attList:
#LogStream.logProblem("att:", att)
ean = att['name']
state = att['st']
county_FIP = att['county_fip']
if len(ean) and len(state) and len(county_FIP):
fip = state + 'C' + county_FIP
if not citydict.has_key(fip):
citydict[fip] = {}
try:
latitude = float(string.strip(att['lat']))
longitude = float(string.strip(att['lon']))
citydict[fip][ean.upper()] = (latitude, longitude)
except:
LogStream.logProblem("Problem creating city location ",
ean, att, LogStream.exc())
s = """
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# CityLocation
# CityLocation file
#
# Author: GFE Installation Script
# ----------------------------------------------------------------------------
# Format:
# CityLocation = {
# "editArea": {"cityName1" : (latitude, longitude),
# "cityName2" : (latitude, longitude),
# ...
# }
# ...
# }
#
# editArea: name of edit area as in AreaDictionary
#
# cityName: name of the city - should be the same as in AreaDictionary.
#
# latitude/longitude: city's lat/lon location.
#
CityLocation = \
"""
pp = pprint.PrettyPrinter()
s = s + pp.pformat(citydict)
if not os.path.isdir(outputDir):
os.makedirs(outputDir)
outName = os.path.join(outputDir, "CityLocation.py")
fh = None
try:
fh, fpath = tempfile.mkstemp(dir=outputDir, suffix=".py")
os.write(fh, s)
os.chmod(fpath, stat.S_IRUSR | stat.S_IWUSR |
stat.S_IRGRP | stat.S_IWGRP |
stat.S_IROTH)
os.close(fh)
fh = None
os.rename(fpath, outName)
except:
LogStream.logProblem("Error writing city location", LogStream.exc())
finally:
if fh is not None:
os.close(fh)
示例11: createAreaDictionary
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
def createAreaDictionary(outputDir, mapDict):
LogStream.logEvent("Generating AreaDictionary")
areadict = {}
mapIter = mapDict.entrySet().iterator()
while mapIter.hasNext():
entry = mapIter.next()
ean = str(entry.getKey())
att = entry.getValue()
if len(ean):
try:
d = {}
if att.containsKey('zone') and att.containsKey('state'):
d['ugcCode'] = str(att.get('state')) + "Z" + str(att.get('zone'))
elif att.containsKey('id'):
d['ugcCode'] = str(att.get('id'))
elif att.containsKey('fips') and att.containsKey('state') and \
att.containsKey('countyname'):
d['ugcCode'] = str(att.get('state')) + "C" + str(att.get('fips'))[-3:]
d['ugcName'] = string.strip(str(att.get('countyname')))
else:
continue
if att.containsKey('state'):
d["stateAbbr"] = str(att.get('state'))
if att.containsKey('name'):
d["ugcName"] = string.strip(str(att.get('name')))
if att.containsKey('time_zone'):
tzvalue = getRealTimeZone(str(att.get('time_zone')))
if tzvalue is not None:
d["ugcTimeZone"] = tzvalue
if zonedata.has_key(d['ugcCode']):
cityDict = zonedata[d['ugcCode']]
elif fipsdata.has_key(d['ugcCode']):
cityDict = fipsdata[d['ugcCode']]
else:
cityDict = None
if cityDict:
cityString = makeCityString(cityDict)
if cityString is not None:
cityString, locs = cityString
if len(cityString):
d["ugcCityString"] = cityString
CityLocationDict[ean] = locs
# partOfState codes
if zonedata.has_key(d['ugcCode']):
if zonedata[d['ugcCode']].has_key('partOfState'):
d["partOfState"] = \
zonedata[d['ugcCode']]['partOfState']
elif fipsdata.has_key(d['ugcCode']):
if fipsdata[d['ugcCode']].has_key('partOfState'):
d["partOfState"] = \
fipsdata[d['ugcCode']]['partOfState']
# full state name
if zonedata.has_key(d['ugcCode']):
if zonedata[d['ugcCode']].has_key('fullStateName'):
d["fullStateName"] = \
zonedata[d['ugcCode']]['fullStateName']
elif fipsdata.has_key(d['ugcCode']):
if fipsdata[d['ugcCode']].has_key('fullStateName'):
d["fullStateName"] = \
fipsdata[d['ugcCode']]['fullStateName']
else:
marineState = checkMarineState(d['ugcCode'])
if marineState is not None:
d['fullStateName'] = marineState
if areadict.has_key(ean) and d != areadict[ean]:
LogStream.logDiag("Mismatch of definitions in " +\
"AreaDictionary creation. EditAreaName=", ean,
"AreaDict=\n", areadict[ean], "\nIgnored=\n", d)
else:
areadict[ean] = d
except:
LogStream.logProblem("Problem with ", ean, LogStream.exc())
s = """
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# AreaDictionary
# AreaDictionary file
#
# Author: GFE Installation Script
# ----------------------------------------------------------------------------
# Format:
# AreaDictionary = {
# "editArea" : {
# "ugcCode": "STZxxx",
# "ugcName": "EditAreaName",
# "ugcCityString": "...CITY1...CITY2",
#.........这里部分代码省略.........
示例12: usage
# 需要导入模块: import LogStream [as 别名]
# 或者: from LogStream import exc [as 别名]
s = "Missing output directory: " + outDir
LogStream.logProblem(s)
usage()
raise SyntaxError, s
if not os.path.isdir(outDir):
s = "Specified output directory is not a directory: " + outDir
LogStream.logProblem(s)
usage()
raise SyntaxError, s
if not os.access(outDir, os.W_OK):
s = "Output directory is not writable: " + outDir
LogStream.logProblem(s)
usage()
raise SyntaxError, s
pngTimeRange = TimeRange.TimeRange(startTime, endTime)
try:
pngw = PngWriter(config,userNameOption, baseTime,
pngTimeRange, usrTimeName)
pngw.paint(outDir)
except Exception, e:
LogStream.logProblem(LogStream.exc())
sys.exit(1)
LogStream.logEvent("ifpIMAGE Finished")
if __name__ == "__main__":
main()