-
Notifications
You must be signed in to change notification settings - Fork 813
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
Common modularization, custom emitters #112
Common modularization, custom emitters #112
Conversation
- Move module-loading logic into single location - Allow multiple emitters to be attached to an agent - Add and document config-file syntax for specifying custom emitters - Allow Python modules to be specified by full filename, rather than leveraging PYTHONPATH
Sweet, I like having a common implementation for loading modules. Could you add a test that tests loading a module by name and by filename? |
We use travis-ci for running a bunch of tests (.travis.yml should work as is if you plug in your repo) |
emitter = http_emitter | ||
emitters = [http_emitter] | ||
for emitter_spec in [s.strip() for s in agentConfig.get('custom_emitters', '').split(',')]: | ||
if len(s) == 0: continue |
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.
@charles-dyfis-net not sure I get this line. Did you mean?
if len(emitter_spec) == 0: continue
My little test
agentConfig = {'custom_emitters': "2,3 , 4 ,,,,," }
print agentConfig.get('custom_emitters')
emitters = [1]
print [s.strip() for s in agentConfig.get('custom_emitters', '').split(',')]
for emitter_spec in [s.strip() for s in agentConfig.get('custom_emitters', '').split(',')]:
if len(emitter_spec) == 0: continue
emitters.append(emitter_spec)
print emitters
gets me [1, '2', '3', '4']
whereas with len(s) == 0
I only get [1]
.
Did I get this right?
Interestingly enough:
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for x in [s for s in [1, 2, 3]]:
... print x, s
...
1 3
2 3
3 3
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.
We might want to go listcomp all the way and replace the for loop + if test.
emitters.extend([s.strip() for s in agentConfig.get('custom_emitters', '').split(',') if len(s.strip()) > 0])
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.
Good catch, thanks!
As for the condensed version, that's what I would have done if it didn't mean calling strip()
twice.
Merged in 2b7d6ea |
leveraging
PYTHONPATH