From a83ffb3dce791e0ff7ecae241a4bcfad582ec014 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 12 Oct 2015 18:19:28 +0800 Subject: [PATCH] protocols: move FlatFileDB into pyon --- artiq/frontend/artiq_compile.py | 2 +- artiq/protocols/file_db.py | 22 ---------------------- artiq/protocols/pyon.py | 20 ++++++++++++++++++++ artiq/test/hardware_testbench.py | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 artiq/protocols/file_db.py diff --git a/artiq/frontend/artiq_compile.py b/artiq/frontend/artiq_compile.py index c47360c51..a058a298a 100755 --- a/artiq/frontend/artiq_compile.py +++ b/artiq/frontend/artiq_compile.py @@ -3,7 +3,7 @@ import logging import argparse -from artiq.protocols.file_db import FlatFileDB +from artiq.protocols.pyon import FlatFileDB from artiq.master.worker_db import DeviceManager from artiq.tools import * diff --git a/artiq/protocols/file_db.py b/artiq/protocols/file_db.py deleted file mode 100644 index 8a0da9aa0..000000000 --- a/artiq/protocols/file_db.py +++ /dev/null @@ -1,22 +0,0 @@ -from artiq.protocols import pyon -from artiq.protocols.sync_struct import Notifier - - -class FlatFileDB: - def __init__(self, filename): - self.filename = filename - self.data = Notifier(pyon.load_file(self.filename)) - - def save(self): - pyon.store_file(self.filename, self.data.read) - - def get(self, key): - return self.data.read[key] - - def set(self, key, value): - self.data[key] = value - self.save() - - def delete(self, key): - del self.data[key] - self.save() diff --git a/artiq/protocols/pyon.py b/artiq/protocols/pyon.py index ff793945d..471025b43 100644 --- a/artiq/protocols/pyon.py +++ b/artiq/protocols/pyon.py @@ -187,3 +187,23 @@ def load_file(filename): """Parses the specified file and returns the decoded Python object.""" with open(filename, "r") as f: return decode(f.read()) + + +class FlatFileDB: + def __init__(self, filename): + self.filename = filename + self.data = pyon.load_file(self.filename) + + def save(self): + pyon.store_file(self.filename, self.data) + + def get(self, key): + return self.data[key] + + def set(self, key, value): + self.data[key] = value + self.save() + + def delete(self, key): + del self.data[key] + self.save() diff --git a/artiq/test/hardware_testbench.py b/artiq/test/hardware_testbench.py index 550e04371..cbb0dabe9 100644 --- a/artiq/test/hardware_testbench.py +++ b/artiq/test/hardware_testbench.py @@ -6,7 +6,7 @@ import unittest import logging from artiq.language import * -from artiq.protocols.file_db import FlatFileDB +from artiq.protocols.pyon import FlatFileDB from artiq.master.worker_db import DeviceManager, ResultDB from artiq.frontend.artiq_run import DummyScheduler