当前位置: 首页>>代码示例>>Python>>正文


Python whisper.parseRetentionDef函数代码示例

本文整理汇总了Python中whisper.parseRetentionDef函数的典型用法代码示例。如果您正苦于以下问题:Python parseRetentionDef函数的具体用法?Python parseRetentionDef怎么用?Python parseRetentionDef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parseRetentionDef函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_invalid_retentions

    def test_invalid_retentions(self):
        retention_map = (
            # From getUnitString
            ('10x:10', ValueError("Invalid unit 'x'")),
            ('60:10x', ValueError("Invalid unit 'x'")),

            # From parseRetentionDef
            ('10', ValueError("Invalid retention definition '10'")),
            ('10X:10', ValueError("Invalid precision specification '10X'")),
            ('10:10$', ValueError("Invalid retention specification '10$'")),
            ('60:10', (60, 10)),
        )
        for retention, expected_exc in retention_map:
            try:
                results = whisper.parseRetentionDef(retention)
            except expected_exc.__class__ as exc:
                self.assertEqual(
                    str(expected_exc),
                    str(exc),
                )
                self.assertEqual(
                    expected_exc.__class__,
                    exc.__class__,
                )
            else:
                # When there isn't an exception raised
                self.assertEqual(results, expected_exc)
开发者ID:yadsirhc,项目名称:whisper,代码行数:27,代码来源:test_whisper.py

示例2: test_valid_retentions

 def test_valid_retentions(self):
     retention_map = (
         ('60:10', (60, 10)),
         ('10:60', (10, 60)),
         ('10s:10h', (10, 3600)),
     )
     for retention, expected in retention_map:
         results = whisper.parseRetentionDef(retention)
         self.assertEqual(results, expected)
开发者ID:yadsirhc,项目名称:whisper,代码行数:9,代码来源:test_whisper.py

示例3: _create

 def _create(self):
     """Create the Whisper file on disk"""
     if not os.path.exists(settings.SALMON_WHISPER_DB_PATH):
         os.makedirs(settings.SALMON_WHISPER_DB_PATH)
     archives = [whisper.parseRetentionDef(retentionDef)
                 for retentionDef in settings.ARCHIVES.split(",")]
     whisper.create(self.path, archives,
                    xFilesFactor=settings.XFILEFACTOR,
                    aggregationMethod=settings.AGGREGATION_METHOD)
开发者ID:2mind,项目名称:salmon,代码行数:9,代码来源:graph.py

示例4: createDs

def createDs(uuid):
    archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in WHISPER_ARCHIVES]
    dataFile = os.path.join(WHISPER_DATA,str(uuid) + ".wsp")
    try:
        os.makedirs(WHISPER_DATA)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise
    try:
        whisper.create(dataFile, archives, xFilesFactor=0.5, aggregationMethod="average")
    except whisper.WhisperException, exc:
        raise SystemExit('[ERROR] %s' % str(exc))
开发者ID:lowks,项目名称:teleceptor,代码行数:12,代码来源:whisperUtils.py

示例5: create

def create(path, retentions,  overwrite=False, xFilesFactor=0.5, aggregationMethod='average'):
    archives = [whisper.parseRetentionDef(str(timePerPoint)+":"+str(timeToStore))
            for (timePerPoint, timeToStore) in retentions]
    if len(retentions) == 0:
        raise Exception("No Retention given")

    if overwrite and os.path.exists(path):
        print 'Overwriting existing file: %s' % path
        os.unlink(path)

    p = path.split("/")[:-1]
    p = join(p, os.path.sep)
    if not os.path.exists(p):
        os.makedirs(p)

    whisper.create(path + '.wsp', archives, xFilesFactor, aggregationMethod)
    return True
开发者ID:dergraf,项目名称:whisbert,代码行数:17,代码来源:whisbert.py

示例6: ConfigParser

config_parser = ConfigParser()
if not config_parser.read(SCHEMAS_FILE):
  raise SystemExit("Error: Couldn't read config file: %s" % SCHEMAS_FILE)

errors_found = 0

