Пример #1
0
	def __init__(self):
		user_store = os.path.join(basedir.xdg_cache_home, '0install.net', 'implementations')
		self.stores = [Store(user_store)]

		impl_dirs_files = list(basedir.load_config_paths('0install.net', 'injector',
							  'implementation-dirs'))
		if impl_dirs_files:
			dirs = []
			for impl_dirs in impl_dirs_files:
				debug(_("Location of 'implementation-dirs' config file being used: '%s'"), impl_dirs)
				dirs.extend(file(impl_dirs))
		else:
			if os.name == "nt":
				from win32com.shell import shell, shellcon
				localAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, 0, 0)
				commonAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)

				userCache = os.path.join(localAppData, "0install.net", "implementations")
				sharedCache = os.path.join(commonAppData, "0install.net", "implementations")
				dirs = [userCache, sharedCache]

			else:
				dirs = ['/var/cache/0install.net/implementations']

		for directory in dirs:
			directory = directory.strip()
			if directory and not directory.startswith('#'):
				debug(_("Added system store '%s'"), directory)
				self.stores.append(Store(directory))
Пример #2
0
	def __init__(self):
		# Always add the user cache to have a reliable fallback location for storage
		user_store = os.path.join(basedir.xdg_cache_home, '0install.net', 'implementations')
		self.stores = [Store(user_store)]

		# Add custom cache locations
		dirs = []
		for impl_dirs in basedir.load_config_paths('0install.net', 'injector', 'implementation-dirs'):
			with open(impl_dirs, 'rt') as stream:
				dirs.extend(stream.readlines())
		for directory in dirs:
			directory = directory.strip()
			if directory and not directory.startswith('#'):
				logger.debug(_("Added system store '%s'"), directory)
				self.stores.append(Store(directory))

		# Add the system cache when not in portable mode
		if not os.environ.get('ZEROINSTALL_PORTABLE_BASE'):
			if os.name == "nt":
				from win32com.shell import shell, shellcon
				commonAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
				systemCachePath = os.path.join(commonAppData, "0install.net", "implementations")
				# Only use shared cache location on Windows if it was explicitly created
				if os.path.isdir(systemCachePath):
					self.stores.append(Store(systemCachePath))
			else:
				self.stores.append(Store('/var/cache/0install.net/implementations'))
Пример #3
0
    def __init__(self):
        # Always add the user cache to have a reliable fallback location for storage
        user_store = os.path.join(basedir.xdg_cache_home, '0install.net',
                                  'implementations')
        self.stores = [Store(user_store)]

        # Add custom cache locations
        dirs = []
        for impl_dirs in basedir.load_config_paths('0install.net', 'injector',
                                                   'implementation-dirs'):
            with open(impl_dirs, 'rt') as stream:
                dirs.extend(stream.readlines())
        for directory in dirs:
            directory = directory.strip()
            if directory and not directory.startswith('#'):
                logger.debug(_("Added system store '%s'"), directory)
                self.stores.append(Store(directory))

        # Add the system cache when not in portable mode
        if not os.environ.get('ZEROINSTALL_PORTABLE_BASE'):
            if os.name == "nt":
                from win32com.shell import shell, shellcon
                commonAppData = shell.SHGetFolderPath(
                    0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
                systemCachePath = os.path.join(commonAppData, "0install.net",
                                               "implementations")
                # Only use shared cache location on Windows if it was explicitly created
                if os.path.isdir(systemCachePath):
                    self.stores.append(Store(systemCachePath))
            else:
                self.stores.append(
                    Store('/var/cache/0install.net/implementations'))
Пример #4
0
	def iterate_apps(self):
		seen = set()
		for apps_dir in basedir.load_config_paths(namespaces.config_site, "apps"):
			for name in os.listdir(apps_dir):
				if valid_name.match(name):
					if name in seen: continue
					seen.add(name)
					yield name
Пример #5
0
 def iterate_apps(self):
     seen = set()
     for apps_dir in basedir.load_config_paths(namespaces.config_site,
                                               "apps"):
         for name in os.listdir(apps_dir):
             if valid_name.match(name):
                 if name in seen: continue
                 seen.add(name)
                 yield name
Пример #6
0
	def list_all_interfaces(self):
		"""List all interfaces in the cache.
		@rtype: [str]
		"""
		all = set()
		for d in basedir.load_cache_paths(config_site, 'interfaces'):
			for leaf in os.listdir(d):
				if not leaf.startswith('.'):
					all.add(unescape(leaf))
		for d in basedir.load_config_paths(config_site, config_prog, 'user_overrides'):
			for leaf in os.listdir(d):
				if not leaf.startswith('.'):
					all.add(unescape(leaf))
		return list(all)	# Why not just return the set?
Пример #7
0
    def list_all_interfaces(self):
        """List all interfaces in the cache.
		@rtype: [str]
		"""
        all = set()
        for d in basedir.load_cache_paths(config_site, 'interfaces'):
            for leaf in os.listdir(d):
                if not leaf.startswith('.'):
                    all.add(unescape(leaf))
        for d in basedir.load_config_paths(config_site, config_prog,
                                           'user_overrides'):
            for leaf in os.listdir(d):
                if not leaf.startswith('.'):
                    all.add(unescape(leaf))
        return list(all)  # Why not just return the set?
Пример #8
0
    def __init__(self):
        user_store = os.path.join(basedir.xdg_cache_home, '0install.net',
                                  'implementations')
        self.stores = [Store(user_store)]

        impl_dirs_files = list(
            basedir.load_config_paths('0install.net', 'injector',
                                      'implementation-dirs'))
        if impl_dirs_files:
            dirs = []
            for impl_dirs in impl_dirs_files:
                debug(
                    _("Location of 'implementation-dirs' config file being used: '%s'"
                      ), impl_dirs)
                dirs.extend(file(impl_dirs))
        else:
            if os.name == "nt":
                from win32com.shell import shell, shellcon
                localAppData = shell.SHGetFolderPath(
                    0, shellcon.CSIDL_LOCAL_APPDATA, 0, 0)
                commonAppData = shell.SHGetFolderPath(
                    0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)

                userCache = os.path.join(localAppData, "0install.net",
                                         "implementations")
                sharedCache = os.path.join(commonAppData, "0install.net",
                                           "implementations")
                dirs = [userCache, sharedCache]

            else:
                dirs = ['/var/cache/0install.net/implementations']

        for directory in dirs:
            directory = directory.strip()
            if directory and not directory.startswith('#'):
                debug(_("Added system store '%s'"), directory)
                self.stores.append(Store(directory))