Beispiel #1
0
 def test_samplers(self):
     """Test a client with samplers"""
     client = Client([os.path.join(tests_dir, "projects/samplers/dataplicity.conf")], create_m2m=False)
     client.samplers.sample_now("test", 101)
     sampler = client.samplers.get_sampler("test")
     for t, v in sampler.snapshot_samples():
         self.assertEqual(v, 101)
     client.close()
Beispiel #2
0
 def test_timeline(self):
     """Test a client with a timeline"""
     TEXT = "Explicit is better than implicit."
     client = Client([os.path.join(tests_dir, "projects/timeline/dataplicity.conf")], create_m2m=False)
     timeline = client.timelines.get_timeline("cam")
     timeline.clear_all()
     event = timeline.new_event("TEXT", timestamp=100000, text=TEXT)
     event.write()
     events = timeline.get_events()
     self.assertEqual(len(events), 1)
     self.assertEqual(events[0]["text"], TEXT)
     client.close()
Beispiel #3
0
 def make_client(self, log):
     if self.args.conf:
         path = self.args.conf
     path = tools.find_conf()
     if path is None:
         raise ProjectNotFoundError(
             'unable to locate dataplicity.conf for project')
     client = Client(path, log=log)
     return client
Beispiel #4
0
    def __init__(self, conf_path=None, foreground=False, debug=False):
        self.conf_path = conf_path
        self.foreground = foreground
        self.debug = debug

        self.log = logging.getLogger('dataplicity')

        client = self.client = Client(conf_path,
                                      check_firmware=not foreground,
                                      log=self.log)
        conf = client.conf

        self.poll_rate_seconds = conf.get_float("daemon", "poll", 60.0)
        self.last_check_time = None
        self.pid_path = abspath(
            conf.get('daemon', 'pidfile', '/var/run/dataplicity.pid'))
        self.pipe_path = abspath(
            conf.get('daemon', 'pipe', '/tmp/dataplicitypipe'))

        self.server_closing_event = Event()

        # Command to execute with the daemon exits
        self.exit_command = None
        self.exit_event = Event()
Beispiel #5
0
 def test_create(self):
     """Test creating a client"""
     client = Client([os.path.join(tests_dir, "projects/simple/dataplicity.conf")], create_m2m=False)
     client.close()