forked from M-Labs/artiq
protocols: move FlatFileDB into pyon
This commit is contained in:
parent
22bffa98b5
commit
a83ffb3dce
|
@ -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 *
|
||||
|
||||
|
|
|
@ -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()
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue