Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ed0a7632d9ad
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ed00ca148570
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Aug 18, 2015

  1. Copy the full SHA
    2275017 View commit details
  2. influxdb: use types

    sbourdeauducq committed Aug 18, 2015
    Copy the full SHA
    2ac8c53 View commit details
  3. Copy the full SHA
    ed00ca1 View commit details
Showing with 29 additions and 9 deletions.
  1. +29 −9 artiq/frontend/artiq_influxdb.py
38 changes: 29 additions & 9 deletions artiq/frontend/artiq_influxdb.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import fnmatch
from functools import partial

import numpy as np
import aiohttp

from artiq.tools import verbosity_args, init_logger
@@ -91,24 +92,43 @@ def _do(self):
k, exc_info=True)
else:
if response.status not in (200, 204):
logger.warning("got HTTP status %d trying to update '%s'",
response.status, k)
content = (yield from response.content.read()).decode()
if content:
content = content[:-1] # drop \n
logger.warning("got HTTP status %d "
"trying to update '%s': %s",
response.status, k, content)
response.close()


def format_influxdb(v):
if isinstance(v, bool):
if v:
return "t"
else:
return "f"
elif np.issubdtype(type(v), int):
return "{}i".format(v)
elif np.issubdtype(type(v), float):
return "{}".format(v)
elif isinstance(v, str):
return '"' + v.replace('"', '\\"') + '"'
else:
return None


class Parameters:
def __init__(self, filter_function, writer, init):
self.filter_function = filter_function
self.writer = writer

def __setitem__(self, k, v):
try:
v = float(v)
except:
pass
else:
if self.filter_function(k):
self.writer.update(k, v)
v_db = format_influxdb(v)
if v_db is not None and self.filter_function(k):
self.writer.update(k, v_db)

def __delitem__(self, k):
pass


class MasterReader(TaskObject):