Currently, I can only see .yaml the file inside the snap directory even after creating the snap.
is this normal behavior or some other files should also be generated?
is that possible for you to provide a link to some resources or minimum example of storing user inputs and then using those configs later inside the snap?
When you built your snap, you should have ended up with a package with the file extension .snap. You can see the contents of the package by running unsquashfs -l filename.snap. This is what you will see at /snap/olibox-core/current when you install it. Nothing else in your repository will be available on the user’s system.
Judging by those errors, you’re trying to build against Python 3.5 again, which does not support f-strings. Are you still building against core18?
It also looks like a lot of your code is searching for configuration files relative to the current working directory still. So again: I suggest using the environment variables snapd makes available to you to decide where to put your configuration files.
yes, I’m using base: core18. This is the .yaml file:
name: olibox-core
base: core18
version: '0.1dev'
summary: Core functionality for Oli box
description: |
Olibox_core module provides the basic functionality
to wrtie data from IR sensor and REST API to json files
and publish this data to mqtt broker.
This utility is particularly useful for Oli box.
base: core
grade: devel
confinement: devmode
parts:
olibox-core:
source: https://github.com/olisystems/olibox_core.git
source-tag: 0.1dev
plugin: python
source: .
requirements: ['requirements.txt']
apps:
olibox-core:
command: bin/olibox-core
do I need to move config.toml file to some directory?
or do I need to make some changes to .yaml file to achieve this?
looking again, you also have two base: entries, drop the one pointing to “core” you can really only have one (and i guess snspcraft just picked the second one and defaulted to core instead of core18)
I’m stupid.
I created a new repo (https://github.com/m-yahya/snap-tutorial.git) and dropping the extra core seems working.
So, at this moment I can read the config file.
I’ll open another topic to describe what I wanted to achieve at the end.
Thank you all for your precious time and help, very much appreciated.
can you please say a few words about file path, how they are determine?
do I need to specify file path relative to modules or file path should be relative to home directory?
for example with the following app structure:
if config.toml is copied into the root of your snap (either look inside the snap by unsquashing it, or use the snapcraft --debug feature to inspect the prime/ dir inside the builds (which is identical to the structure inside the snap) … you’d access it by using something like os.environ['SNAP'] to read the toplevel path of the snap from the environment.
but assuming your config file should actually be configurable ($SNAP is the readonly bit of your snap) you probably want to use a configure or install hook to copy it to $SNAP_DATA (which corresponds to /var/snap/<snapname>/current/ (needs root, due to being in /var)) or SNAP_USER_DATA (i.e.: ~/snap/<snapname>/current/)