Skip to content

Commit

Permalink
Prepare for third-party modules
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastProject committed Mar 22, 2017
1 parent 1462735 commit 9968043
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added
- Documentation
- Repository for third-party modules

### Changed
- Give more information upon installing modules and warn the user that they are code
Expand Down
25 changes: 24 additions & 1 deletion pext/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import atexit
import collections
import configparser
import getopt
import json
Expand Down Expand Up @@ -1157,7 +1158,25 @@ def _menu_list_modules(self) -> None:
self, "Pext", '\n'.join(['Installed modules:'] + sorted(module_list)))

def _menu_install_module_from_repository(self) -> None:
url = "https://pext.hackerchick.me/modules.json"
modules_sources_source = collections.OrderedDict((
("Pext team", "https://pext.hackerchick.me/modules.json"),
("Other developers", "https://pext.hackerchick.me/third_party_modules.json"),
))

modules_sources = collections.OrderedDict(("{} ({})".format(module[0], module[1]), module[1]) for module in modules_sources_source.items())

if len(modules_sources) > 1:
modules_source, ok = QInputDialog.getItem(
self, "Pext", "Where do you want to get modules from?",
modules_sources.keys(), 0, False)

if not ok:
return
else:
modules_source = list(modules_sources)[0]

url = modules_sources[modules_source]

try:
response = urlopen(url)
except URLError:
Expand Down Expand Up @@ -1189,6 +1208,10 @@ def _menu_install_module_from_repository(self) -> None:
traceback.print_exc()
return

if len(modules) == 0:
QMessageBox.information(self, "Pext", "No modules found from source {}.".format(modules_source))
return

module_info, ok = QInputDialog.getItem(
self, "Pext", "Choose the module to install",
sorted(module_list.keys()), 0, False)
Expand Down

0 comments on commit 9968043

Please sign in to comment.