Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Common modularization, custom emitters #112

wants to merge 2 commits into from

Conversation

charles-dyfis-net
Copy link
Contributor

  • 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

- 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
@clofresh
Copy link
Contributor

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?

@alq666
Copy link
Member

alq666 commented Jul 19, 2012

We use travis-ci for running a bunch of tests (.travis.yml should work as is if you plug in your repo)

@ghost ghost assigned alq666 Jul 20, 2012
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
Copy link
Member

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

Copy link
Member

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])

Copy link
Contributor Author

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.

@alq666
Copy link
Member

alq666 commented Jul 20, 2012

Merged in 2b7d6ea

@alq666 alq666 closed this Jul 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants