Unverified Commit 800066c0 authored by Dan Jones's avatar Dan Jones
Browse files

fix: create data path and default client

The code was catching a FileNotFoundError and trying
to create the empty file but wasn't creating the
data directory before trying to save into it.

Rather than starting with 0 clients it now creates
a default "admin" client so that when you start the
app you always have something.

We need to think about how to provide these credentials
back to the user. Normally you save the response from
the post to /client. You can just read the file.

The admin client is set to receive all messages.
It may be better to set it to receive nothing so that
if the default client is not implemented the queues don't
fill up.
2 merge requests!23Resolve "Release v0.1.0",!15Resolve "Fix error running without any clients defined"
Pipeline #108036 failed with stages
in 23 seconds
...@@ -34,7 +34,13 @@ class ClientModel: ...@@ -34,7 +34,13 @@ class ClientModel:
self.clients = json.load(client_file) self.clients = json.load(client_file)
self.mtime = mtime self.mtime = mtime
except FileNotFoundError as error: except FileNotFoundError as error:
os.makedirs('data', exist_ok=True)
self.clients = {} self.clients = {}
self.add({
'client_id': 'admin',
'client_name': 'Default Admin Client',
'subscription': '#'
})
self.save() self.save()
self.mtime = os.path.getmtime(self.file) self.mtime = os.path.getmtime(self.file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment