Пример #1
0
 def getResources(self):
     # Reads application resources file
     def _setResource(line):
     # returns true if line defines resource and is not in menu
         if line[0] == '!':
             return 0
         name, value = line.split(None, 1)
         for m in self.menu:
             if m.id == name[:-1]:       # skip ':'
                 m.set(value[:-1])   # skip '\n'
                 return 0
         return 1
     
     filename = 'etc/app-resources/X'
     id = AvnParser.getForecasters().get(Globals.Forecaster, '')['id']
     ffilename = '%s.%s' % (filename, id)
     if not os.path.isfile(ffilename):
         Busy.showwarning('Cannot access resources file\n' + \
             'starting with defaults', self.parent) 
         ffilename = filename
     try:
         self.fresources = filter(_setResource, file(ffilename))
     except IOError:
         msg = 'Cannot access resources file'
         _Logger.exception(msg)
         Busy.showerror(msg, self.parent)
         self.fresources = []
         return
Пример #2
0
    def __restore(self):
        if not Busy.askokcancel("""This will delete your configuration.
Really want to continue?""", self.interior()):
            return
        id = AvnParser.getForecasters().get(Globals.Forecaster, '')['id']
        filename = 'etc/app-resources/X.%s' % id
        try:
            os.unlink(filename)
            self.getResources()
        except OSError:
            msg = 'Cannot remove %s' % filename
            _Logger.exception(msg)
            Busy.showerror(msg, self.interior())
Пример #3
0
def main():

    os.chdir(TopDir)
    sys.path = sys.path[1:]
    sys.path.extend([os.path.join(TopDir, 'py')])
    
    import AvnParser
    
    fdict = AvnParser.getForecasters()
    fcstrs = dict([(str(fdict[k]['id']),k) for k in fdict])
    okx='0'
    if os.uname()[1].find('-okx') > -1:
        okx='1'

    print 'Processing files in etc'
    rmvOldExtensions(os.path.join('etc'))
    #
    for _file in [x for x in os.listdir(os.path.join('etc','app-resources'))
                  if re.match('X\.\d+$',x)]:
        cvtFcstResourceFile(_file,okx,fcstrs.get(_file.split('.')[1],
                                                 'Unknown Forecaster'))        
    updateGUICfg(os.path.join('etc','gui.cfg'))
    updateWxPlotCfg(os.path.join('etc','wxplot.cfg'))
    updateServerCfg(os.path.join('etc','server.cfg'))
    updateXmitCfg(os.path.join('etc','xmit.cfg'))
#
    sites = [x for x in os.listdir(os.path.join('etc','tafs')) if re.match('[PNKT][A-Z0-9]{3}$',x)]
    for site in sites:
	cvtInfoCfg(site)
#        
    sites.insert(0,'XXXX')
    for site in sites:
        cvtMtrsCfg(site)

    for product in [x for x in os.listdir(os.path.join('etc','tafs')) if x.endswith('.cfg')]:
        cvtTAFPrdct(product)
    
    if okx == '1':
        print """Attention OKX ITO! Attention OKX AFP! Attention OKX ITO! Attention OKX AFP!

  You no longer have to alter TafEditDialog.__saveWorkFile() function
  to store the TAF workfile in the text database.  It is now
  implemented as a forecaster resource setting '*alwaySaveToDB'.  For
  all OKX forecasters, this new resource has been turned on as a
  convenience.
  """      
        print """Attention OKX ITO! Attention OKX AFP! Attention OKX ITO! Attention OKX AFP!"""
Пример #4
0
 def loadForecasters(self):
     try:
         fcstnames = AvnParser.getForecasters().keys()
         if not fcstnames:
             raise ValueError, 'Empty file'
         fcstnames.sort()
         self.slist.setlist(fcstnames)
     except IOError:
         msg = 'Cannot open forecaster file'
         _Logger.exception(msg)
         Busy.showerror(msg, self.interior())
         raise SystemExit
     except (ValueError, IndexError):
         msg = 'Invalid entry in forecaster file'
         _Logger.exception(msg)
         Busy.showerror(msg, self.interior())
         raise SystemExit
Пример #5
0
 def __save(self):
     ident = AvnParser.getForecasters().get(Globals.Forecaster, '')['id']
     filename = 'etc/app-resources/X.%s' % ident
     lines = ['!! file X.%s\n' % Globals.Forecaster]
     for m in self.menu:
         v = m.get()
         if v in (None, ''):
             msg = 'Missing entry for %s' % m.id
             _Logger.error(msg)
             Busy.showerror(msg, self.interior())
             return
         lines.append('%s:     %s\n' % (m.id, v))
     lines.extend(self.fresources)
     try:
         file(filename, 'w').writelines(lines)
         Busy.showinfo('Restart GUI for changes to take effect',
             self.interior())
     except IOError:
         msg = 'Cannot create %s' % filename
         _Logger.exception(msg)
         Busy.showerror(msg, self.interior())
     self.withdraw()