Handling [FileInfo()] format

632 Views Asked by At

I'm using scrcpy module and trying to get info about folder in mobile device.

With command devices.sync.list(remote), where remote is serial of phone and devices is Client, I will get FileInfo format type of respond:

[FileInfo(mode=16888, size=3452, mtime=datetime.datetime(2023, 4, 24, 14, 28, 8), path='000_230424_14-26-50')]

How can I handle this output?

I've tried for (mode, size, mtime, path) in devices.sync.list(remote): but getting the TypeError TypeError: cannot unpack non-iterable FileInfo object.

1

There are 1 best solutions below

0
mkrieger1 On BEST ANSWER

[FileInfo(mode=16888, size=3452, mtime=datetime.datetime(2023, 4, 24, 14, 28, 8), path='000_230424_14-26-50')] simply means that you have received a list containing one FileInfo object.

for fileinfo in devices.sync.list(remote): will iterate over this list, giving you each FileInfo object assigned to the fileinfo variable.

Presumably you can then access its properties as attributes:

for fileinfo in devices.sync.list(remote):
    print(fileinfo.mode)
    print(fileinfo.size)
    # etc.