Changeset 454 in tmcsimulator for trunk/src/python/unifiedlogger


Ignore:
Timestamp:
07/18/2019 08:19:25 AM (7 years ago)
Author:
jdalbey
Message:

Logging Service: add missing file error check. Cad watcher modified to read log file path from config file.

Location:
trunk/src/python/unifiedlogger
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/python/unifiedlogger/cad_watcher.py

    r439 r454  
    1 import json, time 
     1import json, time, ConfigParser 
    22from copy import deepcopy 
    33 
     
    2020# Read the cad comments log  
    2121def readFile(): 
     22    # get path to input file from configuration 
     23    config = ConfigParser.ConfigParser() 
     24    config.read('config/logging_service.cfg') 
     25    logfilepath  = config.get('Paths', 'UnifiedLogPath') 
     26     
    2227    lines = [] 
    2328    try: 
    24         text_file = open("CADcomments.log", "r") 
     29        text_file = open(logfilepath + "CADcomments.log", "r") 
    2530    except IOError: 
    26         print "Error: missing CADcomments.log file." 
     31        print "Error: missing "+logfilepath+"CADcomments.log file." 
    2732    else: 
    2833        lines = text_file.read().split('\n') 
  • trunk/src/python/unifiedlogger/logging_service.py

    r439 r454  
    99    with open ("webapps/dynamicdata/sim_elapsedtime.json", 'r') as myfile: 
    1010        jsonData=myfile.read() 
    11           
    12     seconds = json.loads(jsonData)['elapsedtime'] 
     11    seconds = 0 
     12    try:      
     13       seconds = json.loads(jsonData)['elapsedtime'] 
     14    except: 
     15       print "Error loading json for elapsed time" 
    1316    # convert seconds to H:MM:SS 
    1417    m, s = divmod(int(seconds), 60) 
  • trunk/src/python/unifiedlogger/wing_project.wpr

    r452 r454  
    183183                       'toolbox-percent': 1.0, 
    184184                       'toolbox-tree-sel': ''})], 
    185         'primary_view_state': {'editor_states': ({'bookmarks': ([[loc('__main__.py'), 
    186         {'attrib-starts': [('main|0|', 
    187                             2)], 
    188          'code-line': '    print "revision ",get_app_properties.getRevision('\ 
    189                       ')\n', 
    190          'first-line': 0L, 
     185        'primary_view_state': {'editor_states': ({'bookmarks': ([[loc('logging_service.py'), 
     186        {'attrib-starts': [('startup|0|', 
     187                            17)], 
     188         'code-line': 'def startup():\n', 
     189         'first-line': 12L, 
    191190         'folded-linenos': [], 
    192          'sel-line': 4L, 
    193          'sel-line-start': 215L, 
    194          'selection_end': 269L, 
    195          'selection_start': 269L, 
     191         'sel-line': 17L, 
     192         'sel-line-start': 513L, 
     193         'selection_end': 527L, 
     194         'selection_start': 527L, 
    196195         'zoom': 0L}, 
    197         1563131297.40217], 
    198         [loc('logging_service.py'), 
    199          {'attrib-starts': [], 
    200           'code-line': 'import cms_watcher, cad_watcher, time, json, ConfigP'\ 
    201                        'arser\n', 
    202           'first-line': 0L, 
    203           'folded-linenos': [], 
    204           'sel-line': 0L, 
    205           'sel-line-start': 0L, 
    206           'selection_end': 57L, 
    207           'selection_start': 57L, 
    208           'zoom': 0L}, 
    209          1563131307.615114], 
    210         [loc('get_app_properties.py'), 
    211          {'attrib-starts': [('getRevision|0|', 
    212                              14)], 
    213           'code-line': 'def getRevision(lines):\n', 
    214           'first-line': 0L, 
    215           'folded-linenos': [], 
    216           'sel-line': 14L, 
    217           'sel-line-start': 382L, 
    218           'selection_end': 382L, 
    219           'selection_start': 382L, 
    220           'zoom': 0L}, 
    221          1563131330.855952], 
    222         [loc('__main__.py'), 
    223          {'attrib-starts': [('main|0|', 
    224                              2)], 
    225           'code-line': '    print "revision ",get_app_properties.getRevision'\ 
    226                        '()\n', 
    227           'first-line': 0L, 
    228           'folded-linenos': [], 
    229           'sel-line': 4L, 
    230           'sel-line-start': 215L, 
    231           'selection_end': 215L, 
    232           'selection_start': 215L, 
    233           'zoom': 0L}, 
    234          1563131341.340806], 
    235         [loc('get_app_properties.py'), 
    236          {'attrib-starts': [('getRevision|0|', 
    237                              14)], 
    238           'code-line': '    lines = getProperties()\n', 
    239           'first-line': 0L, 
    240           'folded-linenos': [], 
    241           'sel-line': 15L, 
    242           'sel-line-start': 401L, 
    243           'selection_end': 413L, 
    244           'selection_start': 413L, 
    245           'zoom': 0L}, 
    246          1563131376.535666], 
    247         [loc('__main__.py'), 
    248          {'attrib-starts': [('main|0|', 
    249                              2)], 
    250           'code-line': '    print "Unified Logging Service v"+revNum,"starti'\ 
    251                        'ng from ",os.getcwd()\n', 
    252           'first-line': 0L, 
    253           'folded-linenos': [], 
    254           'sel-line': 4L, 
    255           'sel-line-start': 198L, 
    256           'selection_end': 244L, 
    257           'selection_start': 244L, 
    258           'zoom': 0L}, 
    259          1563131462.025839], 
    260         [loc('get_app_properties.py'), 
    261          {'attrib-starts': [], 
    262           'code-line': '\n', 
    263           'first-line': 0L, 
    264           'folded-linenos': [], 
    265           'sel-line': 0L, 
    266           'sel-line-start': 0L, 
    267           'selection_end': 0L, 
    268           'selection_start': 0L, 
    269           'zoom': 0L}, 
    270          1563131503.437265], 
    271         [loc('__main__.py'), 
    272          {'attrib-starts': [('main|0|', 
    273                              2)], 
    274           'code-line': '    print "Unified Logging Service v"+revNum,"starti'\ 
    275                        'ng from ",os.getcwd()\n', 
    276           'first-line': 0L, 
    277           'folded-linenos': [], 
    278           'sel-line': 4L, 
    279           'sel-line-start': 198L, 
    280           'selection_end': 244L, 
    281           'selection_start': 244L, 
    282           'zoom': 0L}, 
    283          1563231920.207662], 
    284         [loc('get_app_properties.py'), 
    285          {'attrib-starts': [('getProperties|0|', 
    286                              3)], 
    287           'code-line': '        print "Error: missing src/tmcsim/application'\ 
    288                        '.properties file."\n', 
    289           'first-line': 0L, 
    290           'folded-linenos': [], 
    291           'sel-line': 8L, 
    292           'sel-line-start': 173L, 
    293           'selection_end': 213L, 
    294           'selection_start': 213L, 
    295           'zoom': 0L}, 
    296          1563232029.32642], 
    297         [loc('logging_service.py'), 
    298          {'attrib-starts': [('startup|0|', 
    299                              17)], 
    300           'code-line': '    # get path to output file from configuration\n', 
    301           'first-line': 9L, 
    302           'folded-linenos': [], 
    303           'sel-line': 18L, 
    304           'sel-line-start': 528L, 
    305           'selection_end': 721L, 
    306           'selection_start': 528L, 
    307           'zoom': 0L}, 
    308          1563232797.935308], 
    309         [loc('__main__.py'), 
    310          {'attrib-starts': [('main|0|', 
    311                              2)], 
    312           'code-line': '    \n', 
    313           'first-line': 0L, 
    314           'folded-linenos': [], 
    315           'sel-line': 7L, 
    316           'sel-line-start': 340L, 
    317           'selection_end': 344L, 
    318           'selection_start': 344L, 
    319           'zoom': 0L}, 
    320          1563232895.220896], 
    321         [loc('get_app_properties.py'), 
    322          {'attrib-starts': [], 
    323           'code-line': '# Obsolete - moved to config file instead.\n', 
    324           'first-line': 0L, 
    325           'folded-linenos': [], 
    326           'sel-line': 0L, 
    327           'sel-line-start': 0L, 
    328           'selection_end': 42L, 
    329           'selection_start': 42L, 
    330           'zoom': 0L}, 
    331          1563232919.766056], 
    332         [loc('__main__.py'), 
    333          {'attrib-starts': [('main|0|', 
    334                              2)], 
    335           'code-line': "    config.read('config/application_properties.cf')"\ 
    336                        "\n", 
    337           'first-line': 0L, 
    338           'folded-linenos': [], 
    339           'sel-line': 5L, 
    340           'sel-line-start': 232L, 
    341           'selection_end': 281L, 
    342           'selection_start': 281L, 
    343           'zoom': 0L}, 
    344          1563294795.82432], 
    345         [loc('../../../../../../../../usr/lib/python2.7/ConfigParser.py'), 
    346          {'attrib-starts': [('ConfigParser|0|', 
    347                              85), 
    348                             ('ConfigParser|0|.get|0|', 
    349                              589)], 
    350           'code-line': '                raise NoSectionError(section)\n', 
    351           'first-line': 601L, 
    352           'folded-linenos': [], 
    353           'sel-line': 606L, 
    354           'sel-line-start': 22028L, 
    355           'selection_end': 22028L, 
    356           'selection_start': 22028L, 
    357           'zoom': 0L}, 
    358          1563294818.055248], 
    359         [loc('__main__.py'), 
    360          {'attrib-starts': [('main|0|', 
    361                              2)], 
    362           'code-line': '    except:  # If config file not found, use a quest'\ 
    363                        'ion mark placeholder \n', 
    364           'first-line': 0L, 
    365           'folded-linenos': [], 
    366           'sel-line': 8L, 
    367           'sel-line-start': 356L, 
    368           'selection_end': 417L, 
    369           'selection_start': 417L, 
    370           'zoom': 0L}, 
    371          1563294949.099012], 
    372         [loc('logging_service.py'), 
    373          {'attrib-starts': [('startup|0|', 
    374                              17)], 
    375           'code-line': 'def startup():\n', 
    376           'first-line': 12L, 
    377           'folded-linenos': [], 
    378           'sel-line': 17L, 
    379           'sel-line-start': 513L, 
    380           'selection_end': 527L, 
    381           'selection_start': 527L, 
    382           'zoom': 0L}, 
    383          1563295110.747974], 
     196        1563295110.747974], 
    384197        [loc('get_app_properties.py'), 
    385198         {'attrib-starts': [], 
     
    430243          'selection_start': 527L, 
    431244          'zoom': 0L}, 
    432          1563295126.806403]], 
     245         1563295126.806403], 
     246        [loc('__main__.py'), 
     247         {'attrib-starts': [('main|0|', 
     248                             2)], 
     249          'code-line': '    except:  # If config file not found, use a quest'\ 
     250                       'ion mark placeholder \n', 
     251          'first-line': 0L, 
     252          'folded-linenos': [], 
     253          'sel-line': 8L, 
     254          'sel-line-start': 356L, 
     255          'selection_end': 417L, 
     256          'selection_start': 417L, 
     257          'zoom': 0L}, 
     258         1563298825.820571], 
     259        [loc('cad_watcher.py'), 
     260         {'attrib-starts': [('readFile|0|', 
     261                             20)], 
     262          'code-line': 'def readFile():\n', 
     263          'first-line': 15L, 
     264          'folded-linenos': [], 
     265          'sel-line': 20L, 
     266          'sel-line-start': 575L, 
     267          'selection_end': 590L, 
     268          'selection_start': 590L, 
     269          'zoom': 0L}, 
     270         1563298863.068667], 
     271        [loc('logging_service.py'), 
     272         {'attrib-starts': [('startup|0|', 
     273                             17)], 
     274          'code-line': 'def startup():\n', 
     275          'first-line': 12L, 
     276          'folded-linenos': [], 
     277          'sel-line': 17L, 
     278          'sel-line-start': 513L, 
     279          'selection_end': 527L, 
     280          'selection_start': 527L, 
     281          'zoom': 0L}, 
     282         1563298890.003056], 
     283        [loc('../../../config/logging_service.cfg'), 
     284         {'attrib-starts': [], 
     285          'code-line': '[Paths]\n', 
     286          'first-line': 0L, 
     287          'folded-linenos': [], 
     288          'sel-line': 0L, 
     289          'sel-line-start': 0L, 
     290          'selection_end': 0L, 
     291          'selection_start': 0L, 
     292          'zoom': 0L}, 
     293         1563298905.850272], 
     294        [loc('logging_service.py'), 
     295         {'attrib-starts': [('startup|0|', 
     296                             17)], 
     297          'code-line': '    # get path to output file from configuration\n', 
     298          'first-line': 12L, 
     299          'folded-linenos': [], 
     300          'sel-line': 18L, 
     301          'sel-line-start': 528L, 
     302          'selection_end': 720L, 
     303          'selection_start': 528L, 
     304          'zoom': 0L}, 
     305         1563298925.9103], 
     306        [loc('cad_watcher.py'), 
     307         {'attrib-starts': [('readFile|0|', 
     308                             20)], 
     309          'code-line': '        text_file = open(logfilepath + "CADcomments.'\ 
     310                       'log", "r")\n', 
     311          'first-line': 12L, 
     312          'folded-linenos': [], 
     313          'sel-line': 28L, 
     314          'sel-line-start': 813L, 
     315          'selection_end': 852L, 
     316          'selection_start': 852L, 
     317          'zoom': 0L}, 
     318         1563298944.867817], 
     319        [loc('logging_service.py'), 
     320         {'attrib-starts': [('startup|0|', 
     321                             17)], 
     322          'code-line': '    # get path to output file from configuration\n', 
     323          'first-line': 12L, 
     324          'folded-linenos': [], 
     325          'sel-line': 18L, 
     326          'sel-line-start': 528L, 
     327          'selection_end': 720L, 
     328          'selection_start': 528L, 
     329          'zoom': 0L}, 
     330         1563298961.49365], 
     331        [loc('../../../config/logging_service.cfg'), 
     332         {'attrib-starts': [], 
     333          'code-line': '[Paths]\n', 
     334          'first-line': 0L, 
     335          'folded-linenos': [], 
     336          'sel-line': 0L, 
     337          'sel-line-start': 0L, 
     338          'selection_end': 0L, 
     339          'selection_start': 0L, 
     340          'zoom': 0L}, 
     341         1563298965.173624], 
     342        [loc('cad_watcher.py'), 
     343         {'attrib-starts': [('readFile|0|', 
     344                             20)], 
     345          'code-line': '    config = ConfigParser.ConfigParser()\n', 
     346          'first-line': 0L, 
     347          'folded-linenos': [], 
     348          'sel-line': 22L, 
     349          'sel-line-start': 640L, 
     350          'selection_end': 640L, 
     351          'selection_start': 640L, 
     352          'zoom': 0L}, 
     353         1563299005.834573], 
     354        [loc('__main__.py'), 
     355         {'attrib-starts': [], 
     356          'code-line': 'import logging_service, os, ConfigParser\n', 
     357          'first-line': 0L, 
     358          'folded-linenos': [], 
     359          'sel-line': 0L, 
     360          'sel-line-start': 0L, 
     361          'selection_end': 40L, 
     362          'selection_start': 28L, 
     363          'zoom': 0L}, 
     364         1563299012.548244], 
     365        [loc('cad_watcher.py'), 
     366         {'attrib-starts': [('readFile|0|', 
     367                             20)], 
     368          'code-line': '    # get path to input file from configuration\n', 
     369          'first-line': 18L, 
     370          'folded-linenos': [], 
     371          'sel-line': 21L, 
     372          'sel-line-start': 605L, 
     373          'selection_end': 628L, 
     374          'selection_start': 628L, 
     375          'zoom': 0L}, 
     376         1563311309.128491], 
     377        [loc('logging_service.py'), 
     378         {'attrib-starts': [('getSimTime|0|', 
     379                             7)], 
     380          'code-line': '    h, m = divmod(m, 60)\n', 
     381          'first-line': 3L, 
     382          'folded-linenos': [], 
     383          'sel-line': 14L, 
     384          'sel-line-start': 444L, 
     385          'selection_end': 468L, 
     386          'selection_start': 468L, 
     387          'zoom': 0L}, 
     388         1563311363.078389], 
     389        [loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
     390         {'attrib-starts': [('JSONDecoder|0|', 
     391                             271), 
     392                            ('JSONDecoder|0|.raw_decode|0|', 
     393                             369)], 
     394          'code-line': '            obj, end = self.scan_once(s, idx)\n', 
     395          'first-line': 370L, 
     396          'folded-linenos': [], 
     397          'sel-line': 379L, 
     398          'sel-line-start': 13534L, 
     399          'selection_end': 13534L, 
     400          'selection_start': 13534L, 
     401          'zoom': 0L}, 
     402         1563311407.328163], 
     403        [loc('logging_service.py'), 
     404         {'attrib-starts': [('getSimTime|0|', 
     405                             7)], 
     406          'code-line': '    h, m = divmod(m, 60)\n', 
     407          'first-line': 6L, 
     408          'folded-linenos': [], 
     409          'sel-line': 14L, 
     410          'sel-line-start': 444L, 
     411          'selection_end': 468L, 
     412          'selection_start': 468L, 
     413          'zoom': 0L}, 
     414         1563311428.009251], 
     415        [loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
     416         {'attrib-starts': [('JSONDecoder|0|', 
     417                             271), 
     418                            ('JSONDecoder|0|.raw_decode|0|', 
     419                             369)], 
     420          'code-line': '            obj, end = self.scan_once(s, idx)\n', 
     421          'first-line': 370L, 
     422          'folded-linenos': [], 
     423          'sel-line': 379L, 
     424          'sel-line-start': 13534L, 
     425          'selection_end': 13534L, 
     426          'selection_start': 13534L, 
     427          'zoom': 0L}, 
     428         1563311437.82119]], 
    433429        20), 
    434         'current-loc': loc('__main__.py'), 
     430        'current-loc': loc('logging_service.py'), 
    435431        'editor-state-list': [(loc('cad_watcher.py'), 
    436                                {'attrib-starts': [], 
    437                                 'code-line': '# Read the cad comments log \n', 
    438                                 'first-line': 15L, 
     432                               {'attrib-starts': [('readFile|0|', 
     433        20)], 
     434                                'code-line': '    # get path to input file f'\ 
     435        'rom configuration\n', 
     436                                'first-line': 18L, 
    439437                                'folded-linenos': [], 
    440                                 'sel-line': 19L, 
    441                                 'sel-line-start': 546L, 
    442                                 'selection_end': 838L, 
    443                                 'selection_start': 546L, 
     438                                'sel-line': 21L, 
     439                                'sel-line-start': 605L, 
     440                                'selection_end': 628L, 
     441                                'selection_start': 628L, 
    444442                                'zoom': 0L}), 
    445443                              (loc('cms_watcher.py'), 
     
    455453                                'selection_start': 353L, 
    456454                                'zoom': 0L}), 
     455                              (loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
     456                               {'attrib-starts': [('JSONDecoder|0|', 
     457        271), 
     458        ('JSONDecoder|0|.raw_decode|0|', 
     459         369)], 
     460                                'code-line': '            obj, end = self.sc'\ 
     461        'an_once(s, idx)\n', 
     462                                'first-line': 370L, 
     463                                'folded-linenos': [], 
     464                                'sel-line': 379L, 
     465                                'sel-line-start': 13534L, 
     466                                'selection_end': 13534L, 
     467                                'selection_start': 13534L, 
     468                                'zoom': 0L}), 
     469                              (loc('../../../config/logging_service.cfg'), 
     470                               {'attrib-starts': [], 
     471                                'code-line': '[Paths]\n', 
     472                                'first-line': 0L, 
     473                                'folded-linenos': [], 
     474                                'sel-line': 0L, 
     475                                'sel-line-start': 0L, 
     476                                'selection_end': 0L, 
     477                                'selection_start': 0L, 
     478                                'zoom': 0L}), 
    457479                              (loc('logging_service.py'), 
    458                                {'attrib-starts': [('startup|0|', 
    459         17)], 
    460                                 'code-line': 'def startup():\n', 
    461                                 'first-line': 12L, 
     480                               {'attrib-starts': [('getSimTime|0|', 
     481        7)], 
     482                                'code-line': '       print "Error loading js'\ 
     483        'on for elapsed time"\n', 
     484                                'first-line': 0L, 
    462485                                'folded-linenos': [], 
    463                                 'sel-line': 17L, 
    464                                 'sel-line-start': 513L, 
    465                                 'selection_end': 527L, 
    466                                 'selection_start': 527L, 
     486                                'sel-line': 14L, 
     487                                'sel-line-start': 410L, 
     488                                'selection_end': 460L, 
     489                                'selection_start': 460L, 
    467490                                'zoom': 0L}), 
    468491                              (loc('__main__.py'), 
    469                                {'attrib-starts': [('main|0|', 
    470         2)], 
    471                                 'code-line': '    except:  # If config file '\ 
    472         'not found, use a question mark placeholder \n', 
     492                               {'attrib-starts': [], 
     493                                'code-line': 'import logging_service, os, Co'\ 
     494        'nfigParser\n', 
    473495                                'first-line': 0L, 
    474496                                'folded-linenos': [], 
    475                                 'sel-line': 8L, 
    476                                 'sel-line-start': 356L, 
    477                                 'selection_end': 417L, 
    478                                 'selection_start': 417L, 
     497                                'sel-line': 0L, 
     498                                'sel-line-start': 0L, 
     499                                'selection_end': 40L, 
     500                                'selection_start': 28L, 
    479501                                'zoom': 0L})], 
    480502        'has-focus': True, 
     
    482504        [loc('cad_watcher.py'), 
    483505         loc('cms_watcher.py'), 
     506         loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
     507         loc('../../../config/logging_service.cfg'), 
    484508         loc('logging_service.py'), 
    485509         loc('__main__.py')]), 
    486                                'open_files': [u'cad_watcher.py', 
     510                               'open_files': [u'../../../config/logging_service.cfg', 
     511        u'__main__.py', 
    487512        u'cms_watcher.py', 
    488         u'logging_service.py', 
    489         u'__main__.py']}, 
     513        u'cad_watcher.py', 
     514        u'logging_service.py']}, 
    490515        'saved_notebook_display': None, 
    491516        'split_percents': {0: 0.5}, 
     
    494519        'traversal_pos': ((0, 
    495520                           3), 
    496                           1563294795.772892), 
     521                          1563311427.998152), 
    497522        'user_data': {}}, 
    498523                 'saved_notebook_display': None, 
     
    502527                 'traversal_pos': ((0, 
    503528                                    4), 
    504                                    1563295152.502479), 
     529                                   1563311544.529663), 
    505530                 'user_data': {}}, 
    506531        'window-alloc': (29, 
     
    508533                         1197, 
    509534                         722)}]} 
    510 guimgr.recent-documents = [loc('__main__.py'), 
    511                            loc('logging_service.py'), 
     535guimgr.recent-documents = [loc('logging_service.py'), 
     536                           loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
    512537                           loc('cad_watcher.py'), 
     538                           loc('__main__.py'), 
     539                           loc('../../../config/logging_service.cfg'), 
    513540                           loc('cms_watcher.py')] 
    514541guimgr.visual-state = {loc('get_app_properties.py'): {'attrib-starts': [], 
Note: See TracChangeset for help on using the changeset viewer.