#!/usr/bin/env python3
import asyncio, sys
sys.stdout.reconfigure(encoding='utf-8')
from pymobiledevice3.lockdown import create_using_usbmux
from pymobiledevice3.services.house_arrest import HouseArrestService

BID = 'vn.gsm.md'
UDID = '00008130-001E084434DB803A'


async def main():
    ld = await create_using_usbmux(serial=UDID)
    async with await HouseArrestService.create(ld, BID, documents_only=False) as afc:
        for root in ('/', '/Library', '/Library/Preferences', '/Documents', '/tmp'):
            try:
                print('==', root, await afc.listdir(root))
            except Exception as e:
                print('==', root, 'ERR', type(e).__name__, e)


asyncio.run(main())
