blob: c7eec105933fb6d1070e46c05faeb0d0995d2c77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/python
import sys
import dbus
def list_folder(folder):
bus = dbus.SessionBus()
client = dbus.Interface(bus.get_object("org.openobex.client", "/"),
"org.openobex.Client")
session_path = client.CreateSession({ "Destination": sys.argv[1], "Target": "ftp"})
ftp = dbus.Interface(bus.get_object("org.openobex.client", session_path),
"org.openobex.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)
|