8000 Easier extendablity with custom commands. by yggdr · Pull Request #133 · aio-libs/aiomonitor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Easier extendablity with custom commands. #133

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

Merged
merged 3 commits into from
Aug 31, 2018

Conversation

yggdr
Copy link
Contributor
@yggdr yggdr commented Aug 25, 2018

This adds the ability for the user to add custom commands to a Monitor subclass, inspired by the standard library module "Cmd".

yggdr added 2 commits August 25, 2018 23:21
This adds customisability via subclassing to the Monitor. The standard
library module Cmd was a loose reference point when it comes to the
interface.

+ small fixes here and there.
@codecov
Copy link
codecov bot commented Aug 25, 2018

Codecov Report

Merging #133 into master will decrease coverage by 0.82%.
The diff coverage is 92.63%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #133      +/-   ##
========================================
- Coverage   92.82%    92%   -0.83%     
========================================
  Files           4      4              
  Lines         251    300      +49     
  Branches       32     39       +7     
========================================
+ Hits          233    276      +43     
- Misses         11     16       +5     
- Partials        7      8       +1
Impacted Files Coverage Δ
aiomonitor/utils.py 95.18% <100%> (+0.37%) ⬆️
aiomonitor/monitor.py 90.47% <92.04%> (-1.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cb1d8e...a1d9957. Read the comment docs.

@jettify
Copy link
Member
jettify commented Aug 27, 2018

You mean https://docs.python.org/3/library/cmd.html this one? I did not know that such thing even exists :)

@jettify
Copy link
Member
jettify commented Aug 27, 2018

Sorry for delay, I will PR more closely in few days.

@@ -94,20 +108,29 @@ def test_basic_monitor(monitor, tn_client, loop):
assert 'Task' in resp

resp = execute(tn, 'ps 123\n')
assert 'Task' in resp
assert 'TypeError' in resp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on this one? Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the new code for looking up the method to execute will take the method (do_ps in this example) and give it any arguments supplied by the user (123). The TypeError is simply the error that Python raises when you give an incorrect amount of arguments to a function.

I am currently working on implementing more of the public interface of Cmd where this will picked up.


resp = execute(tn, 'signal name\n')
assert 'Unknown signal name' in resp

resp = execute(tn, 'stacktrace\n')
assert 'loop.run_forever()' in resp

resp = execute(tn, 'wehere 123\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ why this event worked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it worked in the past you mean? Because with the old code any command beginning with a "w" would be routed to "where".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, stupid error on my side :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did take me a while to realise what was going on as well :D

@yggdr
Copy link
Contributor Author
yggdr commented Aug 27, 2018

@jettify Yes, that's the standard library cmd module. I thought it useful to try and adhere to its API while making aiomonitor more extensible. If you have any comments about the direction this is taking, I'm listening :)

Building on this PR I'm working on adding more of the Cmd-API (like precmd, postcmd) to aiomonitor.

@jettify
Copy link
Member
jettify commented Aug 27, 2018

I like your idea and implementation (thanks for updating docs and example!), give me few days to reread PR more carefully.

Copy link
Member
@jettify jettify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@jettify jettify merged commit 569c095 into aio-libs:master Aug 31, 2018
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.

2 participants
0