Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2313 from forslund/bugfix/uuid-pickup
Browse files Browse the repository at this point in the history
Apply skill uuid directly after reload from disk
  • Loading branch information
forslund committed Sep 18, 2019
2 parents 35bf4c8 + 09c0651 commit 11a52af
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions mycroft/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class InternetDown(RequestException):
pass


UUID = '{MYCROFT_UUID}'


class Api:
""" Generic class to wrap web APIs """
params_to_etag = {}
Expand All @@ -59,6 +62,8 @@ def __init__(self, path):

def request(self, params):
self.check_token()
if 'path' in params:
params['path'] = params['path'].replace(UUID, self.identity.uuid)
self.build_path(params)
self.old_params = copy(params)
return self.send(params)
Expand Down Expand Up @@ -266,7 +271,7 @@ def update_version(self):

return self.request({
"method": "PATCH",
"path": "/" + self.identity.uuid,
"path": "/" + UUID,
"json": {"coreVersion": version.get("coreVersion"),
"platform": platform,
"platform_build": platform_build,
Expand All @@ -276,21 +281,21 @@ def update_version(self):
def send_email(self, title, body, sender):
return self.request({
"method": "PUT",
"path": "/" + self.identity.uuid + "/message",
"path": "/" + UUID + "/message",
"json": {"title": title, "body": body, "sender": sender}
})

def report_metric(self, name, data):
return self.request({
"method": "POST",
"path": "/" + self.identity.uuid + "/metric/" + name,
"path": "/" + UUID + "/metric/" + name,
"json": data
})

def get(self):
""" Retrieve all device information from the web backend """
return self.request({
"path": "/" + self.identity.uuid
"path": "/" + UUID
})

def get_settings(self):
Expand All @@ -300,7 +305,7 @@ def get_settings(self):
str: JSON string with user configuration information.
"""
return self.request({
"path": "/" + self.identity.uuid + "/setting"
"path": "/" + UUID + "/setting"
})

def get_location(self):
Expand All @@ -310,7 +315,7 @@ def get_location(self):
str: JSON string with user location.
"""
return self.request({
"path": "/" + self.identity.uuid + "/location"
"path": "/" + UUID + "/location"
})

def get_subscription(self):
Expand All @@ -321,7 +326,7 @@ def get_subscription(self):
Returns: dictionary with subscription information
"""
return self.request({
'path': '/' + self.identity.uuid + '/subscription'})
'path': '/' + UUID + '/subscription'})

@property
def is_subscriber(self):
Expand All @@ -340,7 +345,7 @@ def get_subscriber_voice_url(self, voice=None):
archs = {'x86_64': 'x86_64', 'armv7l': 'arm', 'aarch64': 'arm'}
arch = archs.get(get_arch())
if arch:
path = '/' + self.identity.uuid + '/voice?arch=' + arch
path = '/' + UUID + '/voice?arch=' + arch
return self.request({'path': path})['link']

def get_oauth_token(self, dev_cred):
Expand All @@ -355,14 +360,14 @@ def get_oauth_token(self, dev_cred):
"""
return self.request({
"method": "GET",
"path": "/" + self.identity.uuid + "/token/" + str(dev_cred)
"path": "/" + UUID + "/token/" + str(dev_cred)
})

def get_skill_settings(self):
"""Get the remote skill settings for all skills on this device."""
return self.request({
"method": "GET",
"path": "/" + self.identity.uuid + "/skill/settings",
"path": "/" + UUID + "/skill/settings",
})

def upload_skill_metadata(self, settings_meta):
Expand All @@ -373,7 +378,7 @@ def upload_skill_metadata(self, settings_meta):
"""
return self.request({
"method": "PUT",
"path": "/" + self.identity.uuid + "/settingsMeta",
"path": "/" + UUID + "/settingsMeta",
"json": settings_meta
})

Expand Down Expand Up @@ -414,7 +419,7 @@ def upload_skills_data(self, data):

self.request({
"method": "PUT",
"path": "/" + self.identity.uuid + "/skillJson",
"path": "/" + UUID + "/skillJson",
"json": to_send
})

Expand Down

0 comments on commit 11a52af

Please sign in to comment.