-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Modules installer #174
base: master
Are you sure you want to change the base?
Modules installer #174
Conversation
635b014
to
cceaf05
Compare
I didn't have the time to take a closer look yet, but I already have to nag (silly me 😜 ): Please do not use the minus sign ( I'd suggest...uhmmm..... |
cceaf05
to
8070250
Compare
Ok, I changed the name to the module. |
@Holzhaus @crm416 @shbhrsaha were you able to take a look at this? What do you think? |
8070250
to
b77648c
Compare
IMHO we can add sth like this to Jasper, but we can also wait for v2. Depending in what @crm416 and @shbhrsaha say, we can either start testing for v1 or we change the code to play nice with v2's Plugin system and postpone merging. |
@@ -43,10 +43,10 @@ def get_modules(cls): | |||
""" | |||
|
|||
module_locations = [jasperpath.PLUGIN_PATH] | |||
module_names = [name for loader, name, ispkg in pkgutil.iter_modules(module_locations)] | |||
module_names = [name for loader, name, ispkg in pkgutil.walk_packages(module_locations, prefix='modules.')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of a separate PR and can be merged regardless of the plugin installer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it could. But it was necessary for this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make a new PR containing just the changes to brain.py
and I'll merge it today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I think when v2 comes out, with it's plugin system, the module site will still be pretty much the same (downloading the code from a location, and setting it up in a directory). So the plugin installing would remain the same, the only change would be the code inside of those plugins |
Yes, but the site would contain a lot of v2 incompatible plugins. |
print "Installed module: %s" % self.module | ||
|
||
def create_module_folder(self): | ||
self.module_path = os.path.abspath('modules/'+self.module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use jasperpath.PLUGIN_PATH
. This won't work it's executed from outside the client folder, e.g:
cd /
/home/pi/jasper/client/modinstaller.py --install foo
In this case, it will try to create /modules/foo
(in the root fs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
os.makedirs(self.module_path) | ||
open(os.path.join(self.module_path, '__init__.py'), 'a').close() | ||
|
||
def get_module_metadata(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method name is very misleading. It does not return metadata but checks if a plugin of this name existis in the remote repository. Therefore it should be renamed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I made then two methods, one to get the metadata and another to check if the metadata exists.
60cfedf
to
9d43499
Compare
7e6e780
to
e047a15
Compare
Will do my best to read through this today... Sorry for the delay. |
Don't have a ton of comments on the actual code, but I'd be fine with merging this in the near future. Seems reasonably useful. However, it's going to need some documentation. For example, it wasn't clear to me that you have to the Git route if your module has dependencies (i.e., because you need to include a folder with a Additionally, why do you need to give the site full access to your GitHub "personal user data"? |
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Jasper modules installer') | ||
parser.add_argument('--install', nargs=1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is nargs=1
if we give the Modules to install
description? Shouldn't it be nargs='+'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I took some ideas from the code you wrote, and examples for the comments you added to the PR. |
self.module = module | ||
|
||
def __str__(self): | ||
return self.message + ": " + self.module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use one of these syntaxes:
"%s: %s" % (self.message, self.module)
# or
"{message}: {module}".format(message=self.message, module=self.module)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Nice. PS: I hope I didn't appear rough or something, but in case, I just wanted to say: Sorry, I didn't mean it. Text-only communication can be a bit ambiguous sometimes. |
@Holzhaus No worries. I know it's hard to communicate things using text-only, and I suppose the same counts for me (so, sorry if I offended/annoyed you in any way). Anyways, thanks for that message. |
@Holzhaus do you think this is ready to be merged? |
finally: | ||
shutil.rmtree(temp_path) | ||
else: | ||
raise ModuleInstallationError("Module not found", module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather do something like:
raise ModuleInstallationError("Module '%s' not found" % module)
and then replace the custom ModuleInstallationError
with this:
class ModuleInstallationError(Exception):
pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this way, you'll have to interpolate the name of the module everywhere, and there is no requirement of a module name when instantiating the class. Wouldn't you think that, as the Error pertains a module, that the module is part of the parameters of the object being instantiated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, You know the module name anyway, because you call the install()
function with this argument. And IMHO, the module name should be part of it's message.
Also, the current implementation overrides the __init__()
method, but does not call the superclass' __init__()
, which should not happen.
Sorry, some more comments, but hopefully can merge soon. |
Changes Unknown when pulling da72882 on alexsiri7:installer into * on jasperproject:master*. |
I get the following error if I use AT&T STT. I have already copied the APP_KEY, Secret_key from site (Basic free access). INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.att.com Do I need to upgrade to premium account so to get STT access or there is something wrong with code/keys? |
This is a simple modules installer (can't handle multiple files, or requirements yet)
It connects to http://jaspermoduleshub.herokuapp.com/
I added a
walk_packages
onbrain.py
so that modules can be installed in subfolders.