Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the skill directory and XDG_CONFIG_DIR for settings #2559

Merged
merged 1 commit into from May 15, 2020

Conversation

PureTryOut
Copy link
Contributor

Description

This makes the skills read their settings from either XDG_CONFIG_DIR or /etc/mycroft (if XDG_CONFIG_DIR is unset), and write to XDG_CONFIG_DIR. This however happens only if /opt/mycroft/skills/<skillname>/settings.json (the current default location) doesn't already exist, to make sure we don't break existing setups.

How to test

  1. Run mycroft-skills like before and verify if all skills still load correctly
  2. Quit the running process
  3. Move a settings.json from any skill to either ~/.config/mycroft/skills/<skillname>/settings.json or /etc/mycroft/skills/<skillname>/settings.json. For skill-pairing the skillname would be "PairingSkill" for example
  4. Run mycroft-skills again and verify if the affected skill still loads correctly and if it saves it settings to ~/.config/mycroft/skills/<skillname>/settings.json.

Contributor license agreement signed?

CLA [x]

@pep8speaks
Copy link

pep8speaks commented May 2, 2020

Hello @PureTryOut! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-15 09:51:19 UTC

@devs-mycroft devs-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label May 2, 2020
Copy link
Collaborator

@forslund forslund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked over it a bit and I'm not sure it will work as intended, but I can have misunderstood things

mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
for dir in BaseDirectory.load_config_paths('mycroft'):
path = dir + 'skills' + basename(self.root_dir)
#: If there is a settings file here, use it
if isdir(path):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On first start will this path actually exist? shouldn't it be created if the XDG_CONFIG_DIR is to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might not exist, but that shouldn't be a problem as afaik the skills currently start without settings as well on first start. At least on my system this works fine on first start without any settings anywhere.

When writing the settings we do make sure XDG_CONFIG_DIR exists though.

mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
mycroft/skills/settings.py Outdated Show resolved Hide resolved
mycroft/skills/settings.py Outdated Show resolved Hide resolved
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

1 similar comment
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

requirements.txt Outdated Show resolved Hide resolved
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

Copy link
Collaborator

@forslund forslund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be working exactly as intended.

I've tagged a bunch of minor comments. Could you explain to me how the ~.config/mycroft/skills/SKILL folder is created because I can't quite figure it out :)

Do we need to differentiate between settings read path and settings write path?

mycroft/skills/settings.py Show resolved Hide resolved
mycroft/skills/mycroft_skill/mycroft_skill.py Show resolved Hide resolved
mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
mycroft/skills/mycroft_skill/mycroft_skill.py Outdated Show resolved Hide resolved
@PureTryOut
Copy link
Contributor Author

Do we need to differentiate between settings read path and settings write path?

Yes. While you can read from /etc/xdg or /etc/mycroft, you should never write to them, that's where ~/.config is for.

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@forslund
Copy link
Collaborator

Think you might have rebased on top of master instead of dev, PR is now 10000 commits

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@PureTryOut
Copy link
Contributor Author

Ok why is the master branch still a thing if it's never used and updated? 🙈

Reset the branch and should be fixed now.

@PureTryOut PureTryOut changed the title Check the skill directory, XDG_CONFIG_DIR and /etc/mycroft for settings Check the skill directory and XDG_CONFIG_DIR for settings May 13, 2020
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@forslund
Copy link
Collaborator

It is used, it's the "stable" branch pointing to the latest release basically, but due to some initial script snafu's it has a bunch of extra commits (like 500k), but since it's a branch that's used no-one has wanted to drop it and re-create it.

@PureTryOut
Copy link
Contributor Author

How strange.

Anyhow, anything more I need to fix or change?

@forslund
Copy link
Collaborator

I think all looks good, gonna do a final test run on the Mark-1 hardware and then it should be merged.

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@forslund forslund merged commit d328eba into MycroftAI:dev May 15, 2020
@PureTryOut PureTryOut deleted the xdg branch May 15, 2020 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants