mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add code to MTP test for putting a file
This commit is contained in:
parent
186cf59ec4
commit
7d0bba4ca7
@ -729,13 +729,21 @@ def main():
|
|||||||
print(dev.device_debug_info(), flush=True)
|
print(dev.device_debug_info(), flush=True)
|
||||||
docs = dev.prefix_for_location(None)
|
docs = dev.prefix_for_location(None)
|
||||||
print('Prefix for main mem:', docs, flush=True)
|
print('Prefix for main mem:', docs, flush=True)
|
||||||
entries = dev.list_folder_by_name(dev.filesystem_cache.entries[0], docs)
|
parent = dev.filesystem_cache.entries[0]
|
||||||
|
entries = dev.list_folder_by_name(parent, docs)
|
||||||
pprint(entries)
|
pprint(entries)
|
||||||
pprint(dev.get_mtp_metadata_by_name(dev.filesystem_cache.entries[0], docs, entries[0].name))
|
pprint(dev.get_mtp_metadata_by_name(parent, docs, entries[0].name))
|
||||||
files = [x for x in entries if not x.is_folder]
|
files = [x for x in entries if not x.is_folder]
|
||||||
f = io.BytesIO()
|
f = io.BytesIO()
|
||||||
dev.get_file_by_name(f, dev.filesystem_cache.entries[0], docs, files[0].name)
|
dev.get_file_by_name(f, parent, docs, files[0].name)
|
||||||
print('Got', files[0].name, 'of size:', len(f.getvalue()))
|
data = f.getvalue()
|
||||||
|
print('Got', files[0].name, 'of size:', len(data))
|
||||||
|
parent = parent.folder_named(docs)
|
||||||
|
f.seek(0)
|
||||||
|
destname = 'mtp-driver-test.' + files[0].name.rpartition('.')[2]
|
||||||
|
m = dev.put_file(parent, destname, f, len(data))
|
||||||
|
print('Put', destname, 'in the', docs, 'folder')
|
||||||
|
pprint(m)
|
||||||
except Exception:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user