Package nMOLDYN |
[hide private]
[frames] | no frames]

# Source Code for Package nMOLDYN

     1  #
     2  # Package information
     3  #
     4  from __pkginfo__ import __version__
     5
     6  # Add shared library path to sys.path
     7  import logging
     8  import os
     9  import sys
    10  from time import strftime
    11  sys.path.append(os.path.join(os.path.split(__file__)[0], sys.platform))
    12
    13  # The nMOLDYN Atoms Database is defined as the default database to search in.
    14  from MMTK import Database
    15
    16  from nMOLDYN.Core.Config import loadConfigurationFile
    17  from nMOLDYN.Core.Logger import CONSOLE_LOGGER, FILE_LOGGER, GUI_LOGGER, LogToConsole, LogToFile, LogToGUI
    18  from nMOLDYN.Core.Preferences import PREFERENCES
    19
    20  # Package path
    21  nmoldyn_package_path = os.path.split(__file__)[0]
    22
    23  # The nMOLDYN internal atom database will be the efault one.
    24  Database.path.insert(0, os.path.join(nmoldyn_package_path, 'Database'))
    25
    26  # The user configuration file is read.
    27  loadConfigurationFile()
    28
    29  # if the external programs path are not set, nMOLDYN tries to find them in classical locations.
    30  for p in ['vmd','ncdump','ncgen','acroread']:
    31      if not os.path.isfile(getattr(PREFERENCES,p+'_path')):
    32          from nMOLDYN.Core.Misc import findExecutable
    33          if (p == 'acroread') and (sys.platform == 'win32'):
    34              exe = 'AcroRd32'
    35          else:
    36              exe = p
    37          setattr(PREFERENCES,p+'_path', findExecutable(exe))
    38
    39  # The file handler is created and provided to the file logger.
    40  fileHandler = LogToFile(os.path.join(PREFERENCES.logfile_path,'nMOLDYN_%s.log' % strftime('%a%d%b%Y_%Hh%Mm%Ss')))
    41  FILE_LOGGER.addHandler(fileHandler)
    42
    43  # The console handler is created and provided to the console logger.
    44  consoleHandler = LogToConsole()
    45  CONSOLE_LOGGER.addHandler(consoleHandler)
    46
    47  # The console handler is created and provided to the console logger.
    48  dialogHandler = LogToGUI()
    49  GUI_LOGGER.addHandler(dialogHandler)
    50
    51  del os
    52  del sys
    53