Hi Kovid!
Thanks again for your patience with my total lack of skills - I have some experience with python, but zero knowledge of web protocols and interactions.
I'll have to impose on your kindness once more - I've been trying to implement file upload with mechanized and I'm thoroughly stuck.
For context, plugin code with my changes is here:
https://github.com/a-lagopus/KyBook3Sync/tree/develop
The problematic piece of code is cal2ky3.py:787
KyBook3 exposes a web interface, with a "File Upload..." button coded like this in html:
Code:
<div class="btn-toolbar">
<button type="button" class="btn btn-primary fileinput-button" id="upload-file">
<span class="glyphicon glyphicon-upload"></span> Upload Files…
<input id="fileupload" type="file" name="files[]" multiple="">
</button>
<button type="button" class="btn btn-success" id="create-folder">
<span class="glyphicon glyphicon-folder-close"></span> Create Folder…
</button>
<button type="button" class="btn btn-default" id="reload">
<span class="glyphicon glyphicon-refresh"></span> Refresh
</button>
</div>
I set up a mock mechanize app to try and upload something to it, but can't get it to work.
Any attempts at using a "find control" method to try and use add_file on it and upload the file causes an exception
Code:
no control matching id 'fileupload'
Tried 'fileupload', 'files[]', type=mechanize.FileControl - no luck.
Code:
import time
import urllib
from base64 import b64encode
from mechanize import Browser
br = Browser()
br.add_password("http://192.168.0.25:8080", "guest", "vNXD0d")
br.set_handle_robots(False)
response = br.open("http://192.168.0.25:8080/")
for form in br.forms():
try:
control = form.find_control(id="fileupload")
print(control)
except:
print('Nope')
printing the forms gives me this:
Code:
<GET http://192.168.0.25:8080/ application/x-www-form-urlencoded
<TextControl(<None>=)>>
Any help with this would be tremendously appreciated. I'm really willing to learn, but so far the learning curve proves a bit too steep for me...