Example #1
0
File: event.py Project: bernt/pymt
 def lambda_connect(*largs):
     if type(p2) in (tuple, list):
         if len(largs) != len(p2):
             pymt_logger.exception('Widget: cannot connect with different size')
             raise
         for p in p2:
             if p is None:
                 continue
             w2.__setattr__(p, type(w2.__getattribute__(p))(
                 func(largs[p2.index(p)])))
     else:
         dtype = type(w2.__getattribute__(p2))
         try:
             if len(largs) == 1:
                 w2.__setattr__(p2, dtype(func(*largs)))
             else:
                 w2.__setattr__(p2, dtype(func(largs)))
         except Exception, e:
             pymt_logger.exception('Widget: cannot connect with different size')
             raise
Example #2
0
File: __init__.py Project: imc/pymt
    'svg': ('squirtle',),
}

# Read environment
for option in options:
    key = 'PYMT_%s' % option.upper()
    if key in os.environ:
        try:
            if type(options[option]) in (list, tuple):
                options[option] = (str(os.environ[key]),)
            else:
                options[option] = os.environ[key].lower() in \
                    ('true', '1', 'yes', 'yup')
        except:
            pymt_logger.warning('Core: Wrong value for %s environment key' % key)
            pymt_logger.exception('')

# Extract all needed path in pymt
#: PyMT directory
pymt_base_dir        = os.path.dirname(sys.modules[__name__].__file__)
#: PyMT external libraries directory
pymt_libs_dir        = os.path.join(pymt_base_dir, 'lib')
#: PyMT modules directory
pymt_modules_dir     = os.path.join(pymt_base_dir, 'modules')
#: PyMT data directory
pymt_data_dir        = os.path.join(pymt_base_dir, 'data')
#: PyMT input provider directory
pymt_providers_dir   = os.path.join(pymt_base_dir, 'input', 'providers')
#: PyMT user-home storage directory
pymt_home_dir        = None
#: PyMT configuration filename
Example #3
0
            return self.getint(section, option)
        def adddefaultsection(self, section):
            if self.has_section(section):
                return
            self.add_section(section)


    # Create default configuration
    pymt_config = PyMTConfigParser()

    # Read config file if exist
    if os.path.exists(pymt_config_fn):
        try:
            pymt_config.read(pymt_config_fn)
        except Exception, e:
            pymt_logger.exception('Core: error while reading local configuration')

    pymt_config_version = pymt_config.getdefault('pymt', 'config_version', 0)

# Add defaults section
    pymt_config.adddefaultsection('pymt')
    pymt_config.adddefaultsection('keyboard')
    pymt_config.adddefaultsection('graphics')
    pymt_config.adddefaultsection('input')
    pymt_config.adddefaultsection('dump')
    pymt_config.adddefaultsection('modules')

# Upgrade default configuration until having the current version
    need_save = False
    if pymt_config_version != PYMT_CONFIG_VERSION:
        pymt_logger.warning('Config: Older configuration version detected (%d instead of %d)' % (