File: file_send.py

package info (click to toggle)
python-lightblue 0.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,376 kB
  • ctags: 852
  • sloc: objc: 4,009; python: 2,641; ansic: 1,369; cpp: 818; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 921 bytes parent folder | download | duplicates (3)
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
"""
Shows how to send a file over OBEX.
"""

import lightblue
import sys

if len(sys.argv) == 1:
    print "Usage: file_send.py [filename]"
    sys.exit(1)

sourcefile = sys.argv[1]

# Ask user to choose the device and service to send the file to.
address, serviceport, servicename = lightblue.selectservice()

# Send the file
lightblue.obex.sendfile(address, serviceport, sourcefile)

print "Done!"


# Note:
# Instead of calling selectservice(), you could do:
#
#     services = lightblue.findservices(addr=lightblue.selectdevice()[0],
#                                       servicetype=lightblue.OBEX)
#     address, serviceport, servicename = services[0]
#     lightblue.obex.sendfile(address, serviceport, sourcefile)
#
# This will ask the user to select a device, and then just send the file to the 
# first OBEX service found on that device. Then you don't have to ask the
# user to select a particular service.
#