-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
v0.8.3 bug fix: ping endpoint #59
Conversation
1.get host from endpoint 2.ping host
v0.8.3 bug fix: ping endpoint
1.get host from endpoint 2.ping host
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.
Thanks for your great issue to solve ping problem with endpoint, Please refer to this issue: wechaty/python-wechaty#233
src/wechaty_puppet_service/puppet.py
Outdated
@@ -898,7 +898,12 @@ def _init_puppet(self): | |||
log.debug('get puppet ip address : <%s>', data) | |||
self.options.end_point = '{ip}:{port}'.format(**data) | |||
|
|||
if ping(self.options.end_point) is False: | |||
if ':' not in self.options.end_point: |
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.
:
is not required for the valid endpoint which can be the service name or url. Eg: wechaty-service
in docker network or http://api.wechaty-service.com
.
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 got it
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 can make a rule:
WECHATY_PUPPET_SERVICE_ENDPOINT
must be written as {Host/Domain Name}:{port}
if use default port, we must write it. Eg: for http
, we use 80
, for https
, we use 443
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 must follow the identical rules when we write the WECHATY_PUPPET_SERVICE_ENDPOINT
, otherwise there will be many cases that we can't deal with.
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 believe there must be some bugs in ping code. but port is not required in ping
function. Can you reproduce your problem? And can you fix it after add port support ?
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, you mean that it needs telnet
.
socket is a good way, now i'm looking for the methods about socket
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.
Great, looking forward for your latest commit. You can encapsulate it into utils.py
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.
There are some developers waiting for this pr, please complete the development and testing of this feature as soon as possible. Many thanks for your sharing and understanding.
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.
ok, i will make it soon
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 did a simple local test, no problem. please review my code.
1.ping port 2.if not port, ping host
v0.8.3 bug fix2: test endpoint
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 fix linting to keep the code quality. Thanks please.
src/wechaty_puppet_service/utils.py
Outdated
def test_endpoint(end_point: str) -> float: | ||
""" | ||
test_endpoint: | ||
1.If there is port: telnet | ||
2.If there is host/domain: ping or | ||
""" | ||
tn = Telnet() | ||
host, port = extract_host_and_port(end_point) | ||
if port is None: | ||
return ping(host) | ||
else: | ||
try: | ||
tn.open(host, port=port) | ||
except Exception: | ||
return False | ||
return True |
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.
Your return data type is Wrong:
You define the return type is float
, but you return float/bool data type. This code will not pass CI testing.
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.
no, there are 2 pylint errors:
1./puppet.py:37:0: W0611: Unused ping imported from ping3 (unused-import)
2./utils.py:55:4: R1705: Unnecessary "else" after "return" (no-else-return)
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 just fix these pylint errors, let it run CI test.
1.pylint bug fix
pylint bug fix
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.
1
1 |
??? Your CI testing is down. |
oh no, there are 2 other pylint errors: |
This is the general linting error, I believe you can fix it. Go ahead. |
1.pylint bug fix2
pylint fix2
Yes, I will try again. |
|
1.pylint bug fix3
pylint3
i try it again, then i will install pylint and do some local testing. i'm sorry to have incommoded you for my pylint |
1.ping type ignore
yes, pylint passed! i add |
ping type ignore
Awesome, the last step: bump the version in |
v0.8.4 version
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.
LGTM
Link to wechaty/PMC#16 |
yeah, i make it done. last, |
If you wish, you can continue to participate in the python-wechaty project development, issue processing and documentation improvements. Welcome to become contrbutor of python-wechaty 🎉 🎉 🎉 |
Yes, I think I will do it better |
Thank you very much for your contribution! You are welcome to join Wechaty Contributor Program1. Join Wechaty Organization
I have invited you to join our Wechaty GitHub Organization, please accept it by following the above message. (See also: wechaty/PMC#16) 2. Update Your Wechaty Contributor Profile
3. Join The Contributor Only WeChat RoomWe also have a WeChat room for contributors only which can discuss Wechaty at a deeper level, you are welcome to join and if you are interested. Please add @lijiarui wechat: ruirui_0914 and send her this pr link. She will invite you into Wechaty Contributor Room Cheers! |
v0.8.3 bug fix: ping endpoint
1.get host from endpoint
2.ping host
3.pylint