-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Refactored code and added some exceptions avogadro-remote.py #406
Conversation
Functionalities/changes required: [x]2. Error detection in init if the socket cannot be created. [ ]3. Merge the current send_message and receive_message methods (which handle the low-level interaction with the connection) into the _json methods. [ ]4. Create new "high level" send_message(method, params = {}) method which formats the JSON template to minimize code duplication: |
Also if you can help me with the functions loadMolecule and exportFile will do, so that I can implement them @ghutchis |
I thought I was pretty clear in my other commends:
I don't care as much about all the methods as far as points 3, 4 and the general code scanning comments from Codacy. (Let me know if you don't see them on the pull request) |
There are few codacy comments but they are outdated, I think I am not able to see the latest ones |
a0a6cc1
to
c01367e
Compare
@ghutchis I have done the final refactoring from my side, latest codacy comments are not visible |
To be fair, I didn't write the original code. But It's not used because those particular methods are one-way .. send something to the app and not receive anything in return. Some time-intensive things (e.g., "render a molecular surface .. tell me when you're done") need both a send and a receive component:
I do think the size for the receive_message is really small (1024 bytes). It should probably be something like 16384 or 32768 to be sure larger messages can be sent. |
was this script used to run previously? |
The script works. You have to run the Avogadro app - it will create the socket when running. |
When I corrected UNIX it throws
Please help me with this Also which OS are you using? |
I use Mac and Linux. A local socket is also known as a named pipe - it's a temporary file buffer used for inter-process communication. You don't want a port. https://wiki.wireshark.org/CaptureSetup/Pipes#way-3-python-on-windows Looking around I think you can try something like this on Windows: As per: |
My understanding was that the interprocess communication was tested on Windows, but clearly we need to add some tests on all platforms! |
Yes, sadly it seems as if Python doesn't support that on Windows: python/cpython#77589 |
Its totally fine, I think its time to switch to ubuntu. |
I would definitely like to know about the |
Sure! First I will try this. |
I think it needs the exact path but as I could see in the previous code this was the temp dir we were creating? |
38be40c
to
69682d1
Compare
@ghutchis sir is this script ready to merge ? |
Thanks, I will take a look tomorrow (24 Oct) |
self.sock.connect(tempfile.gettempdir() + "/" + name) | ||
# print the connection statement | ||
print("CONNECTION ESTABLISHED SUCCESSFULLY") | ||
except Exception as exception: |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Catching too general exception Exception Note
Refactored the complete code into connection class and added the check for socket connection Signed-off-by: Omar <[email protected]> Signed-off-by: aditya <[email protected]> Signed-off-by: Omar <[email protected]>
Signed-off-by: Omar <[email protected]> Signed-off-by: aditya <[email protected]> Signed-off-by: Omar <[email protected]>
methods to one private method Signed-off-by: Omar <[email protected]> Signed-off-by: aditya <[email protected]> Signed-off-by: Omar <[email protected]>
… completely functional Signed-off-by: aditya <[email protected]> Signed-off-by: Omar <[email protected]>
Signed-off-by: aditya <[email protected]> Signed-off-by: Omar <[email protected]>
Signed-off-by: Omar <[email protected]>
Sure sir, I have observed you are quiet busy with university and this app, also I didn't saw others much active here, |
Congrats on merging your first pull request! 🎉 Thanks for making Avogadro better for everyone! |
Refactored the complete code into connection class and added the check for socket connection
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.