SHA256
1
0
forked from pool/sbl
sbl/sbl-orca-python3.patch
Ismail Dönmez 47dea93159 Accepting request 547564 from home:dimstar:Factory
- Migrate orca plugin to python3: orca has been a python3
  application since version 3.7, released in 2013:
  + Add python3-base BuildRequires.
  + Add sbl-orca-python3.patch: convert brlapi.py and
    python/Makefile to python3.

(removed python3-tools BR of my previous SR; was from an earlier experiment)

OBS-URL: https://build.opensuse.org/request/show/547564
OBS-URL: https://build.opensuse.org/package/show/hardware/sbl?expand=0&rev=29
2017-12-04 09:34:31 +00:00

139 lines
5.0 KiB
Diff

Index: sbl-3.5.0.20130317.git7a75bc29/python/Makefile
===================================================================
--- sbl-3.5.0.20130317.git7a75bc29.orig/python/Makefile
+++ sbl-3.5.0.20130317.git7a75bc29/python/Makefile
@@ -2,12 +2,11 @@
### Author: Marco Skambraks <marco@skammel.de>
include ../make.config
-PYVER=$(shell python --version 2>&1|cut -c 8-|cut -c 1-3)
-ORCA_DIR=$(DESTDIR)$(LIBDIR)/python$(PYVER)/site-packages/orca
+ORCA_DIR=$(DESTDIR)$(shell python3 -c "import site; print(site.getsitepackages()[0])")/orca
all: brlapi.py
@echo -n Generating byte code...
- @python -c 'import brlapi' && echo ok || @echo failed
+ @python3 -c 'import brlapi' && echo ok || @echo failed
clean:
rm -f *~ xyz jj.jj *.pyc
@@ -15,7 +14,7 @@ clean:
install: all
@if [ -d $(ORCA_DIR) ] || [ ! -z "$(DESTDIR)" ]; then \
install --directory $(ORCA_DIR) ; \
- install -m 644 brlapi.py brlapi.pyc $(ORCA_DIR) ; \
+ install -m 644 brlapi.py* $(ORCA_DIR) ; \
else \
echo please make sure that orca is installed in: ; \
echo $(ORCA_DIR) ; \
Index: sbl-3.5.0.20130317.git7a75bc29/python/brlapi.py
===================================================================
--- sbl-3.5.0.20130317.git7a75bc29.orig/python/brlapi.py
+++ sbl-3.5.0.20130317.git7a75bc29/python/brlapi.py
@@ -42,7 +42,7 @@ class getconf:
try:
conffile = open("/etc/sbl.conf",'r')
except:
- print "cannot open /etc/sbl.conf"
+ print("cannot open /etc/sbl.conf")
return None
for i in conffile.readlines():
@@ -99,7 +99,7 @@ class getconf:
try:
kmfile = open("/etc/sbl/keymap/" + brlname + ".map", 'r')
except:
- print "no keymap found for ", brlname
+ print("no keymap found for ", brlname)
return False
for i in kmfile.readlines():
@@ -167,32 +167,32 @@ class Connection:
if self.brld == None:
self.brld = CDLL("libbrld.so.1")
except:
- print "cannot open libbrld.so.1"
+ print("cannot open libbrld.so.1")
return None
self.conf = getconf()
self.fileDescriptor = self.brld.brld_open("localhost", self.conf.brldport())
if self.fileDescriptor < 0:
- print "brld: connection failed"
+ print("brld: connection failed")
raise IoError
tmpstr = create_string_buffer('\000' * 128)
tmpstr.value = self.conf.brldauth()
if self.brld.brld_reg(2, tmpstr.value) < 0:
- print "brld: reg failed"
+ print("brld: reg failed")
else:
if self.brld.brld_seteventmode() <0:
- print "brld: eventmode setfailed"
+ print("brld: eventmode setfailed")
return None
if self.brld.brld_getxy(byref(self.x),byref(self.y)) <0:
- print "brld: error getting Displaysize"
+ print("brld: error getting Displaysize")
return None
self.displaySize = (self.x.value, self.y.value)
if self.brld.brld_getalias(byref(tmpstr)) <0:
- print "brld: error getting brlname"
+ print("brld: error getting brlname")
return None
self.brlname = tmpstr.value
self.conf.loadkeymap(self.brlname)
@@ -208,7 +208,7 @@ class Connection:
s.value = text.decode("UTF-8").encode("iso8859-1")
if self.brld.brld_write(cursor, s, "") <0:
- print "brld: writeText error"
+ print("brld: writeText error")
return False
return True
@@ -220,7 +220,7 @@ class Connection:
len_diff = 0
add_spaces = ""
- s.value = writestruct.text.replace(u"\u2022", "*").encode("iso8859-1")
+ s.value = writestruct.text.replace("\u2022", "*").encode("iso8859-1")
if len(writestruct.attrOr) < len(writestruct.text):
len_diff = len(writestruct.text) - len(writestruct.attrOr)
add_spaces = ' ' * len_diff
@@ -228,8 +228,8 @@ class Connection:
a.value = writestruct.attrOr.replace('\x00',' ') + add_spaces
if self.brld.brld_write(writestruct.cursor-1, s.value, a.value) <0:
- print "brld: write err"
- print "brlline= ", writestruct.text
+ print("brld: write err")
+ print("brlline= ", writestruct.text)
return False
return True
@@ -239,7 +239,7 @@ class Connection:
pressed = c_int()
key = self.brld.brld_getkey(byref(pressed))
if key == -4:
- print "brld: getkey no connection"
+ print("brld: getkey no connection")
raise IoError
if key <= 0:
@@ -319,8 +319,8 @@ class Connection:
return True
def enterTtyMode(self, tty=7, driver=None):
- print "brld: enterTtyMode"
- print tty, driver
+ print("brld: enterTtyMode")
+ print(tty, driver)
def leaveTtyMode(self):