for section in config_parser.sections():
  print("Section '%s':" % section)
  options = dict(config_parser.items(section))
  retentions = options['retentions'].split(',')

  archives = []
  section_failed = False
  for retention in retentions:
    try:
      archives.append(whisper.parseRetentionDef(retention))
    except ValueError as e:
      print(
        "  - Error: Section '%s' contains an invalid item in its retention definition ('%s')" %
        (section, retention)
      )
      print("    %s" % e)
      section_failed = True

  if not section_failed:
    try:
      whisper.validateArchiveList(archives)
    except whisper.InvalidConfiguration as e:
      print(
        "  - Error: Section '%s' contains an invalid retention definition ('%s')" %
        (section, ','.join(retentions))
开发者ID:NixM0nk3y,项目名称:carbon,代码行数:31,代码来源:validate-storage-schemas.py

示例7: function

    help="Change the aggregation function (%s)" % ", ".join(whisper.aggregationMethods),
)
option_parser.add_option("--force", default=False, action="store_true", help="Perform a destructive change")
option_parser.add_option(
    "--newfile", default=None, action="store", help="Create a new database file without removing the existing one"
)
option_parser.add_option("--nobackup", action="store_true", help="Delete the .bak file after successful execution")

(options, args) = option_parser.parse_args()

if len(args) < 2:
    option_parser.print_usage()
    sys.exit(1)

path = args[0]
new_archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in args[1:]]

info = whisper.info(path)
old_archives = info["archives"]
# sort by precision, lowest to highest
old_archives.sort(key=lambda a: a["secondsPerPoint"], reverse=True)

if options.xFilesFactor is None:
    xff = info["xFilesFactor"]
else:
    xff = options.xFilesFactor

if options.aggregationMethod is None:
    aggregationMethod = info["aggregationMethod"]
else:
    aggregationMethod = options.aggregationMethod
开发者ID:afsheenb,项目名称:graphite,代码行数:31,代码来源:whisper-resize.py

示例8: fromString

 def fromString(retentionDef):
   (secondsPerPoint, points) = whisper.parseRetentionDef(retentionDef)
   return Archive(secondsPerPoint, points)
开发者ID:devsfr,项目名称:carbon,代码行数:3,代码来源:storage.py

示例9: values

1h:7d        1 hour per datapoint, 7 days of retention
12h:2y       12 hours per datapoint, 2 years of retention
''')
option_parser.add_option('--xFilesFactor', default=0.5, type='float')
option_parser.add_option('--aggregationMethod', default='average',
        type='string', help="Function to use when aggregating values (%s)" %
        ', '.join(whisper.aggregationMethods))
option_parser.add_option('--overwrite', default=False, action='store_true')

(options, args) = option_parser.parse_args()

if len(args) < 2:
  option_parser.print_usage()
  sys.exit(1)

path = args[0]
archives = [whisper.parseRetentionDef(retentionDef)
            for retentionDef in args[1:]]

if os.path.exists(path) and options.overwrite:
    print 'Overwriting existing file: %s' % path
    os.unlink(path)

try:
  whisper.create(path, archives, xFilesFactor=options.xFilesFactor, aggregationMethod=options.aggregationMethod)
except whisper.WhisperException, exc:
  raise SystemExit('[ERROR] %s' % str(exc))

size = os.stat(path).st_size
print 'Created: %s (%d bytes)' % (path,size)
开发者ID:debedb,项目名称:kupuestra2,代码行数:30,代码来源:whisper-create.py

示例10: timedelta

from datetime import timedelta
import glob
import os
import re
import time

import whisper

HOUR = 3600
DAY = timedelta(days=1).total_seconds()
WEEK = timedelta(days=7).total_seconds()
MONTH = timedelta(days=30).total_seconds()  # close enough
YEAR = timedelta(days=365).total_seconds()

RETENTION = [whisper.parseRetentionDef(x) for x in ["60:70", "10m:150", "1h:8d", "4h:31d", "1d:366d"]]


def get_period(label):
    label = label.lower()
    if "hour" in label:
        return HOUR
    elif "week" in label:
        return WEEK
    elif "month" in label:
        return MONTH
    elif "year" in label:
        return YEAR
    return DAY  # default

开发者ID:shendo,项目名称:itzodmon,代码行数:28,代码来源:datastore.py

示例11: start

 def start(self):
     # build archives based on retention setting
     # NOTE: if retention is changed in config on an existing database
     # it will have to be rebuilt.
     self.archives = [whisper.parseRetentionDef(x) for x in self.retention]
开发者ID:20c,项目名称:vaping,代码行数:5,代码来源:whisper.py


注:本文中的whisper.parseRetentionDef函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。