Python clear cache
60 Python code examples are found related to "
clear cache".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: dispatcher.py From training_results_v0.6 with Apache License 2.0 | 7 votes |
def clear_fallback_cache(target, workload): """Clear fallback cache. Pass the same argument as _query_inside to this function to clean the cache. Parameters ---------- target: Target The current target workload : Workload The current workload. Note ---- This is used in alter_op_layout to clear the bad cache created before call topi compute function """ context = DispatchContext.current while not isinstance(context, FallbackContext): context = context._old_ctx context.clear_cache(target, workload)
Example 2
Source File: support.py From plugin.program.indigo with GNU General Public License v3.0 | 7 votes |
def clear_cache(): kodi.log('STARTUP CLEAR CACHE ACTIVATED') xbmc_cache_path = os.path.join(xbmc.translatePath('special://home'), 'cache') if os.path.exists(xbmc_cache_path) == True: for root, dirs, files in os.walk(xbmc_cache_path): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: os.unlink(os.path.join(root, f)) except: pass for d in dirs: if 'archive_cache' not in d: try: shutil.rmtree(os.path.join(root, d)) except: pass kodi.log('Startup Service could not clear cache')
Example 3
Source File: workflow3.py From wechat-alfred-workflow with MIT License | 6 votes |
def clear_session_cache(self, current=False): """Remove session data from the cache. .. versionadded:: 1.25 .. versionchanged:: 1.27 By default, data belonging to the current session won't be deleted. Set ``current=True`` to also clear current session. Args: current (bool, optional): If ``True``, also remove data for current session. """ def _is_session_file(filename): if current: return filename.startswith('_wfsess-') return filename.startswith('_wfsess-') \ and not filename.startswith(self._session_prefix) self.clear_cache(_is_session_file)
Example 4
Source File: trust_list.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
def clear_cache(temp_dir=None): """ Clears any cached info that was exported from the OS trust store. This will ensure the latest changes are returned from calls to get_list() and get_path(), but at the expense of re-exporting and parsing all certificates. :param temp_dir: The temporary directory to cache the CA certs in on OS X and Windows. Needs to have secure permissions so other users can not modify the contents. Must be the same value passed to get_path(). """ with memory_lock: _module_values['last_update'] = None _module_values['certs'] = None ca_path, temp = _ca_path(temp_dir) if temp: with path_lock: if os.path.exists(ca_path): os.remove(ca_path)
Example 5
Source File: bot_groups_config.py From luci-py with Apache License 2.0 | 6 votes |
def clear_cache(): """Removes cached bot config from the datastore and the local memory. Intended to be used only from tests. """ _bots_cfg_head_key().delete() _bots_cfg_body_key().delete() _cache.reset() ### Private stuff. # Bump this to force trigger bots.cfg cache refresh, even if the config itself # didn't change. # # Changing this value is equivalent to removing the entities that hold # the cache. Note that we intentionally keep older version of the config to # allow GAE instances that still run the old code to use them.
Example 6
Source File: util.py From ACedIt with MIT License | 6 votes |
def clear_cache(site): """ Method to clear cached test cases """ confirm = input( 'Remove entire cache for site %s? (y/N) : ' % (site)) if confirm == 'y': from shutil import rmtree try: rmtree(os.path.join(Utilities.cache_dir, site)) except: print('Some error occured. Try again.') return os.makedirs(os.path.join(Utilities.cache_dir, site)) print('Done.')
Example 7
Source File: vector.py From emotion-classification with MIT License | 6 votes |
def ClearCacheKernel(self, x=None): # default behavior if x is not None: assert len(x.shape) == 2, "Argument 1 has wrong shape" if self._cacheKernel.has_key(id(x)) is False: return False else: del self._cacheKernel[id(x)] else: self._cacheKernel.clear() return True ## Create the cache for the base part of the kernel computed for # data x, and index them by the id of x. If x have already been # remembered, the old stored information is simply overwritten. # Overload this method to store different base part for different # kernels. # @param x [read] The data whose base part is to be cached. #
Example 8
Source File: generator.py From ops-cli with Apache License 2.0 | 6 votes |
def clear_cache(self): # Note: This function is not used when --refresh-cache is passed cache = self._get_cache() if cache: display.display( "Removing inventory cache %s" % self.cache_location, stderr=True, color='green') try: os.remove(os.path.expanduser(self.cache_location)) display.display("Success", color='blue') except OSError: display.display( "Warning, could not delete cache as it is not there.", color='yellow')
Example 9
Source File: fpn_global_local_fmreg_ensemble.py From GLNet with MIT License | 6 votes |
def clear_cache(self): self.c2_g = None; self.c3_g = None; self.c4_g = None; self.c5_g = None; self.output_g = None self.ps0_g = None; self.ps1_g = None; self.ps2_g = None; self.ps3_g = None self.c2_l = []; self.c3_l = []; self.c4_l = []; self.c5_l = []; self.ps00_l = []; self.ps01_l = []; self.ps02_l = []; self.ps03_l = []; self.ps10_l = []; self.ps11_l = []; self.ps12_l = []; self.ps13_l = []; self.ps20_l = []; self.ps21_l = []; self.ps22_l = []; self.ps23_l = []; self.ps0_l = None; self.ps1_l = None; self.ps2_l = None self.ps3_l = []; self.output_l = [] self.c2_b = None; self.c3_b = None; self.c4_b = None; self.c5_b = None; self.ps00_b = None; self.ps01_b = None; self.ps02_b = None; self.ps03_b = None; self.ps10_b = None; self.ps11_b = None; self.ps12_b = None; self.ps13_b = None; self.ps20_b = None; self.ps21_b = None; self.ps22_b = None; self.ps23_b = None; self.ps3_b = []; self.output_b = [] self.patch_n = 0
Example 10
Source File: sdef.py From cats-blender-plugin with MIT License | 6 votes |
def clear_cache(cls, obj=None, unused_only=False): if unused_only: valid_keys = set(hash(i) for i in bpy.data.objects if i.type == 'MESH' and i != obj) for key in (cls.g_verts.keys()-valid_keys): del cls.g_verts[key] for key in (cls.g_shapekey_data.keys()-cls.g_verts.keys()): del cls.g_shapekey_data[key] for key in (cls.g_bone_check.keys()-cls.g_verts.keys()): del cls.g_bone_check[key] elif obj: key = hash(obj) if key in cls.g_verts: del cls.g_verts[key] if key in cls.g_shapekey_data: del cls.g_shapekey_data[key] if key in cls.g_bone_check: del cls.g_bone_check[key] else: cls.g_verts = {} cls.g_bone_check = {} cls.g_shapekey_data = {}
Example 11
Source File: clear.py From plugin.program.openwizard with GNU General Public License v3.0 | 6 votes |
def clear_function_cache(over=False): dialog = xbmcgui.Dialog() if not over: if dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to clear resolver function caches?[/COLOR]'.format(CONFIG.COLOR2), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Clear Cache[/COLOR][/B]'): clear = True else: clear = True if clear: if xbmc.getCondVisibility('System.HasAddon(script.module.resolveurl)'): xbmc.executebuiltin('RunPlugin(plugin://script.module.resolveurl/?mode=reset_cache)') if xbmc.getCondVisibility('System.HasAddon(script.module.urlresolver)'): xbmc.executebuiltin('RunPlugin(plugin://script.module.urlresolver/?mode=reset_cache)')
Example 12
Source File: 0006_clear_empty_colnames_from_cache.py From cjworkbench with GNU Affero General Public License v3.0 | 6 votes |
def clear_empty_colnames_from_cache(apps, schema_editor): # Can't grab WfModule from 'apps' because we need our migration to write to # S3 -- which 'apps' models don't. from cjwstate.rendercache.io import clear_cached_render_result_for_wf_module from cjwstate.models import WfModule qs = WfModule.objects.extra( # Lots of escaping here: '\"' gets us double quotes; '%%' gives SQL '%' # instead of the DB module's SQL param replacement. where=['cached_render_result_columns::text LIKE \'%%"name": ""%%\''] # also, set ".only" so we don't select columns created in later migrations ).only( "id", "tab_id", "cached_render_result_delta_id", "cached_render_result_status", "cached_render_result_error", "cached_render_result_json", "cached_render_result_quick_fixes", "cached_render_result_columns", "cached_render_result_nrows", ) for wf_module in qs: with wf_module.workflow.cooperative_lock(): clear_cached_render_result_for_wf_module(wf_module)
Example 13
Source File: cache.py From intake with BSD 2-Clause "Simplified" License | 6 votes |
def clear_cache(self, urlpath): """ Clears cache and metadata for a given urlpath. Parameters ---------- urlpath: str, location of data May be a local path, or remote path if including a protocol specifier such as ``'s3://'``. May include glob wildcards. """ cache_entries = self._metadata.pop(urlpath, []) # ignore if missing for cache_entry in cache_entries: try: os.remove(cache_entry['cache_path']) except (OSError, IOError): pass try: fn = os.path.dirname(cache_entry['cache_path']) os.rmdir(fn) except (OSError, IOError): logger.debug("Failed to remove cache directory: %s" % fn)
Example 14
Source File: caching.py From orange3-bioinformatics with GNU General Public License v3.0 | 6 votes |
def clear_cache(): """Clear all locally cached KEGG data. """ import glob path = conf.params["cache.path"] if os.path.realpath(path) != os.path.realpath(conf.kegg_dir): raise Exception("Non default cache path. Please remove the contents " "of %r manually." % path) for cache_filename in glob.glob(os.path.join(path, "*.sqlite3")): os.remove(cache_filename) for ko_filename in glob.glob(os.path.join(path, "*.keg")): os.remove(ko_filename) for kgml_filename in glob.glob(os.path.join(path, "*.xml")): os.remove(kgml_filename) for png_filename in glob.glob(os.path.join(path, "*.png")): os.remove(png_filename)
Example 15
Source File: ch.py From chumpy with MIT License | 6 votes |
def clear_cache(self, itr=None): todo = [self] done = set([]) nodes_visited = 0 while len(todo) > 0: nodes_visited += 1 next = todo.pop() if itr is not None and itr==next._itr: continue if id(next) not in done: next._cache['r'] = None next._cache['drs'].clear() next._itr = itr for parent, parent_dict in list(next._parents.items()): object.__setattr__(parent, '_dirty_vars', parent._dirty_vars.union(parent_dict['varnames'])) parent._invalidate_cacheprop_names(parent_dict['varnames']) todo.append(parent) done.add(id(next)) return nodes_visited
Example 16
Source File: neighbor_index_cache.py From ibeis with Apache License 2.0 | 6 votes |
def clear_uuid_cache(qreq_): """ CommandLine: python -m ibeis.algo.hots.neighbor_index_cache --test-clear_uuid_cache Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.neighbor_index_cache import * # NOQA >>> import ibeis >>> qreq_ = ibeis.testdata_qreq_(defaultdb='testdb1', p='default:fg_on=True') >>> fgws_list = clear_uuid_cache(qreq_) >>> result = str(fgws_list) >>> print(result) """ print('[nnindex] clearing uuid cache') uuid_map_fpath = get_nnindexer_uuid_map_fpath(qreq_) ut.delete(uuid_map_fpath) ut.delete(uuid_map_fpath + '.lock') print('[nnindex] finished uuid cache clear')
Example 17
Source File: _system.py From ArcREST with Apache License 2.0 | 6 votes |
def clearRestCache(self): """ This operation clears the cache on all REST handlers in the system. While the server typically manages the REST cache for you, use this operation to get explicit control over the cache. Note: Invoking this operation will cause REST handlers to be restarted on all server machines. """ url = self._url + "/handlers/rest/cache/clear" params = { "f" : "json" } return self._post(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_port=self._proxy_port, proxy_url=self._proxy_url)
Example 18
Source File: admin.py From mautrix-telegram with GNU Affero General Public License v3.0 | 6 votes |
def clear_db_cache(evt: CommandEvent) -> EventID: try: section = evt.args[0].lower() except IndexError: return await evt.reply("**Usage:** `$cmdprefix+sp clear-db-cache <section>`") if section == "portal": po.Portal.by_tgid = {} po.Portal.by_mxid = {} await evt.reply("Cleared portal cache") elif section == "puppet": pu.Puppet.cache = {} for puppet in pu.Puppet.by_custom_mxid.values(): puppet.sync_task.cancel() pu.Puppet.by_custom_mxid = {} await asyncio.gather(*[puppet.try_start() for puppet in pu.Puppet.all_with_custom_mxid()], loop=evt.loop) await evt.reply("Cleared puppet cache and restarted custom puppet syncers") elif section == "user": u.User.by_mxid = { user.mxid: user for user in u.User.by_tgid.values() } await evt.reply("Cleared non-logged-in user cache") else: return await evt.reply("**Usage:** `$cmdprefix+sp clear-db-cache <section>`")
Example 19
Source File: precache.py From supotato with MIT License | 6 votes |
def clear_cache_directory(): for root, dirs, files in os.walk(download_cache_directory): for d in dirs: if d == '.git': dirpath = os.path.join(root,d) # print('rm dir ' + dirpath) try: os.rmdir(dirpath) except: pass for f in files: if f.endswith('.h') or f.endswith('.m'): continue filepath = os.path.join(root, f) #remove try: # print('remove ' + filepath) os.remove(filepath) except: pass
Example 20
Source File: gutter_color.py From GutterColor with MIT License | 6 votes |
def clear_cache(force = False): """ If the folder exists, and has more than 5MB of icons in the cache, delete it to clear all the icons then recreate it. """ from os.path import getsize, join, isfile, exists from os import makedirs, listdir from sublime import cache_path from shutil import rmtree # The icon cache path icon_path = join(cache_path(), "GutterColor") # The maximum amount of space to take up limit = 5242880 # 5 MB if exists(icon_path): size = sum(getsize(join(icon_path, f)) for f in listdir(icon_path) if isfile(join(icon_path, f))) if force or (size > limit): rmtree(icon_path) if not exists(icon_path): makedirs(icon_path)
Example 21
Source File: pydevd_dont_trace.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
def clear_trace_filter_cache(): ''' Clear the trace filter cache. Call this after reloading. ''' global should_trace_hook try: # Need to temporarily disable a hook because otherwise # _filename_to_ignored_lines.clear() will never complete. old_hook = should_trace_hook should_trace_hook = None # Clear the linecache linecache.clearcache() _filename_to_ignored_lines.clear() finally: should_trace_hook = old_hook
Example 22
Source File: interactiveshell.py From Computable with MIT License | 6 votes |
def clear_main_mod_cache(self): """Clear the cache of main modules. Mainly for use by utilities like %reset. Examples -------- In [15]: import IPython In [16]: m = _ip.new_main_mod(IPython.__file__) In [17]: len(_ip._main_mod_cache) > 0 Out[17]: True In [18]: _ip.clear_main_mod_cache() In [19]: len(_ip._main_mod_cache) == 0 Out[19]: True """ self._main_mod_cache.clear() #------------------------------------------------------------------------- # Things related to debugging #-------------------------------------------------------------------------
Example 23
Source File: base.py From albatross with GNU Affero General Public License v3.0 | 6 votes |
def clear_cache(self): """ Remove the cache files. The various try/except blocks are there to account for race conditions where the directory may already have been deleted. """ try: self.logger.info("Clearing out %s", self.cache_dir) shutil.rmtree(self.cache_dir) except FileNotFoundError: pass parent = os.path.dirname(self.cache_dir) if not os.listdir(parent): try: self.logger.info("Clearing out parent dir: %s", parent) shutil.rmtree(parent) except FileNotFoundError: pass
Example 24
Source File: indices.py From watchmen with Apache License 2.0 | 6 votes |
def clear_cache(self, index=None, params=None): """ Clear either all caches or specific cached associated with one ore more indices. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html>`_ :arg index: A comma-separated list of index name to limit the operation :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to concrete indices that are open, closed or both., default 'open', valid choices are: 'open', 'closed', 'none', 'all' :arg field_data: Clear field data :arg fielddata: Clear field data :arg fields: A comma-separated list of fields to clear when using the `field_data` parameter (default: all) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg query: Clear query caches :arg recycler: Clear the recycler cache :arg request: Clear request cache """ return self.transport.perform_request('POST', _make_path(index, '_cache', 'clear'), params=params)
Example 25
Source File: lru.py From redis-lru with BSD 2-Clause "Simplified" License | 6 votes |
def clear_all_cache(self): def delete_keys(items): pipeline = self.client.pipeline() for item in items: pipeline.delete(item) pipeline.execute() match = '{}*'.format(self.key_prefix) keys = [] for key in self.client.scan_iter(match, count=100): keys.append(key) if len(keys) >= 100: delete_keys(keys) keys = [] time.sleep(0.01) else: delete_keys(keys)
Example 26
Source File: util.py From bazarr with GNU General Public License v3.0 | 6 votes |
def post_clear_cache(func): """Decorator for functions that alter the index using the git command. This would invalidate our possibly existing entries dictionary which is why it must be deleted to allow it to be lazily reread later. :note: This decorator will not be required once all functions are implemented natively which in fact is possible, but probably not feasible performance wise. """ @wraps(func) def post_clear_cache_if_not_raised(self, *args, **kwargs): rval = func(self, *args, **kwargs) self._delete_entries_cache() return rval # END wrapper method return post_clear_cache_if_not_raised
Example 27
Source File: query.py From coursys with GNU General Public License v3.0 | 6 votes |
def clear_expired_members_from_cache(): """ Remove any files from the cache if they've expired. """ cache_location = CachedQuery.cache_location() CachedQuery.logger.log( "Looking for expired cache members in " + cache_location ) if not os.path.isdir(cache_location): CachedQuery.logger.log( "Cache directory not found.") return for cache_file in os.listdir(cache_location): cache_file = os.path.join(cache_location, cache_file ) if cache_file.endswith('.query') and os.path.isfile( cache_file ): with open(cache_file, 'r') as f: obj = json.loads( f.read() ) expires = iso8601.parse_date(obj['expires']) if not pytz.UTC.localize(datetime.datetime.now()) < expires: result_file = cache_file.replace('.query', '.result') os.remove( cache_file ) os.remove( result_file ) CachedQuery.logger.log( "Deleting expired cache: " + cache_file + ", " + result_file )
Example 28
Source File: spec.py From filesystem_spec with BSD 3-Clause "New" or "Revised" License | 6 votes |
def clear_instance_cache(cls): """ Clear the cache of filesystem instances. Notes ----- Unless overridden by setting the ``cachable`` class attribute to False, the filesystem class stores a reference to newly created instances. This prevents Python's normal rules around garbage collection from working, since the instances refcount will not drop to zero until ``clear_instance_cache`` is called. """ cls._cache.clear() # ------------------------------------------------------------------------ # Aliases
Example 29
Source File: _terminal.py From enlighten with Mozilla Public License 2.0 | 5 votes |
def clear_cache(self): """ Clear cached terminal returns """ self._cache.clear()
Example 30
Source File: data.py From Saliency-detection-in-360-video with MIT License | 5 votes |
def clear_cache(self): from tqdm import trange for item in trange(len(self), desc='cleaning'): cfile = self.data[item][:-4] + '_gt.npy' if os.path.isfile(cfile): print('remove {}'.format(cfile)) os.remove(cfile) return self
Example 31
Source File: downloading.py From thinkhazard with GNU General Public License v3.0 | 5 votes |
def clear_cache(self): logger.info("Clearing raster cache.") cache_path = os.path.join(self.settings["data_path"], "hazardsets") for filename in os.listdir(cache_path): file_path = os.path.join(cache_path, filename) if os.path.isfile(file_path): os.unlink(file_path)
Example 32
Source File: CachedDataManager.py From ue4cli with MIT License | 5 votes |
def clearCache(): """ Clears any cached data we have stored about specific engine versions """ if os.path.exists(CachedDataManager._cacheDir()) == True: shutil.rmtree(CachedDataManager._cacheDir())
Example 33
Source File: load_channels.py From plugin.video.stalker with GNU General Public License v2.0 | 5 votes |
def clearCache(url, path): portalurl = "_".join(re.findall("[a-zA-Z0-9]+", url)); for root, dirs, files in os.walk(path): for file in files: if file.startswith(portalurl): os.remove(root + '/' + file);
Example 34
Source File: handlers.py From rtv with MIT License | 5 votes |
def clear_cache(cls): """Remove all items from the cache.""" with cls.ca_lock: cls.cache = {} cls.timeouts = {}
Example 35
Source File: copy_reg.py From ImageFusion with MIT License | 5 votes |
def clear_extension_cache(): _extension_cache.clear() # Standard extension code assignments # Reserved ranges # First Last Count Purpose # 1 127 127 Reserved for Python standard library # 128 191 64 Reserved for Zope # 192 239 48 Reserved for 3rd parties # 240 255 16 Reserved for private use (will never be assigned) # 256 Inf Inf Reserved for future assignment # Extension codes are assigned by the Python Software Foundation.
Example 36
Source File: database.py From ImageFusion with MIT License | 5 votes |
def clear_cache(self): """ Clears the internal cache. """ self._cache.clear() self._cache_egg.clear()
Example 37
Source File: signals.py From credentials with GNU Affero General Public License v3.0 | 5 votes |
def clear_site_cache(sender, **kwargs): # pylint: disable=unused-argument Site.objects.clear_cache() # Clear the Site cache to force a refresh of related SiteConfiguration objects
Example 38
Source File: reaper.py From reapy with MIT License | 5 votes |
def clear_peak_cache(): """ Reset global peak cache. """ RPR.ClearPeakCache()
Example 39
Source File: workflow.py From pomodoro-alfred with MIT License | 5 votes |
def clear_cache(self, filter_func=lambda f: True): """Delete all files in workflow's :attr:`cachedir`. :param filter_func: Callable to determine whether a file should be deleted or not. ``filter_func`` is called with the filename of each file in the data directory. If it returns ``True``, the file will be deleted. By default, *all* files will be deleted. :type filter_func: ``callable`` """ self._delete_directory_contents(self.cachedir, filter_func)
Example 40
Source File: xbmcmixin.py From ru with GNU General Public License v2.0 | 5 votes |
def clear_function_cache(self): '''Clears the storage that caches results when using :meth:`xbmcswift2.Plugin.cached_route` or :meth:`xbmcswift2.Plugin.cached`. ''' self.get_storage(self._function_cache_name).clear()
Example 41
Source File: urllib2.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def clear_cache(self): for conn in self.cache.values(): conn.close() self.cache.clear() self.timeout.clear()
Example 42
Source File: navigator.py From plugin.video.brplay with GNU General Public License v3.0 | 5 votes |
def clear_cache(self): control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return cache.delete_file() control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
Example 43
Source File: profanity_filter.py From profanity-filter with GNU General Public License v3.0 | 5 votes |
def clear_cache(self) -> None: if self._cache_clearing_disabled: return self._update_profane_word_dictionary_files() self._update_profane_word_dictionaries() self._clear_words_cache()