Merge lp:~joel-auterson/python-snippets/bluetooth-snippets into lp:~jonobacon/python-snippets/trunk

Proposed by Joel Auterson
Status: Needs review
Proposed branch: lp:~joel-auterson/python-snippets/bluetooth-snippets
Merge into: lp:~jonobacon/python-snippets/trunk
Diff against target: 41 lines (+25/-0)
2 files modified
CATEGORIES (+1/-0)
bluetooth/scan.py (+24/-0)
To merge this branch: bzr merge lp:~joel-auterson/python-snippets/bluetooth-snippets
Reviewer Review Type Date Requested Status
Jono Bacon Pending
Review via email: mp+24075@code.launchpad.net

Description of the change

Added bluetooth snippet and category.

To post a comment you must log in.

Unmerged revisions

100. By Joel <joel@AUTERSON-STUDY>

Added Bluetooth snippet and category.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CATEGORIES'
2--- CATEGORIES 2010-04-24 18:34:32 +0000
3+++ CATEGORIES 2010-04-25 14:50:38 +0000
4@@ -13,6 +13,7 @@
5 When adding a snippet please try to use one of the following categories if suitable:
6
7 Application Indicator Application indicator examples.
8+ bluetooth PyBlueZ Bluetooth module.
9 bzrlib Bazaar source control system Python module.
10 Cairo Cairo drawing examples
11 Clutter Clutter toolkit examples.
12
13=== added directory 'bluetooth'
14=== added file 'bluetooth/scan.py'
15--- bluetooth/scan.py 1970-01-01 00:00:00 +0000
16+++ bluetooth/scan.py 2010-04-25 14:50:38 +0000
17@@ -0,0 +1,24 @@
18+# [SNIPPET_NAME: Scan for devices]
19+# [SNIPPET_CATEGORIES: bluetooth]
20+# [SNIPPET_DESCRIPTION: Scans for nearby devices, then lists their names and addresses.]
21+# [SNIPPET_AUTHOR: Joel Auterson joel.auterson@googlemail.com]
22+# [SNIPPET_DOCS: http://pybluez.googlecode.com/svn/www/docs-0.7/index.html]
23+# [SNIPPET_LICENSE: GPL]
24+
25+import bluetooth
26+
27+devices = None
28+
29+print 'Searching for devices. Please wait.'
30+devices = bluetooth.discover_devices()
31+
32+if devices == []:
33+ print "I couldn't find any devices. Check the device is in range and its Bluetooth is switched on."
34+
35+if devices != []:
36+ devLength = len(devices)
37+ devNum = 0
38+ while (devNum <= (devLength - 1)):
39+ print bluetooth.lookup_name(devices[devNum]) + " (" + devices[devNum] + ")"
40+ devNum = devNum + 1
41+ print "\nDone. " + str(devNum) + " device(s) were found."

Subscribers

People subscribed via source and target branches