Exemplo n.º 1
0
def remove_caches():
    # Remove .pyc files
    deleted = 0
    for root, dirs, files in os.walk('.'):
        if "{arch}" in root or "_darcs" in root:
            continue  # stupid blah
        for afile in files:
            pathname = os.path.join(root, afile)
            if pathname.endswith('.pyc'):
                deleted += 1
                os.unlink(pathname)
    if deleted:
        print "Deleted .pyc files (%d total)" % (deleted)

    cache_dir = helper.get_magpie_dir('cache_dir', None)
    template_dir = helper.get_magpie_dir('template_cache_dir', None)
    cache_files_deleted = 0
    for some_dir in (cache_dir, template_dir):
        if os.path.exists(some_dir):
            for dir_path, dir_names, file_names in os.walk(some_dir,
                                                           topdown=False):
                for file_name in file_names:
                    path_name = os.path.join(dir_path, file_name)
                    os.remove(path_name)
                    cache_files_deleted += 1
    print "Deleted cache files (%d total)" % (cache_files_deleted)
Exemplo n.º 2
0
Arquivo: test.py Projeto: BruceYi/okl4
def remove_caches():
	# Remove .pyc files
	deleted = 0
	for root, dirs, files in os.walk('.'):
		if "{arch}" in root or "_darcs" in root:
			continue # stupid blah
		for afile in files:
			pathname = os.path.join(root, afile)
			if pathname.endswith('.pyc'):
				deleted += 1
				os.unlink(pathname)
	if deleted:
		print "Deleted .pyc files (%d total)" % (deleted)
	
	cache_dir = helper.get_magpie_dir('cache_dir', None)
	template_dir = helper.get_magpie_dir('template_cache_dir', None)
	cache_files_deleted = 0
	for some_dir in (cache_dir, template_dir):
		if os.path.exists(some_dir):
			for dir_path, dir_names, file_names in os.walk(some_dir, topdown = False):
				for file_name in file_names:
					path_name = os.path.join(dir_path, file_name)
					os.remove(path_name)
					cache_files_deleted += 1
	print "Deleted cache files (%d total)" % (cache_files_deleted)
Exemplo n.º 3
0
	def _initialise(self):
		if options['cache_enabled'] and not self.initialised:
			self.cache_dir = helper.get_magpie_dir('cache_dir', options)
			self._setup_files()
			self._load_directory()
			self.initialised = True
Exemplo n.º 4
0
 def _initialise(self):
     if options['cache_enabled'] and not self.initialised:
         self.cache_dir = helper.get_magpie_dir('cache_dir', options)
         self._setup_files()
         self._load_directory()
         self.initialised = True