-
Notifications
You must be signed in to change notification settings - Fork 39
added Dialog and Extention, added missing functions on Config #54
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
Conversation
Hi, thanks for your collaboration. |
sure, here is a small example of dialogs and extensions:
from myjdapi import myjdapi
import time
def answer_dialog(device, type, answer):
# TODO: implement timeout if no dialog happens despite being expected
dialogs = []
while not dialogs:
dialogs = device.dialogs.list()
time.sleep(1.5)
for dialog_id in dialogs:
dialoginfo = device.dialogs.get(dialog_id)
print(f"dialoginfo: {dialoginfo}")
# get expected structure of answer and question
dialogTypeInfo = device.dialogs.getTypeInfo(dialoginfo["type"])
print(f"dialogTypeInfo: {dialogTypeInfo}")
if dialoginfo["type"] == type:
device.dialogs.answer(dialog_id, answer)
return True
return False
def install_ext(device, id):
isInstalled = device.extensions.isInstalled(id)
if isInstalled:
return True
response = device.extensions.install(id)
dialogType = "org.appwork.uio.ConfirmDialogInterface"
response = {"dontshowagainselected": True, "closereason": "OK"}
return answer_dialog(device, dialogType, response)
def toggle_ext(device, id, state):
isEnabled = device.extensions.isEnabled(id)
if isEnabled == state:
return True
return device.extensions.setEnabled(id, state)
def main():
email = ""
password = ""
device_name = ""
jd = myjdapi.Myjdapi()
jd.set_app_key("http://git.io/vmcsk")
jd.connect(email, password)
jd.update_devices()
device = jd.get_device(device_name)
r = install_ext(device, "scheduler")
print(f"[+] installed scheduler successfully: {r}")
# wait for device to restart, implementing device.ping would be a better solution
time.sleep(30)
r = toggle_ext(device, "scheduler", True)
print(f"[+] enabled scheduler successfully: {r}")
if __name__ == "__main__":
main() |
The rest looks good, I didn't test much, but what I tested works, thanks for the example, and in any case nobody was using this so if somebody has issues with it, we will tackle it as it comes. |
Sounds great. What small changes are you talking about: am I missing something? |
myjdapi/myjdapi.py
Outdated
:param params: A dictionary with options. The default dictionary is | ||
configured so it returns you all the downloads with all details, but you |
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.
This is copy pasted from something else, here it references downloads for example and this doesn't return downloads, you don't need to add the docs if you don't want but I would appreciate it if don't keep unrelated comments.
myjdapi/myjdapi.py
Outdated
|
||
def listEnum(self, type): | ||
""" | ||
:return: List<AdvancedConfigAPIEntry> |
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.
This doesn't return a list of AdvancedConfigAPIEntry.
Based on the docs, it's List<EnumOption>. I mean neither of those case we implement the object in the list... it's not great but fine, ends up as dictionary. But I wanted the comment to at least reference the one mentioned in the API.
myjdapi/myjdapi.py
Outdated
}]): | ||
""" | ||
:param params: A dictionary with options. The default dictionary is | ||
configured so it returns you all the downloads with all details, but you |
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.
Same as before here. It mentions downloads again.
You should see them now, it seems I started a review adding comments but I didn't do the "submit" part, since it shows them in the PR already but I guess just for me. Just submitted now, sorry about that. |
Thanks for reviewing my PR. Yes, I messed up some copy pasted comments, I fixed all 3 comments you mentionend. Should be good now. |
No description provided.