summaryrefslogtreecommitdiff
path: root/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py')
-rw-r--r--recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py
index e8f2554..cf8fec4 100644
--- a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py
+++ b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env python2
-import thread
+#!/usr/bin/env python
import os
import dbus
import dbus.service
@@ -16,9 +15,7 @@ import grp
import stat
import atexit
import re
-import mmap
import subprocess
-import threading
import struct
import fcntl
import termios
@@ -298,9 +295,9 @@ class Profile(dbus.service.Object):
# Bluetooth address portion of the path
address = os.path.basename(self.path)
- numaddr = address[address.find("_")+1:]
+ numaddr = address[address.find("_")+1:]
# Replace _ with :
- Name = bluetooth.lookup_name(numaddr.replace("_",":"))
+ Name = bluetooth.lookup_name(numaddr.replace("_",":"))
print('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd))
lg.info('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd))
@@ -316,18 +313,18 @@ class Profile(dbus.service.Object):
lg.debug('pseudoterminal major and minor: (%d,%d)' % (os.major(slavestat.st_rdev),self.minor))
if not os.path.isdir(RFCOMMDIR):
lg.debug('Before mkdir: RFCOMMDIR %s' % (RFCOMMDIR))
- os.mkdir(RFCOMMDIR,0755)
+ os.mkdir(RFCOMMDIR,0o755)
lg.debug('Address %s' % (address))
self.linkPath = RFCOMMDIR + '/' + address + '_' + Name + '_pts' + str(self.minor)
- self.slavePath = SLAVEDIR + '/' + str(self.minor)
+ self.slavePath = SLAVEDIR + '/' + str(self.minor)
lg.debug('termPath %s' % (self.linkPath))
self.removeLink(self.notexiting)
# linkPath was removed
lg.debug('os.symlink(%s,%s)' % (self.slavePath,self.linkPath))
- old = os.umask(002)
+ old = os.umask(0o002)
lg.debug('past umask')
try:
os.symlink(self.slavePath,self.linkPath)
@@ -471,7 +468,7 @@ class Profile(dbus.service.Object):
try:
os.write(self.fd,data)
except Exception as e:
- print '%s' % (e)
+ print('%s' % e)
lg.error('%s' % (e))
self.RequestDisconnection(self.path)
return True
@@ -563,12 +560,12 @@ if __name__ == '__main__':
if opts.pseudoterminal and opts.loopback:
msg = 'Cannot have both pseudoterminal and loopback option'
- print msg
+ print(msg)
lg.error(msg)
exit(1)
if not opts.pseudoterminal and not opts.loopback and not opts.login:
doterm = True
- print "main: doterm is %s" % (str(doterm))
+ print("main: doterm is %s" % (str(doterm)))
if opts.pseudoterminal or opts.login:
needpseudot = True
@@ -594,7 +591,7 @@ if __name__ == '__main__':
rpipe,wpipe = os.pipe()
loginProcess = logins()
Profile.w = wpipe
- lg.debug('Call threading next')
+ lg.debug('Call StartLogin threading next')
try:
StartLoginThread = threading.Thread(target=loginProcess.StartLogin,args=[rpipe,mainloop])
except Exception as e:
@@ -621,10 +618,10 @@ if __name__ == '__main__':
try:
manager.RegisterProfile(profile_path, opts.uuid, SPP_opts)
except dbus.exceptions.DBusException as inst:
- print 'dbus exception:',inst._dbus_error_name
+ print('dbus exception:',inst._dbus_error_name)
lg.error('dbus exception: %s',inst._dbus_error_name)
if inst._dbus_error_name == 'org.freedesktop.DBus.Error.AccessDenied':
- print 'Try running as root'
+ print('Try running as root')
exit(1)
lg.debug('Completed Register Profile...')
@@ -636,7 +633,7 @@ if __name__ == '__main__':
pass
except Exception as e:
lg.error('mainloop exception: %s' % (e))
- print '\nSerial Port Profile: ERROR Goodbye'
+ print('\nSerial Port Profile: ERROR Goodbye')
lg.error('Serial Port Profile: ERROR Goodbye')
data = struct.pack('i',-1)
os.write(wpipe,data)