mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-23 12:14:26 +08:00
832412f5e3
These scripts have "#!/usr/bin/env python3" but have python2 syntax in several places. Fixed by running the "2to3" utility.
41 lines
824 B
Python
Executable File
41 lines
824 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
import sys
|
|
import dbus
|
|
|
|
|
|
def list_folder(folder):
|
|
bus = dbus.SessionBus()
|
|
client = dbus.Interface(bus.get_object("org.bluez.obex",
|
|
"/org/bluez/obex"),
|
|
"org.bluez.obex.Client")
|
|
|
|
path = client.CreateSession(sys.argv[1], { "Target": "ftp" })
|
|
|
|
ftp = dbus.Interface(bus.get_object("org.bluez.obex", path),
|
|
"org.bluez.obex.FileTransfer")
|
|
|
|
if folder:
|
|
for node in folder.split("/"):
|
|
ftp.ChangeFolder(node)
|
|
|
|
for i in ftp.ListFolder():
|
|
if i["Type"] == "folder":
|
|
print("%s/" % (i["Name"]))
|
|
else:
|
|
print("%s" % (i["Name"]))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: %s <device> [folder]" % (sys.argv[0]))
|
|
sys.exit(1)
|
|
|
|
folder = None
|
|
if len(sys.argv) == 3:
|
|
folder = sys.argv[2]
|
|
|
|
list_folder(folder)
|