Browse Source

date/time parsing, needs work

git-svn-id: https://bucket.mit.edu/svn/nilm/nilmdb@10685 ddd99763-3ecb-0310-9145-efcb8ce7c51f
tags/bxinterval-last
Jim Paris 12 years ago
parent
commit
d725ed1771
3 changed files with 19 additions and 6 deletions
  1. +16
    -5
      nilmdb/cmdline.py
  2. +1
    -1
      setup.cfg
  3. +2
    -0
      tests/test_cmdline.py

+ 16
- 5
nilmdb/cmdline.py View File

@@ -262,8 +262,9 @@ class Cmdline(object):
if not os.path.exists(filename):
self.die("Error opening input file %s\n", filename)
try:
# zcat is much faster than python's gzopen.
# We've checked that the file already exists
# zcat is much faster than python's gzopen. We've
# checked that the file existed, so this isn't too
# likely to fail
process = subprocess.Popen(["zcat", "-f", filename],
bufsize = -1,
stdin = open(os.devnull),
@@ -284,11 +285,18 @@ class Cmdline(object):
except KeyError:
self.die("Need to specify --rate\n")

# These will die if they can't parse
if self.args.start:
start = self.parse_time(self.args.start)
try:
start = self.parse_time(self.args.start)
except ValueError:
self.die("Error parsing start time '%s'\n",
self.args.start)
else:
start = self.parse_time(filename)
try:
start = self.parse_time(filename)
except ValueError:
self.die("Error extracting time from filename '%s'\n",
filename)

ts = nilmdb.timestamper.TimestamperRate(infile, start, rate)

@@ -298,3 +306,6 @@ class Cmdline(object):
print "Rate:", rate

self.die("not implemented")

def parse_time(self, time):
raise ValueError("go away")

+ 1
- 1
setup.cfg View File

@@ -10,7 +10,7 @@ cover-erase=
##cover-branches= # need nose 1.1.3 for this
stop=
verbosity=2
#tests=tests/test_cmdline.py
tests=tests/test_cmdline.py
#tests=tests/test_layout.py
#tests=tests/test_interval.py
#tests=tests/test_client.py


+ 2
- 0
tests/test_cmdline.py View File

@@ -241,6 +241,8 @@ class TestCmdline(object):
self.fail("insert /newton/prep baz qwer")
self.match("Error opening input file baz\n")

self.ok("insert /newton/prep")

#self.fail("insert /newton/nosuchpath")
#self.contain("No stream at path /newton/nosuchpath")



Loading…
Cancel
Save