Guest User

Untitled

a guest
Jan 3rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. def _checkStoreConnectivity(self):
  2. """ check for connectivity to the snap store to install snaps"""
  3. res = False
  4. snap_env = os.environ.copy()
  5. snap_env["LANG"] = "C.UTF-8"
  6. connected = Popen(["snap", "debug", "connectivity"], stdout=PIPE,
  7. stderr=PIPE, env=snap_env,
  8. universal_newlines=True).communicate()
  9. if re.search("^ \* PASS", connected[0], re.MULTILINE):
  10. return
  11. # can't connect
  12. elif re.search("^ \*.*unreachable", connected[0], re.MULTILINE):
  13. logging.error("No snap store connectivity")
  14. res = self._view.askYesNoQuestion(
  15. _("Connection to Snap Store failed"),
  16. _("Your system does not have a connection to the Snap "
  17. "Store. For the best upgrade experience make sure "
  18. "that your system can connect to api.snapcraft.io.\n"
  19. "Do you still want to continue with the upgrade?")
  20. )
  21. # debug command not available
  22. elif 'error: unknown command' in connected[1]:
  23. logging.error("snap debug command not available")
  24. res = self._view.askYesNoQuestion(
  25. _("Outdated snapd package"),
  26. _("Your system does not have the latest version of snapd. "
  27. "Please update the version of snapd on your system to "
  28. "improve the upgrade experience.\n"
  29. "Do you still want to continue with the upgrade?")
  30. )
  31. # not running as root
  32. elif 'error: access denied' in connected[1]:
  33. res = False
  34. logging.error("Not running as root!")
  35. if not res:
  36. self.controller.abort()
Advertisement
Add Comment
Please, Sign In to add comment