Skip to content

Commit

Permalink
Fix monitor with latest parameter changes (microsoft#848)
Browse files Browse the repository at this point in the history
_latest is no longer a function so make sure we do a deep copy rather than modify the dict

Also only try to convert time tuple if this is actually a datetime object
  • Loading branch information
jenshnielsen authored and WilliamHPNielsen committed Nov 3, 2017
1 parent cb60e46 commit f1c01bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qcodes/monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import http.server
import socketserver
import webbrowser
import datetime
from copy import deepcopy

from threading import Thread
from typing import Dict
Expand All @@ -43,12 +45,12 @@ def _get_metadata(*parameters) -> Dict[float, list]:
for parameter in parameters:
_meta = getattr(parameter, "_latest", None)
if _meta:
meta = _meta()
meta = deepcopy(_meta)
else:
raise ValueError("Input is not a parameter; Refusing to proceed")
# convert to string
meta['value'] = str(meta['value'])
if meta["ts"] is not None:
if isinstance(meta["ts"], datetime.datetime):
meta["ts"] = time.mktime(meta["ts"].timetuple())
meta["name"] = parameter.label or parameter.name
meta["unit"] = parameter.unit
Expand Down

0 comments on commit f1c01bd

Please sign in to comment.