本文整理汇总了Python中Avn类的典型用法代码示例。如果您正苦于以下问题:Python Avn类的具体用法?Python Avn怎么用?Python Avn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Avn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getXmitTime
def getXmitTime(kind, headertime):
t = Avn.string2time('%s%s' % (Avn.time2string()[:6], headertime[2:])) \
+ 3600.0 - _Xmit_Windows[0]
now = time.time()
if t < now - 43200.0:
t += 86400.0
return max(t, now)
示例2: fixTafTempo
def fixTafTempo(p, t):
# eliminates TAF TEMPO elements that match those in FM group
if not ('obv' in t or 'pcp' in t) and 'vsby' in t:
tcat = Avn.category(t['vsby']['val'], _VsbyCat)
pcat = Avn.category(p['vsby']['val'], _VsbyCat)
if tcat == pcat:
del t['vsby']
else:
t['obv'] = {'str': 'NSW'}
if 'wind' in t:
tdd, tff = t['wind']['dd'], t['wind']['ff']
pdd, pff = p['wind']['dd'], p['wind']['ff']
if Avn.VARIABLE in (tdd, pdd):
delta = 0
else:
delta = abs(pdd - tdd)
if delta > 180:
delta = 360 - delta
if abs(tff-pff) < 10 and (max(tff, pff) < 12 or delta < 30):
del t['wind']
if 'sky' in t:
tcat = Avn.category(t['sky']['cig'], _CigCat)
pcat = Avn.category(p['sky']['cig'], _CigCat)
if tcat == pcat:
del t['sky']
示例3: _getOffset
def _getOffset(cfg, period):
offObv = 0
if 'obv' in period:
obv = period['obv']['str']
if 'HZ' in obv:
offObv |= 1
if 'BR' in obv or 'FG' in obv:
offObv |= 2
if 'BL' in obv:
offObv |= 4
offInt, offPcp = 0, 0
if 'pcp' in period:
pcp = period['pcp']['str']
if '-' in pcp:
offInt = 1
elif '+' in pcp:
offInt = 3
else:
offInt = 2
if 'SN' in pcp:
offPcp = 1
elif 'DZ' in pcp:
offPcp = 2
else:
offPcp = 3
offDD, offFF = Avn.wind_category(period['wind']['dd'],
period['wind']['ff'], cfg['dd'], cfg['ff'])
offVsby = Avn.category(period['vsby']['value'], cfg['vsby'])
offCig = Avn.category(period['sky']['cig'], cfg['cig'])
return offDD, offFF, offObv, offInt, offPcp, offCig, offVsby
示例4: __createMenuBar
def __createMenuBar(self):
self.menubar = Pmw.MenuBar(self.interior(),
hull_relief='raised',
hull_borderwidth=1,
)
self.menubar.pack(side='top', fill='x')
self.menubar.addmenu('Help', 'Help actions', side='right')
self.menubar.addmenuitem('Help', 'command',
label='Key bindings',
command=Avn.curry(self.showHelp, EditorTools.Help),
)
self.menubar.addmenuitem('Help', 'command',
label='Usage',
command=Avn.curry(self.showHelp, HelpEdit),
)
self.menubar.addmenu('File', 'Main actions', side='left')
self.menubar.addmenuitem('File', 'command',
'Invoke print dialog',
label = 'Print',
command=self.showPrintDialog,
)
self.menubar.addmenuitem('File', 'separator')
self.menubar.addmenuitem('File', 'command',
label = 'Close',
command=self.close,
)
self.menubar.addmenu('Edit', 'Editing actions', side='left')
self.menubar.addmenuitem('Edit', 'command',
label = 'Cut',
command=self.__cut,
)
self.menubar.addmenuitem('Edit', 'command',
label = 'Copy',
command=self.__copy,
)
self.menubar.addmenuitem('Edit', 'command',
label = 'Paste',
command=self.__paste,
)
self.menubar.addmenuitem('Edit', 'command',
label = 'Find',
command=self.__find,
)
self.menubar.addmenuitem('Edit', 'command',
label = 'Undo',
command=self.__undo,
)
self.menubar.addmenuitem('Edit', 'command',
label = 'Redo',
command=self.__redo,
)
示例5: __init__
def __init__(self, **kw):
self.root = Tk()
self.root.withdraw()
self.get_option_db()
Pmw.initialise(self.root, useTkOptionDb=1)
self.root.title(self.AppName)
Pmw.MegaWidget.__init__(self, parent=self.root)
self.root.resizable(0, 0)
ErrorRedirect.fixlogging(_Logger, self.interior())
interior = self.interior()
Busy.instantiate(interior)
self._img1 = PhotoImage(file=Image1)
self.slist = Pmw.ScrolledListBox(interior,
labelpos='n',
label_image=self._img1,
listbox_exportselection=0,
)
self.slist.pack(side='top', expand='yes', fill='x')
f = Frame(interior)
self._img2 = PhotoImage(file=Image2)
cfg = AvnParser.getGuiCfg()
self.servers = Pmw.ScrolledListBox(f,
labelpos='n',
label_image=self._img2,
items=cfg['ns'],
listbox_height=max(4, len(cfg['ns'])),
listbox_exportselection=0,
)
self.servers.pack(side='left', expand='yes', fill='x')
self.servers.selection_set(0)
self.bbox = Pmw.ButtonBox(f,
orient='vertical',
labelpos='w',
frame_borderwidth=2,
frame_relief='groove',
)
self.bbox.pack(side='left', expand='yes', fill='x')
self.bbox.add('TAFs', command=Avn.curry(self.ok, 'TAFs'))
self.bbox.add('Climate', command=Avn.curry(self.ok, 'Climate'))
self.bbox.add('Cancel', command=self.cancel)
self.bbox.setdefault('TAFs')
self.bbox.alignbuttons()
f.pack(side='top')
self.loadForecasters()
self.prods = 0
self.pid = 0
signal.signal(signal.SIGUSR1, self.handler)
signal.signal(signal.SIGCHLD, self.handler)
示例6: _makeTimeStamp
def _makeTimeStamp(tstamp):
# Returns time stamp used in output file name
now = time.time()
tmptstamp = '%s%s' % (Avn.time2string(now)[:4], tstamp)
# possible correction for next month/year
t = Avn.string2time(tmptstamp)
if t > now + 86400:
mm = int(tmptstamp[2:4]) - 1
yy = int(tmptstamp[:2])
if mm < 1:
mm = 12
yy -= 1
return '%02d%02d%s' % (yy, mm, tmptstamp[4:])
else:
return tmptstamp
示例7: getEtaData
def getEtaData(self, ids, issuetime=None):
# Returns most recent Eta model data
if type(ids) == type(''):
idslist = [ids]
else:
idslist = ids
data = []
for i in idslist:
path = os.path.join('data', 'eta', i)
try:
if issuetime:
f = Avn.time2string(issuetime) + '.data'
else:
f = _getFiles(path, 15, time.time()-86400.0, 1)[0]
data.append(Avn.Bunch(file=f,
data=cPickle.load(file(os.path.join(path, f)))))
except (IndexError, OSError):
pass
if type(ids) == type(''):
try:
return data[0]
except IndexError:
return None
else:
return data
示例8: __make_stats
def __make_stats(self):
now = time.time()
ftime = self.__get_timestamp()
if now - ftime < 3600.0*self._cfg['period']:
return
def _process_forecast(f):
ftok = f.split('-')
yymm = ftok[4][:4]
text = file(os.path.join('xmit', 'sent', f)).read()
if not text.startswith('TAF'):
return None
text = text[text.find('\n')+1:]
tafs = filter(None, [x.strip() for x in self.regSplit.split(text)])
def _makeLine(taf):
ttok = taf.split()
return ' '.join(ftok[2:6] + \
[ttok[0], yymm+ttok[1], ttok[2], ftok[0]])
return '\n'.join(map(_makeLine, tafs))
try:
report = '\n'.join(map(_process_forecast, self.__get_files(ftime)))
if not report:
raise Avn.AvnError, 'No data to process'
report += '\n'
tt, cc = self._cfg['wmo'].split()
path = os.path.join('xmit', 'pending', '%03d-%s-%s-%s-%s-%s-%-10d' \
% (self._cfg['fcstid'], self._cfg['awips'], tt, cc, \
Avn.time2string(now), '___', now))
file(path, 'w').write(report)
self.__update_timestamp()
except Avn.AvnError, e:
_Logger.warning(str(e))
self.__update_timestamp()
示例9: getEtaTable
def getEtaTable(self, ids, issuetime=None):
# Returns most recent tabulated ETA model data
if type(ids) == type(''):
idslist = [ids]
else:
idslist = ids
tables = []
for i in idslist:
path = os.path.join('data', 'eta', i)
try:
if issuetime:
f = Avn.time2string(issuetime) + '.table'
else:
f = _getFiles(path, 16, time.time()-86400.0, 1)[0]
tables.append(Avn.Bunch(file=f,
table=file(os.path.join(path, f)).read()))
except (IndexError, OSError):
pass
if type(ids) == type(''):
try:
return tables[0]
except IndexError:
return None
else:
return tables
示例10: getActiveRules
def getActiveRules(id_, namespace, source):
rules = []
# file containing rule definitions
fname = Avn.getTafPath(id_, source + '.cfg')
cp = ConfigParser.SafeConfigParser()
cp.read(fname)
try:
activeRules = cp.get('rules', 'active')
except Exception :
raise Avn.AvnError('No active rules in "%s"' % fname)
active = ['rule_'+x.strip() for x in cp.get('rules', 'active').split(',')]
if activeRules:
while 'rule_' in active:
active.remove('rule_')
if not activeRules or len(activeRules) == 0 :
raise Avn.AvnError('No active rules in "%s"' % fname)
for s in active:
try:
name = cp.get(s, 'method')
rule = namespace[name]()
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError), ex:
_Logger.error(' %s - in file %s' % (str(ex), fname))
continue
except KeyError:
_Logger.error('Invalid method: %s, for rule: %s - in file %s' % (name, s, fname))
continue
示例11: getCCFP
def getCCFP(self, id_, ftime=0):
# Retrieves recent CCFP newer than ftime
path = os.path.join('data', 'ccfp')
ccfps = []
try:
# get up to 3 most recent forecasts
# if valid times equal, select one with newer issue time
flist = _getFiles(path, 13, ftime, 3)
vtimes = [Avn.string2time(x)+3600.0*int(x[-2:]) for x in flist]
tmp = [(vtimes[0], flist[0])]
for n, t in enumerate(vtimes[1:]):
if t not in vtimes[:n+1]:
tmp.append((vtimes[n+1], flist[n+1]))
tmp.sort()
for t, f in tmp:
try:
data = file(os.path.join(path, f)).read()
lines = data.split('\n')
for line in lines[1:]:
if line.startswith(id_):
ccfps.append(Avn.Bunch(file=f, header=lines[0],
text=line))
break
else:
ccfps.append(Avn.Bunch(file=f, header=lines[0],
text=''))
except OSError:
pass
return ccfps
except (OSError, IndexError):
return ccfps
示例12: method
def method(self, taf, grids):
self.setmsg('Ceilings categories differs by %d', self.args['ncat'])
try:
thresholds = self.sitedata['thresholds']['cig']
tclo = Avn.category(taf['sky']['lo'], thresholds)
tchi = Avn.category(taf['sky']['hi'], thresholds)
gclo = Avn.category(grids['sky']['lo'], thresholds)
gchi = Avn.category(grids['sky']['hi'], thresholds)
if gchi < tclo:
return tclo-gchi >= self.args['ncat']
elif gclo > tchi:
return gclo-tchi >= self.args['ncat']
else:
return False
except KeyError:
raise Avn.AvnMissing
示例13: getIssueTime
def getIssueTime(kind, bbb, t=None):
if t is None:
t = time.time()
if not bbb or bbb[0] == ' ': # regular issue forecast
itime = Avn.string2time('%s00' % getFmtValidTime(kind, bbb, t)[:8])
itime -= _Xmit_Windows[0]
if itime > t:
return itime
return t
示例14: _readPrbConf
def _readPrbConf():
conf=ConfigParser.ConfigParser()
conf.read(Avn.getTafPath('XXXX', 'grid_prob.cfg'))
prb_conf={'before9hr': {},'after9hr': {}}
wxkeys = ['S', 'IS', 'WS', 'SC', 'NM', 'O', 'C', 'D', 'WP', 'L']
for wx in wxkeys:
prb_conf['before9hr'][wx] = conf.getint('before9hr',wx)
prb_conf['after9hr'][wx] = conf.getint('after9hr',wx)
return prb_conf
示例15: _cleanup
def _cleanup(path, nhours):
tstamp = Avn.time2string(time.time()-nhours*3600.0)
for f in os.listdir(path):
if f[:10] < tstamp:
fname = os.path.join(path, f)
try:
os.unlink(fname)
except OSError, e:
_Logger.exception('Cannot remove %s', fname)