-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional whisper utilities for testing purposes
- Loading branch information
Showing
8 changed files
with
201 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Fri Aug 26 15:26:44 CEST 2011 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys, time | ||
import whisper | ||
from optparse import OptionParser | ||
|
||
now = int( time.time() ) | ||
yesterday = now - (60 * 60 * 24) | ||
|
||
option_parser = OptionParser(usage='''%prog [options] path''') | ||
option_parser.add_option('--from', default=yesterday, type='int', dest='_from', | ||
help=("Unix epoch time of the beginning of " | ||
"your requested interval (default: 24 hours ago)")) | ||
option_parser.add_option('--until', default=now, type='int', | ||
help="Unix epoch time of the end of your requested interval (default: now)") | ||
option_parser.add_option('--json', default=False, action='store_true', | ||
help="Output results in JSON form") | ||
option_parser.add_option('--pretty', default=False, action='store_true', | ||
help="Show human-readable timestamps instead of unix times") | ||
|
||
(options, args) = option_parser.parse_args() | ||
|
||
if len(args) != 1: | ||
option_parser.print_usage() | ||
sys.exit(1) | ||
|
||
path = args[0] | ||
|
||
from_time = int( options._from ) | ||
until_time = int( options.until ) | ||
|
||
(timeInfo, values) = whisper.fetch(path, 1313585674, 1313672074) | ||
#(timeInfo, values) = whisper.fetch(path, from_time, until_time) | ||
|
||
(start,end,step) = timeInfo | ||
|
||
if options.json: | ||
values_json = str(values).replace('None','null') | ||
print '''{ | ||
"start" : %d, | ||
"end" : %d, | ||
"step" : %d, | ||
"values" : %s | ||
}''' % (start,end,step,values_json) | ||
sys.exit(0) | ||
|
||
t = start | ||
for value in values: | ||
if options.pretty: | ||
timestr = time.ctime(t) | ||
else: | ||
timestr = str(t) | ||
if value is None: | ||
valuestr = "None" | ||
else: | ||
valuestr = "%f" % value | ||
print "%s\t%s" % (timestr,valuestr) | ||
t += step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys, os | ||
import whisper | ||
from optparse import OptionParser | ||
|
||
option_parser = OptionParser(usage='''%prog path [field]''') | ||
(options, args) = option_parser.parse_args() | ||
|
||
if len(args) < 1: | ||
option_parser.print_usage() | ||
sys.exit(1) | ||
|
||
path = args[0] | ||
if len(args) > 1: | ||
field = args[1] | ||
else: | ||
field = None | ||
|
||
info = whisper.info(path) | ||
info['fileSize'] = os.stat(path).st_size | ||
|
||
if field: | ||
if field not in info: | ||
print 'Unknown field "%s". Valid fields are %s' % (field, ','.join(info)) | ||
sys.exit(1) | ||
|
||
print info[field] | ||
sys.exit(0) | ||
|
||
|
||
archives = info.pop('archives') | ||
for key,value in info.items(): | ||
print '%s: %s' % (key,value) | ||
|
||
for i,archive in enumerate(archives): | ||
print 'Archive %d' % i | ||
for key,value in archive.items(): | ||
print '%s: %s' % (key,value) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys, time | ||
import whisper | ||
from optparse import OptionParser | ||
|
||
now = int( time.time() ) | ||
|
||
option_parser = OptionParser( | ||
usage='''%prog [options] path timestamp:value [timestamp:value]*''') | ||
|
||
(options, args) = option_parser.parse_args() | ||
|
||
if len(args) < 2: | ||
option_parser.print_usage() | ||
sys.exit(1) | ||
|
||
path = args[0] | ||
datapoint_strings = args[1:] | ||
datapoint_strings = [point.replace('N:', '%d:' % now) | ||
for point in datapoint_strings] | ||
datapoints = [tuple(point.split(':')) for point in datapoint_strings] | ||
|
||
if len(datapoints) == 1: | ||
timestamp,value = datapoints[0] | ||
whisper.update(path, value, timestamp) | ||
else: | ||
print datapoints | ||
whisper.update_many(path, datapoints) |