-
Notifications
You must be signed in to change notification settings - Fork 30
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
Usage examples #4
Comments
Thanks for your interest in the project and sorry for the late reply. Do you mean the command-line tools or the library code? For the command-line tools, try
replacing For using the code as a library, you can look at the source code for the command-line tools. It should be quite readable if you ignore the error handling. Here's an even simpler example to get you started: from socket import AF_INET, SOCK_STREAM, socket
from dvrip import DVRIP_PORT
from dvrip.io import DVRIPClient
HOST = ... # FIXME replace with hostname of the DVR
USERNAME = 'admin' # FIXME replace with actual credentials
PASSWORD = '' # FIXME replace with actual credentials
sock = socket(AF_INET, SOCK_STREAM) # Create the socket we'll be using for communication
conn = DVRIPClient(sock) # Create a client connection using that socket
conn.connect((HOST, DVRIP_PORT), USERNAME, PASSWORD) # Connect and authenticate ourselves to the DVR
print(conn.time().isoformat()) # Print DVR date and time in ISO format
conn.logout() # Deauthenticate
sock.close() # Disconnect Does this answer your question? |
I'd say that README definitely could use some love. Taking as an example a commit like 5e30a72 (3 levels of fallbacks to getting an app version!!1), even if half of that time and lines were put into sprinkling life into the README, that would make the project much better. |
Btw, why do you pass "HOST" parameter to the help ( |
Because I didn’t think about it, it seems. I do prefer that option descriptions exist on a separate manual page and not be embedded in program code, but in this particular case I just didn’t realize the clash.
Well, yes, but writing is painful, so I haven’t gotten around to it. PRs welcome! (It’s not three levels of fallbacks, it’s one option for built distributions and another for source checkouts... with a fallback, yes, I did get a bit carried away). |
I'd suggest to reserve "-h" for help. "-a" (for "address"), "-s" (for "server") would be good alternatives. And fairly speaking, the hostname shouldn't necessarily be an option, can be a positional param (unless the intention is to support passing it as an environment var, which seems to be the case, then option is a better way to deal with it indeed).
Ack. That's why I gave an example of writing "too much code" (from outsider's PoV), even if 1 line doc = 10 lines code, could make a beneficial effort exchange.
I'm afraid if outsider would start writing docs from scratch, result may be much worse than if one wrote some code-drop (e.g. using spaces instead of tabs of indentation ;-), re: #5). See #7 as an example - I thought one would use individual dvr-info, dvr-discover, etc. tools, but turns out, that wasn't an intention. Anyway, thanks for your project, and please treat these comments just as votes from various people regarding priorities which would be helpful for the project ;-). |
Can you give an example to use your code ?
The text was updated successfully, but these errors were encountered: