Skip to content

Commit

Permalink
rename installed to downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Apr 13, 2018
1 parent 3bc9101 commit 4faa1d2
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def skills_config(self):
return self._skills_config or Configuration.get().get("skills", {"directory": '/opt/mycroft/skills'})

@property
def installed_skills(self):
def downloaded_skills(self):
skills = []
for skill in self.skills:
if self.skills[skill].get("installed"):
if self.skills[skill].get("downloaded"):
skills.append(skill)
return skills

Expand Down Expand Up @@ -134,8 +134,8 @@ def prepare_msm(self):
# TODO permissions stuff

def scan_skills_folder(self):
""" scan installed skills """
LOG.info("scanning installed skills")
""" scan downloaded skills """
LOG.info("scanning downloaded skills")
skills = []
if exists(self.skills_dir):
# checking skills dir and getting all skills there
Expand Down Expand Up @@ -195,7 +195,7 @@ def read_skill_folder(self, skill_folder):
self.skills[skill_folder]["name"] = skill_folder
self.skills[skill_folder]["repo"] = git_url
self.skills[skill_folder]["author"] = author
self.skills[skill_folder]["installed"] = True
self.skills[skill_folder]["downloaded"] = True
return True

def install_defaults(self):
Expand Down Expand Up @@ -231,7 +231,7 @@ def install_by_url(self, url):
# TODO get error codes from installing requirements
self.run_requirements_sh(skill_folder)
self.run_pip(skill_folder)
self.skills[skill_folder]["installed"] = True
self.skills[skill_folder]["downloaded"] = True
self.send_message("msm.install.succeeded", data)
except Exception as e:
data["error"] = e
Expand All @@ -253,11 +253,11 @@ def install_by_name(self, name):
return False

def update_skills(self):
""" update all installed skills """
LOG.info("updating installed skills")
""" update all downloaded skills """
LOG.info("updating downloaded skills")
self.send_message("msm.updating")
for skill in self.skills:
if self.skills[skill]["installed"]:
if self.skills[skill]["downloaded"]:
# TODO check if user modified before updating
LOG.info("updating " + skill)
self.install_by_url(self.skills[skill]["repo"])
Expand All @@ -272,14 +272,14 @@ def remove_by_url(self, url):
for skill in self.skills:
if url == self.skills[skill]["repo"]:
LOG.info("found skill!")
if self.skills[skill]["installed"]:
if self.skills[skill]["downloaded"]:
remove(data["path"])
self.send_message("msm.remove.succeeded", data)
self.send_message("msm.removed", data)
return True
else:
LOG.warning("skill not installed!")
data["error"] = "skill not installed"
LOG.warning("skill not downloaded!")
data["error"] = "skill not downloaded"
self.send_message("msm.remove.failed", data)
self.send_message("msm.removed", data)
else:
Expand All @@ -296,12 +296,12 @@ def remove_by_name(self, name):
if skill_folder:
data = self.skills[skill_folder]
self.send_message("msm.removing", data)
installed = self.skills[skill_folder]["installed"]
self.skills[skill_folder]["installed"] = False
if not installed:
LOG.warning("skill is not installed!")
downloaded = self.skills[skill_folder]["downloaded"]
self.skills[skill_folder]["downloaded"] = False
if not downloaded:
LOG.warning("skill is not downloaded!")
# TODO error code
data["error"] = "skill not installed"
data["error"] = "skill not downloaded"
self.send_message("msm.remove.failed", data)
else:
remove(self.skills[skill_folder]["path"])
Expand All @@ -319,7 +319,7 @@ def remove_by_name(self, name):
return False

def list_skills(self):
""" list all mycroft-skills in the skills repo and installed """
""" list all mycroft-skills in the skills repo and downloaded """
# scan skills folder
self.scan_skills_folder()
# scan skills repo
Expand All @@ -340,8 +340,8 @@ def url_info(self, url):
skill_path = join(self.skills_dir, skill_folder)
skill_id = hash(skill_path)
skill_author = url.split("/")[-2]
installed = skill_folder in self.installed_skills
return {"repo": url, "folder": skill_folder, "path": skill_path, "id": skill_id, "author": skill_author, "name": name, "installed": installed}
downloaded = skill_folder in self.downloaded_skills
return {"repo": url, "folder": skill_folder, "path": skill_path, "id": skill_id, "author": skill_author, "name": name, "downloaded": downloaded}

def name_info(self, name):
""" shows information about the skill matching <name> """
Expand Down Expand Up @@ -432,8 +432,8 @@ def remove_from_priority_list(self, skill_name):
skill_folder = skill_name
else:
data = self.skills[skill_folder]
if not data["installed"]:
LOG.debug("removing skill from priority list, but it is not installed")
if not data["downloaded"]:
LOG.debug("removing skill from priority list, but it is not downloaded")

config = self.skills_config
if "priority_skills" not in config:
Expand All @@ -456,8 +456,8 @@ def add_to_priority_list(self, skill_name):
skill_folder = skill_name
else:
data = self.skills[skill_folder]
if not data["installed"]:
LOG.debug("Adding skill to priority list, but it is not installed")
if not data["downloaded"]:
LOG.debug("Adding skill to priority list, but it is not downloaded")

config = self.skills_config
if "priority_skills" not in config:
Expand All @@ -479,8 +479,8 @@ def remove_from_blacklist(self, skill_name):
skill_folder = skill_name
else:
data = self.skills[skill_folder]
if not data["installed"]:
LOG.debug("Whitelisting skill, but it is not installed")
if not data["downloaded"]:
LOG.debug("Whitelisting skill, but it is not downloaded")

config = self.skills_config
if "blacklisted_skills" not in config:
Expand All @@ -504,8 +504,8 @@ def add_to_blacklist(self, skill_name):
skill_folder = skill_name
else:
data = self.skills[skill_folder]
if not data["installed"]:
LOG.debug("Blacklisting skill, but it is not installed")
if not data["downloaded"]:
LOG.debug("Blacklisting skill, but it is not downloaded")

config = self.skills_config
if "blacklisted_skills" not in config:
Expand Down Expand Up @@ -637,11 +637,11 @@ def scan_skills_repo(self):
skill_path = join(self.skills_dir, skill_folder)
skill_id = hash(skill_path)
skill_author = url.split("/")[-2]
installed = False
if skill_folder in self.installed_skills:
installed = True
downloaded = False
if skill_folder in self.downloaded_skills:
downloaded = True
self.skills[skill_folder] = {"repo": url, "folder": skill_folder, "path": skill_path, "id": skill_id,
"author": skill_author, "name": name, "installed": installed}
"author": skill_author, "name": name, "downloaded": downloaded}

LOG.info("scanned " + platform + ": " + str(skills))
return scanned
Expand Down

0 comments on commit 4faa1d2

Please sign in to comment.