def _run_load(self): while len(self.loadlist): name, objs = self.loadlist.popitem() try: fd = urllib.urlopen(name) if fd.getcode() < 200 or fd.getcode() >= 300: pymt_logger.error('unable to load image %s (errorcode=%d)' % \ (name, fd.getcode())) fd.close() continue # Special case for gdk loader # We experienced random crash while using pyglet.image.load # in gdk_pixbuf_loader_write(). # Since we don't known what pyglet will use to load image # we lock the loading each time try: gtk.gdk.threads_enter() except: pass # Load image try: self.cache[name] = pyglet.image.load(name, file=fd) except Exception, e: pymt_logger.error('unable to load image %s : %s' % (name, e)) try: gtk.gdk.threads_leave() except: pass # Close fd fd.close() # Notify object for new data for obj in objs: self.updatelist.append(obj) except Exception, e: pymt_logger.error('unable to load image %s : %s' % (name, e))
if len(args) == 1: args += [''] pymt_config.set('modules', args[0], args[1]) elif opt in ('-s', '--save'): need_save = True elif opt in ('-n', ): options['shadow_window'] = False if need_save: try: with open(pymt_config_fn, 'w') as fd: pymt_config.write(fd) except Exception, e: pymt_logger.exception('Core: error while saving default configuration file') pymt_logger.info('Core: PyMT configuration saved.') sys.exit(0) # last initialization if options['shadow_window']: pymt_logger.debug('Core: Creating PyMT Window') shadow_window = MTWindow() pymt_configure() except getopt.GetoptError, err: pymt_logger.error('Core: %s' % str(err)) pymt_usage() sys.exit(2) # cleanup namespace del sys, getopt, os
pymt_config.set('graphics', 'width', w) pymt_config.set('graphics', 'height', h) elif opt in ['--display']: pymt_config.set('graphics', 'display', str(arg)) elif opt in ['-m', '--module']: if str(arg) == 'list': pymt_modules.usage_list() sys.exit(0) pymt_config.set('modules', str(arg), '') elif opt in ['-s', '--save']: need_save = True if need_save: try: with open(pymt_config_fn, 'w') as fd: pymt_config.write(fd) except Exception, e: pymt_logger.exception('error while saving default configuration file') pymt_logger.info('PyMT configuration saved.') sys.exit(0) # last initialization if options['shadow_window']: pymt_logger.debug('Creating PyMT Window') shadow_window = MTWindow() except getopt.GetoptError, err: pymt_logger.error(err) pymt_usage() sys.exit(2)