From 205d9f31d962931bd33f03f78790fd60b8428b13 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 29 Apr 2022 14:43:42 -0500 Subject: Fix python issues in mLinux --- recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py') 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) -- cgit v1.2.3