Utilize CacheManager for all existing caches.
This commit is contained in:
parent
27cba7e26c
commit
c47bb4c902
@ -85,7 +85,7 @@ deploy:
|
|||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
# obs_clone.py
|
# obs_clone.py
|
||||||
- ~/.cache/openSUSE-release-tools-clone
|
- ~/.cache/openSUSE-release-tools/request/clone
|
||||||
# distribution jobs `osc build`
|
# distribution jobs `osc build`
|
||||||
- .docker-tmp
|
- .docker-tmp
|
||||||
pip: true
|
pip: true
|
||||||
|
@ -46,7 +46,7 @@ to unintentionally change the default project, annotation state, or time period
|
|||||||
by saving the dashboard with different defaults.
|
by saving the dashboard with different defaults.
|
||||||
|
|
||||||
Use the `--debug` option and inspect individual request XML dumps by looking in
|
Use the `--debug` option and inspect individual request XML dumps by looking in
|
||||||
`~/.cache/openSUSE-release-tools-metrics` or:
|
`~/.cache/openSUSE-release-tools/request/metrics` or:
|
||||||
|
|
||||||
```
|
```
|
||||||
osc api '/request/$reqid?withfullhistory=1'
|
osc api '/request/$reqid?withfullhistory=1'
|
||||||
|
@ -26,6 +26,7 @@ except:
|
|||||||
|
|
||||||
import osc.conf
|
import osc.conf
|
||||||
import osc.core
|
import osc.core
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
import ReviewBot
|
import ReviewBot
|
||||||
|
|
||||||
from osclib.comments import CommentAPI
|
from osclib.comments import CommentAPI
|
||||||
@ -189,8 +190,7 @@ class LegalAuto(ReviewBot.ReviewBot):
|
|||||||
self.delete_from_db(req.reqid)
|
self.delete_from_db(req.reqid)
|
||||||
|
|
||||||
def _pkl_path(self):
|
def _pkl_path(self):
|
||||||
CACHE_DIR = os.path.expanduser('~/.cache/osc-plugin-factory')
|
return CacheManager.directory('legal-auto')
|
||||||
return os.path.join(CACHE_DIR, 'legaldb')
|
|
||||||
|
|
||||||
def update_project(self, project):
|
def update_project(self, project):
|
||||||
try:
|
try:
|
||||||
|
@ -544,14 +544,13 @@ def main(args):
|
|||||||
|
|
||||||
# Use separate cache since it is persistent.
|
# Use separate cache since it is persistent.
|
||||||
_, package = project_pseudometa_package(apiurl, args.project)
|
_, package = project_pseudometa_package(apiurl, args.project)
|
||||||
Cache.CACHE_DIR = Cache.CACHE_DIR + '-metrics'
|
|
||||||
if args.wipe_cache:
|
if args.wipe_cache:
|
||||||
Cache.delete_all()
|
Cache.delete_all()
|
||||||
if args.heavy_cache:
|
if args.heavy_cache:
|
||||||
Cache.PATTERNS['/search/request'] = sys.maxint
|
Cache.PATTERNS['/search/request'] = sys.maxint
|
||||||
Cache.PATTERNS['/source/[^/]+/{}/_history'.format(package)] = sys.maxint
|
Cache.PATTERNS['/source/[^/]+/{}/_history'.format(package)] = sys.maxint
|
||||||
Cache.PATTERNS['/source/[^/]+/{}/[^/]+\?rev=.*'.format(package)] = sys.maxint
|
Cache.PATTERNS['/source/[^/]+/{}/[^/]+\?rev=.*'.format(package)] = sys.maxint
|
||||||
Cache.init()
|
Cache.init('metrics')
|
||||||
|
|
||||||
Config(apiurl, args.project)
|
Config(apiurl, args.project)
|
||||||
api = StagingAPI(apiurl, args.project)
|
api = StagingAPI(apiurl, args.project)
|
||||||
|
@ -22,7 +22,7 @@ A separate, minimal set of aggregation done for each IP protocol data.
|
|||||||
- `aggregate.php`: invoke to manage entire process including calling (`ingest.php`)
|
- `aggregate.php`: invoke to manage entire process including calling (`ingest.php`)
|
||||||
- `ingest.php`: used to parse a single log file / stream and dump summary JSON to stdout
|
- `ingest.php`: used to parse a single log file / stream and dump summary JSON to stdout
|
||||||
|
|
||||||
See `~/.cache/openSUSE-release-tools-access` for cache data separated by IP protocol. A single JSON file corresponds to a single access log file.
|
See `~/.cache/openSUSE-release-tools/metrics-access` for cache data separated by IP protocol. A single JSON file corresponds to a single access log file.
|
||||||
|
|
||||||
## Future product versions
|
## Future product versions
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
use InfluxDB\Point;
|
use InfluxDB\Point;
|
||||||
use InfluxDB\Database;
|
use InfluxDB\Database;
|
||||||
|
|
||||||
$CACHE_DIR = $_SERVER['HOME'] . '/.cache/openSUSE-release-tools-access';
|
$CACHE_DIR = $_SERVER['HOME'] . '/.cache/openSUSE-release-tools/metrics-access';
|
||||||
const PROTOCOLS = ['ipv4', 'ipv6'];
|
const PROTOCOLS = ['ipv4', 'ipv6'];
|
||||||
const PONTIFEX = 'http://pontifex.infra.opensuse.org/logs';
|
const PONTIFEX = 'http://pontifex.infra.opensuse.org/logs';
|
||||||
const LANGLEY = 'http://langley.suse.de/pub/pontifex%s-opensuse.suse.de';
|
const LANGLEY = 'http://langley.suse.de/pub/pontifex%s-opensuse.suse.de';
|
||||||
|
@ -212,12 +212,11 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if args.cache:
|
if args.cache:
|
||||||
from osclib.cache import Cache
|
from osclib.cache import Cache
|
||||||
Cache.CACHE_DIR = Cache.CACHE_DIR + '-clone'
|
|
||||||
Cache.PATTERNS = {}
|
Cache.PATTERNS = {}
|
||||||
# Prevent caching source information from local clone.
|
# Prevent caching source information from local clone.
|
||||||
Cache.PATTERNS['/source/[^/]+/[^/]+/[^/]+?rev'] = 0
|
Cache.PATTERNS['/source/[^/]+/[^/]+/[^/]+?rev'] = 0
|
||||||
Cache.PATTERNS['.*'] = Cache.TTL_LONG * 2
|
Cache.PATTERNS['.*'] = Cache.TTL_LONG * 2
|
||||||
Cache.init()
|
Cache.init('clone')
|
||||||
|
|
||||||
osc.conf.config['debug'] = args.debug
|
osc.conf.config['debug'] = args.debug
|
||||||
project_fence.project = args.project
|
project_fence.project = args.project
|
||||||
|
@ -12,6 +12,7 @@ import urllib
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from osc import conf
|
from osc import conf
|
||||||
from osc.core import urlopen
|
from osc.core import urlopen
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -64,7 +65,7 @@ class Cache(object):
|
|||||||
cache, but obviously not for other contributors.
|
cache, but obviously not for other contributors.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CACHE_DIR = os.path.expanduser('~/.cache/openSUSE-release-tools')
|
CACHE_DIR = None
|
||||||
TTL_LONG = 12 * 60 * 60
|
TTL_LONG = 12 * 60 * 60
|
||||||
TTL_MEDIUM = 30 * 60
|
TTL_MEDIUM = 30 * 60
|
||||||
TTL_SHORT = 5 * 60
|
TTL_SHORT = 5 * 60
|
||||||
@ -101,7 +102,9 @@ class Cache(object):
|
|||||||
last_updated = {}
|
last_updated = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init():
|
def init(directory='main'):
|
||||||
|
Cache.CACHE_DIR = CacheManager.directory('request', directory)
|
||||||
|
|
||||||
Cache.patterns = []
|
Cache.patterns = []
|
||||||
for pattern in Cache.PATTERNS:
|
for pattern in Cache.PATTERNS:
|
||||||
Cache.patterns.append(re.compile(pattern))
|
Cache.patterns.append(re.compile(pattern))
|
||||||
@ -249,6 +252,9 @@ class Cache(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def path(url, project, include_file=False, makedirs=False):
|
def path(url, project, include_file=False, makedirs=False):
|
||||||
|
if not Cache.CACHE_DIR:
|
||||||
|
raise Exception('Cache.init() must be called first')
|
||||||
|
|
||||||
parts = [Cache.CACHE_DIR]
|
parts = [Cache.CACHE_DIR]
|
||||||
|
|
||||||
o = urlparse.urlsplit(url)
|
o = urlparse.urlsplit(url)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
import subprocess
|
import subprocess
|
||||||
from xdg.BaseDirectory import save_cache_path
|
|
||||||
|
|
||||||
CACHE_DIR = save_cache_path('openSUSE-release-tools', 'git')
|
# Git will not be happy if pruned, but not used enough to be worth excluding.
|
||||||
|
CACHE_DIR = CacheManager.directory('git')
|
||||||
|
|
||||||
def clone(url, directory):
|
def clone(url, directory):
|
||||||
return_code = subprocess.call(['git', 'clone', url, directory])
|
return_code = subprocess.call(['git', 'clone', url, directory])
|
||||||
|
@ -2,26 +2,15 @@ from datetime import datetime
|
|||||||
import fcntl
|
import fcntl
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import os
|
import os
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
import shelve
|
import shelve
|
||||||
try:
|
try:
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
except:
|
except:
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
from xdg.BaseDirectory import save_cache_path
|
|
||||||
except ImportError:
|
|
||||||
from xdg.BaseDirectory import xdg_cache_home
|
|
||||||
|
|
||||||
def save_cache_path(*name):
|
|
||||||
path = os.path.join(xdg_cache_home, *name)
|
|
||||||
if not os.path.isdir(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
return path
|
|
||||||
|
|
||||||
# Where the cache files are stored
|
# Where the cache files are stored
|
||||||
CACHEDIR = save_cache_path('opensuse-repo-checker')
|
CACHEDIR = CacheManager.directory('memoize')
|
||||||
|
|
||||||
|
|
||||||
def memoize(ttl=None, session=False, add_invalidate=False):
|
def memoize(ttl=None, session=False, add_invalidate=False):
|
||||||
@ -175,10 +164,7 @@ def memoize(ttl=None, session=False, add_invalidate=False):
|
|||||||
_close_cache(cache)
|
_close_cache(cache)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
cache_dir = os.path.expanduser(CACHEDIR)
|
cache_name = os.path.join(CACHEDIR, fn.__name__)
|
||||||
if not os.path.exists(cache_dir):
|
|
||||||
os.makedirs(cache_dir)
|
|
||||||
cache_name = os.path.join(cache_dir, fn.__name__)
|
|
||||||
return _fn
|
return _fn
|
||||||
|
|
||||||
ttl = ttl if ttl else TIMEOUT
|
ttl = ttl if ttl else TIMEOUT
|
||||||
|
@ -19,12 +19,12 @@ from osc.core import Package
|
|||||||
from osc.core import show_results_meta
|
from osc.core import show_results_meta
|
||||||
from osc.core import undelete_package
|
from osc.core import undelete_package
|
||||||
from osc import conf
|
from osc import conf
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
from osclib.conf import Config, str2bool
|
from osclib.conf import Config, str2bool
|
||||||
from osclib.core import repository_path_expand
|
from osclib.core import repository_path_expand
|
||||||
from osclib.stagingapi import StagingAPI
|
from osclib.stagingapi import StagingAPI
|
||||||
from osclib.util import project_list_family
|
from osclib.util import project_list_family
|
||||||
from osclib.util import project_list_family_prior
|
from osclib.util import project_list_family_prior
|
||||||
from xdg.BaseDirectory import save_cache_path
|
|
||||||
import glob
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
@ -47,7 +47,7 @@ import string
|
|||||||
import ToolBase
|
import ToolBase
|
||||||
|
|
||||||
# share header cache with repochecker
|
# share header cache with repochecker
|
||||||
from osclib.memoize import CACHEDIR
|
CACHEDIR = CacheManager.directory('repository-meta')
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
@ -1235,7 +1235,7 @@ class CommandLineInterface(ToolBase.CommandLineInterface):
|
|||||||
|
|
||||||
# Cache dir specific to hostname and project.
|
# Cache dir specific to hostname and project.
|
||||||
host = urlparse.urlparse(api.apiurl).hostname
|
host = urlparse.urlparse(api.apiurl).hostname
|
||||||
cache_dir = save_cache_path('opensuse-packagelists', host, opts.project)
|
cache_dir = CacheManager.directory('pkglistgen', host, opts.project)
|
||||||
|
|
||||||
if not opts.no_checkout:
|
if not opts.no_checkout:
|
||||||
if os.path.exists(cache_dir):
|
if os.path.exists(cache_dir):
|
||||||
@ -1298,7 +1298,7 @@ class CommandLineInterface(ToolBase.CommandLineInterface):
|
|||||||
if drop_list:
|
if drop_list:
|
||||||
# Ensure solv files from all releases in product family are updated.
|
# Ensure solv files from all releases in product family are updated.
|
||||||
print('-> solv_cache_update')
|
print('-> solv_cache_update')
|
||||||
cache_dir_solv = save_cache_path('opensuse-packagelists', 'solv')
|
cache_dir_solv = CacheManager.directory('pkglistgen', 'solv')
|
||||||
family_last = target_config.get('pkglistgen-product-family-last')
|
family_last = target_config.get('pkglistgen-product-family-last')
|
||||||
family_include = target_config.get('pkglistgen-product-family-include')
|
family_include = target_config.get('pkglistgen-product-family-include')
|
||||||
solv_prior = self.solv_cache_update(
|
solv_prior = self.solv_cache_update(
|
||||||
|
@ -175,7 +175,8 @@ sub mirror_repo($$$) {
|
|||||||
my $repo = shift;
|
my $repo = shift;
|
||||||
my $arch = shift;
|
my $arch = shift;
|
||||||
|
|
||||||
my $repodir = ($ENV{XDG_CACHE_HOME}||$ENV{HOME}."/.cache")."/opensuse-repo-checker/repo-$project-$repo-$arch";
|
# Old and new in single directory, but never deployed together.
|
||||||
|
my $repodir = ($ENV{XDG_CACHE_HOME}||$ENV{HOME}."/.cache")."/openSUSE-release-tools/repository-meta/repo-$project-$repo-$arch";
|
||||||
mkdir($repodir);
|
mkdir($repodir);
|
||||||
|
|
||||||
system(
|
system(
|
||||||
|
@ -14,6 +14,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
from osclib.conf import Config
|
from osclib.conf import Config
|
||||||
from osclib.conf import str2bool
|
from osclib.conf import str2bool
|
||||||
from osclib.core import BINARY_REGEX
|
from osclib.core import BINARY_REGEX
|
||||||
@ -31,12 +32,12 @@ from osclib.core import repositories_states
|
|||||||
from osclib.core import repositories_published
|
from osclib.core import repositories_published
|
||||||
from osclib.core import target_archs
|
from osclib.core import target_archs
|
||||||
from osclib.cycle import CycleDetector
|
from osclib.cycle import CycleDetector
|
||||||
from osclib.memoize import CACHEDIR
|
|
||||||
from osclib.memoize import memoize
|
from osclib.memoize import memoize
|
||||||
from osclib.util import sha1_short
|
from osclib.util import sha1_short
|
||||||
|
|
||||||
import ReviewBot
|
import ReviewBot
|
||||||
|
|
||||||
|
CACHEDIR = CacheManager.directory('repository-meta')
|
||||||
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
|
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||||
CheckResult = namedtuple('CheckResult', ('success', 'comment'))
|
CheckResult = namedtuple('CheckResult', ('success', 'comment'))
|
||||||
INSTALL_REGEX = r"^(?:can't install (.*?)|found conflict of (.*?) with (.*?)):$"
|
INSTALL_REGEX = r"^(?:can't install (.*?)|found conflict of (.*?) with (.*?)):$"
|
||||||
|
@ -13,6 +13,7 @@ import xml.etree.cElementTree as ET
|
|||||||
import httpretty
|
import httpretty
|
||||||
import osc
|
import osc
|
||||||
from osclib.cache import Cache
|
from osclib.cache import Cache
|
||||||
|
from osclib.cache_manager import CacheManager
|
||||||
|
|
||||||
|
|
||||||
APIURL = 'http://localhost'
|
APIURL = 'http://localhost'
|
||||||
@ -114,9 +115,8 @@ class OBS(object):
|
|||||||
"""Instance constructor."""
|
"""Instance constructor."""
|
||||||
self.fixtures = fixtures
|
self.fixtures = fixtures
|
||||||
|
|
||||||
if not hasattr(Cache, '_CACHE_DIR'):
|
CacheManager.directory_test()
|
||||||
Cache._CACHE_DIR = True
|
Cache.init()
|
||||||
Cache.CACHE_DIR += '-test'
|
|
||||||
Cache.delete_all()
|
Cache.delete_all()
|
||||||
httpretty.enable()
|
httpretty.enable()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user