Changeset 9384

Show
Ignore:
Timestamp:
05/28/09 13:39:30 (6 years ago)
Author:
stedwar2
Message:

Updated to work with OEF v1.1.2.

Location:
ossiedev/branches/0.7.x/tools/WaveDev/wavedev
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/0.7.x/tools/WaveDev/wavedev/ComponentFrame.py

    r8729 r9384  
    3232import PropertiesDialog 
    3333import cfg 
     34from chmod import chmod 
    3435import string 
    3536 
     
    333334        if os.path.islink (self.wavedevPath): 
    334335            self.wavedevPath = os.path.realpath (self.wavedevPath) 
    335         self.wavedevPath = os.path.dirname (os.path.abspath (self.wavedevPath))  
     336        self.wavedevPath = os.path.dirname (os.path.abspath (self.wavedevPath)) 
    336337 
    337338        #NOTE: There still may be a better way to do this, 
     
    10271028                if self.template != "py_comp": 
    10281029                    shutil.copy(self.wavedevPath + '/generate/reconf',self.path) 
    1029                     os.chmod(self.path + '/reconf', 0755) 
    1030                 if self.licensefile != "": 
     1030                    chmod(self.path + '/reconf', 0755) 
     1031        if self.licensefile != "": 
    10311032                    shutil.copy(self.licensefile,self.path + '/LICENSE') 
    10321033 
  • ossiedev/branches/0.7.x/tools/WaveDev/wavedev/cfg.py

    r8729 r9384  
    2323import xml.dom.minidom 
    2424import os 
     25import traceback 
     26 
     27##------------------------------------------------------------------------- 
     28## Doc 
     29##------------------------------------------------------------------------- 
     30""" 
     31This module provides functions for accessing configuration settings 
     32stored in the wavedev.cfg file (in xml).  The primary functions provided 
     33for use in other modules are defined in the "public" section of the 
     34module below. 
     35 
     36The configuration file is a simple XML file where values are stored 
     37in specialized tags.  Each value has a name, and is encoded in the 
     38XML file as a child tag of the top-level <owdconfiguration> tag that 
     39looks like this: 
     40    <name>value</name> 
     41 
     42To look up a configuration value, simply provide the corresponding name 
     43as an argument to ossieCfgValue().  The XML in the config file is parsed 
     44only once, and results are cached internally within this module.  Provisions 
     45are also made to override configuration settings loaded from the config 
     46file using the overrideCfgValue() function.  Special methods for retrieving 
     47the version() and ossieInstallDir() are provided as separate methods, since 
     48they are used more frequently.  These methods are shallow wrappers around 
     49ossieCfgValue(). 
     50 
     51Names in this file that begin with double-underscores ("__") are intended 
     52to be private and should not be referenced outside this file. 
     53""" 
     54 
     55##------------------------------------------------------------------------- 
     56## Public functions 
     57##------------------------------------------------------------------------- 
     58 
     59def version(): 
     60    """ 
     61    Get the current OSSIE version by looking up the "version" key. 
     62    """ 
     63    result = ossieCfgValue('version') 
     64    if result == None: 
     65        result = 'unknown' 
     66    return result 
     67 
     68 
     69def ossieInstallDir(): 
     70    """ 
     71    Get the location of the OSSIE installation directory by looking 
     72    up the "installpath" key.  This function ensures that the return 
     73    value always ends in a trailing slash. 
     74    """ 
     75    return ensureDirHasTrailingSlash(ossieCfgValue('installpath')) 
     76 
     77 
     78def ossieCfgValue(key): 
     79    """ 
     80    Look up a key in the configuration file and return its associated value. 
     81    """ 
     82    global __overrides 
     83    if __overrides.has_key(key): 
     84        return __overrides[key] 
     85    else: 
     86        val = __keyFromXml(key) 
     87        # cache it 
     88        if val != None: 
     89            setCfgValueIfNecessary(key, val) 
     90        return val 
     91 
     92 
     93def overrideCfgValue(key, value): 
     94    """ 
     95    Override a configuration value from the config file for the current 
     96    process, without rewriting the configuration file. 
     97    """ 
     98    global __overrides 
     99    __overrides['key'] = value 
     100 
     101 
     102def setCfgValueIfNecessary(key, value): 
     103    """ 
     104    Set an override value for a configuration setting, if no override 
     105    value is already recorded. 
     106    """ 
     107    global __overrides 
     108    if not __overrides.has_key(key): 
     109        overrideCfgValue(key, value) 
     110 
     111 
     112def ensureDirHasTrailingSlash(dir): 
     113    """ 
     114    Add a trailing slash to the dir, if there isn't one there already. 
     115    """ 
     116    if dir != None and dir[len(dir) - 1] != '/': 
     117        dir = dir + '/' 
     118    return dir 
     119 
     120 
     121def commentLine(): 
     122    """ 
     123    Generate an XML comment line containing the current version number 
     124    for use in automatically generated XML files. 
     125    """ 
     126    global __commentLine 
     127    if __commentLine == None: 
     128        __commentLine = u'<!--Created with OSSIE WaveDev ' + version() \ 
     129            + u'-->\n<!--Powered by Python-->\n' 
     130    return __commentLine 
     131 
    25132 
    26133def LoadConfiguration(frame_obj): 
    27     '''Extracts information from configuration file''' 
    28     root = __file__ 
    29     if os.path.islink (root): 
    30         root = os.path.realpath (root) 
    31     root = os.path.dirname (os.path.abspath (root)) 
    32  
    33     doc_cfg = xml.dom.minidom.parse(root + '/../wavedev.cfg') 
    34  
    35     # version 
    36     try: 
    37         frame_obj.version = \ 
    38                 str(doc_cfg.getElementsByTagName("version")[0].firstChild.data) 
    39     except: 
    40         frame_obj.version = "unknown" 
     134    """ 
     135    This function used to be located in MainFrame.py, but is used by 
     136    both MainFrame and ComponentFrame to load configuration settings 
     137    into fields within the provided frame_obj.  It was moved here, since 
     138    it is used by both of those other modules. 
     139    """ 
     140    frame_obj.version = version() 
     141 
    41142 
    42143    # install path 
    43     try: 
    44         frame_obj.installPath = \ 
    45                 str(doc_cfg.getElementsByTagName("installpath")[0].firstChild.data) 
    46         if frame_obj.installPath[len(frame_obj.installPath)-1] != '/': 
    47             frame_obj.installPath = frame_obj.installPath + '/' 
    48     except: 
    49         frame_obj.installPath = "" 
     144    frame_obj.installPath = ossieInstallDir() 
    50145 
    51146    # standard IDL path 
    52     use_default_stdidlpath = False 
    53     try: 
    54         frame_obj.stdIdlPath = str(doc_cfg.getElementsByTagName("stdidlpath")[0].firstChild.data) 
    55     except: 
    56         frame_obj.stdIdlPath = "" 
    57     if len(frame_obj.stdIdlPath) > 0: 
    58         if frame_obj.stdIdlPath[len(frame_obj.stdIdlPath)-1] != '/': 
    59             frame_obj.stdIdlPath = frame_obj.stdIdlPath + '/' 
    60         # see if directory actually exists 
    61         if not os.path.isdir(frame_obj.stdIdlPath): 
     147    frame_obj.stdIdlPath = ensureDirHasTrailingSlash(ossieCfgValue('stdidlpath')) 
     148    if frame_obj.stdIdlPath == None or not os.path.isdir(frame_obj.stdIdlPath): 
     149        if frame_obj.stdIdlPath == None: 
     150            print "warning: wavedev.cfg stdidl path is not set" 
     151        else: 
    62152            print "warning: wavedev.cfg stdidl path " + frame_obj.stdIdlPath + " does not exist" 
    63             print "  => using default standard idl path instead" 
    64             use_default_stdidlpath = True 
    65     else: 
    66         use_default_stdidlpath = True 
    67  
    68     if use_default_stdidlpath: 
    69         if os.path.isdir("/usr/include/standardinterfaces"): 
    70             frame_obj.stdIdlPath = "/usr/include/standardinterfaces/" 
    71         elif os.path.isdir("/usr/local/include/standardinterfaces"): 
    72             frame_obj.stdIdlPath = "/usr/local/include/standardinterfaces/" 
     153        print "  => using default standard idl path instead" 
     154 
     155        # Attempt to use a default value 
     156        if os.path.isdir('/usr/include/standardinterfaces'): 
     157            frame_obj.stdIdlPath = '/usr/include/standardinterfaces/' 
     158        elif os.path.isdir('/usr/local/include/standardinterfaces'): 
     159            frame_obj.stdIdlPath = '/usr/local/include/standardinterfaces/' 
    73160        else: 
    74161            tmpstr = "StandardInterfaces does not appear to be installed!\n" 
     
    81168 
    82169    # custom IDL path 
    83     use_default_customidlpath = False 
    84     try: 
    85         frame_obj.customIdlPath = str(doc_cfg.getElementsByTagName("customidlpath")[0].firstChild.data) 
    86     except: 
    87         frame_obj.customIdlPath = "" 
    88     if len(frame_obj.customIdlPath) > 0: 
    89         if frame_obj.customIdlPath[len(frame_obj.customIdlPath)-1] != '/': 
    90             frame_obj.customIdlPath = frame_obj.customIdlPath + '/' 
    91         # see if directory actually exists 
    92         if not os.path.isdir(frame_obj.customIdlPath): 
     170    frame_obj.customIdlPath = ensureDirHasTrailingSlash(ossieCfgValue('customidlpath')) 
     171    if frame_obj.customIdlPath == None or not os.path.isdir(frame_obj.customIdlPath): 
     172        if frame_obj.customIdlPath == None: 
     173            print "warning: wavedev.cfg customidl path is not set" 
     174        else: 
    93175            print "warning: wavedev.cfg customidl path " + frame_obj.customIdlPath + " does not exist" 
    94             print "  => using default custom idl path instead" 
    95             use_default_customidlpath = True 
    96     else: 
    97         use_default_customidlpath = True 
    98  
    99     if use_default_customidlpath: 
    100         if os.path.isdir("/usr/include/custominterfaces"): 
    101             frame_obj.customIdlPath = "/usr/include/custominterfaces/" 
    102         elif os.path.isdir("/usr/local/include/custominterfaces"): 
    103             frame_obj.customIdlPath = "/usr/local/include/custominterfaces/" 
     176        print "  => using default custom idl path instead" 
     177 
     178        # Attempt to use a default value 
     179        if os.path.isdir('/usr/include/custominterfaces'): 
     180            frame_obj.customIdlPath = '/usr/include/custominterfaces/' 
     181        elif os.path.isdir('/usr/local/include/custominterfaces'): 
     182            frame_obj.customIdlPath = '/usr/local/include/custominterfaces/' 
    104183        else: 
    105184            tmpstr = "CustomInterfaces does not appear to be installed!\n" 
     
    111190 
    112191    # ossie include path 
    113     try: 
    114         frame_obj.ossieIncludePath = \ 
    115                 str(doc_cfg.getElementsByTagName("ossieincludepath")[0].firstChild.data) 
    116     except: 
    117         frame_obj.ossieIncludePath = "" 
    118  
    119     if len(frame_obj.ossieIncludePath) > 0: 
    120         if frame_obj.ossieIncludePath[len(frame_obj.ossieIncludePath)-1] != '/': 
    121             frame_obj.ossieIncludePath = frame_obj.ossieIncludePath + '/' 
    122     else: 
    123         if os.path.isdir("/usr/include/ossie"): 
    124             frame_obj.ossieIncludePath = "/usr/include/ossie/" 
    125         elif os.path.isdir("/usr/local/include/ossie"): 
    126             frame_obj.ossieIncludePath = "/usr/local/include/ossie/" 
     192    frame_obj.ossieIncludePath = ensureDirHasTrailingSlash(ossieCfgValue('ossieincludepath')) 
     193    if frame_obj.ossieIncludePath == None or not os.path.isdir(frame_obj.ossieIncludePath): 
     194        if os.path.isdir('/usr/include/ossie'): 
     195            frame_obj.ossieIncludePath = '/usr/include/ossie/' 
     196        elif os.path.isdir('/usr/local/include/ossie'): 
     197            frame_obj.ossieIncludePath = '/usr/local/include/ossie/' 
    127198        else: 
    128199            tmpstr = "OSSIE does not appear to be installed!\n" 
     
    135206 
    136207    # home directory 
    137     try: 
    138         frame_obj.homeDir = str(doc_cfg.getElementsByTagName("homedir")[0].firstChild.data) 
    139     except: 
    140         frame_obj.homeDir = "" 
    141  
    142     if len(frame_obj.homeDir) > 0: 
    143         if frame_obj.homeDir[len(frame_obj.homeDir)-1] != '/': 
    144             frame_obj.homeDir = frame_obj.homeDir + '/' 
     208    frame_obj.homeDir = ensureDirHasTrailingSlash(ossieCfgValue('homedir')) 
    145209 
    146210    # generate source preamble 
    147     try: 
    148         frame_obj.sourcepreamble = \ 
    149                 str(doc_cfg.getElementsByTagName("sourcepreamble")[0].firstChild.data) 
    150     except: 
    151         frame_obj.sourcepreamble = root + '/generate/generic_preamble' 
     211    frame_obj.sourcepreamble = ossieCfgValue('sourcepreamble') 
     212    if frame_obj.sourcepreamble == None or not os.path.exists(frame_obj.sourcepreamble): 
     213        frame_obj.sourcepreamble = ossieInstallDir() + 'WaveDev/wavedev/generate/generic_preamble' 
    152214 
    153215    # generate license file 
    154     try: 
    155         frame_obj.licensefile = \ 
    156                 str(doc_cfg.getElementsByTagName("licensefile")[0].firstChild.data) 
    157     except: 
    158         frame_obj.licensefile = "" 
     216    frame_obj.licensefile = ossieCfgValue('licensefile') 
     217    if frame_obj.licensefile == None or not os.path.exists(frame_obj.licensefile): 
     218        frame_obj.licensefile = '' 
    159219 
    160220    # developer 
    161     try: 
    162         frame_obj.developer = \ 
    163                 str(doc_cfg.getElementsByTagName("developer")[0].firstChild.data) 
    164     except: 
     221    frame_obj.developer = ossieCfgValue('developer') 
     222    if frame_obj.developer == None or not os.path.exists(frame_obj.developer): 
    165223        frame_obj.developer = "your_name_or_organization" 
    166224 
     225 
     226##------------------------------------------------------------------------- 
     227## Internal 
     228##------------------------------------------------------------------------- 
     229 
     230def __relativeRoot(): 
     231    """ 
     232    Locate the OSSIE SDR root directory by looking relative to this file. 
     233    """ 
     234    root = __file__ 
     235    if os.path.islink(root): 
     236        root = os.path.realpath(root) 
     237    root = root + '../../..' 
     238    root = os.path.dirname(os.path.abspath(root)) 
     239    return root 
     240 
     241 
     242__overrides = {'installpath' : __relativeRoot() } 
     243__cachedXml = None 
     244__commentLine = None 
     245 
     246 
     247def __xml(): 
     248    global __cachedXml 
     249    if __cachedXml == None: 
     250        fileName = ossieInstallDir() + 'tools/WaveDev/wavedev.cfg' 
     251        if not os.path.exists(fileName): 
     252            # For OEF internals 
     253            fileName = ossieInstallDir() + 'WaveDev/wavedev.cfg' 
     254        if not os.path.exists(fileName): 
     255            fileName = '../wavedev.cfg' 
     256        if os.path.exists(fileName): 
     257            __cachedXml = xml.dom.minidom.parse(fileName) 
     258    return __cachedXml 
     259 
     260 
     261def __keyFromXml(key): 
     262    result = None 
     263    xml = __xml() 
     264    if xml != None: 
     265        try: 
     266            result = str(xml.getElementsByTagName(key)[0].firstChild.data) 
     267        except: 
     268            # ignore it--the config file is missing the given setting 
     269            pass 
     270    return result 
  • ossiedev/branches/0.7.x/tools/WaveDev/wavedev/generate/genNode.py

    r8729 r9384  
    2222from WaveDev.wavedev.errorMsg import * 
    2323from WaveDev.wavedev.cfg import LoadConfiguration 
     24from WaveDev.wavedev.chmod import chmod 
    2425from datetime import date 
    2526 
     
    4950 
    5051    shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.node.name) 
    51     os.chmod(self.path + self.node.name + '/reconf', 0755) 
     52    chmod(self.path + self.node.name + '/reconf', 0755) 
    5253 
    5354  ############################################################################## 
  • ossiedev/branches/0.7.x/tools/WaveDev/wavedev/generate/templates/basic_ports/genStructure.py

    r8729 r9384  
    2121import sys, os, shutil 
    2222from WaveDev.wavedev.cfg import LoadConfiguration 
     23from WaveDev.wavedev.chmod import chmod 
    2324from datetime import date 
    2425try: 
     
    5354 
    5455    shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.active_wave.name) 
    55     os.chmod(self.path + self.active_wave.name + '/reconf', '0755') 
     56    chmod(self.path + self.active_wave.name + '/reconf', '0755') 
    5657    for x in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    5758        if not os.path.isdir(x): 
     
    6465            if x.AssemblyController != True: 
    6566                shutil.copy(self.wavedevPath + 'generate/reconf',self.path + x.name) 
    66                 os.chmod(self.path + x.name + '/reconf', 0755) 
     67                chmod(self.path + x.name + '/reconf', 0755) 
    6768                for f in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    6869                    if not os.path.isdir(f): 
  • ossiedev/branches/0.7.x/tools/WaveDev/wavedev/generate/templates/custom_ports/genStructure.py

    r8729 r9384  
    2121import sys, os, shutil 
    2222from WaveDev.wavedev.cfg import LoadConfiguration 
     23from WaveDev.wavedev.chmod import chmod 
    2324from datetime import date 
    2425 
     
    5455 
    5556    shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.active_wave.name) 
    56     os.chmod(self.path + self.active_wave.name + '/reconf', 0755) 
     57    chmod(self.path + self.active_wave.name + '/reconf', 0755) 
    5758    #for x in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    5859    #    if not os.path.isdir(x): 
     
    6566            if x.AssemblyController != True: 
    6667                shutil.copy(self.wavedevPath + 'generate/reconf',self.path + x.name) 
    67                 os.chmod(self.path + x.name + '/reconf', 0755) 
     68                chmod(self.path + x.name + '/reconf', 0755) 
    6869                #for f in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    6970                #    if not os.path.isdir(f):