Skip to content

Commit 1222ece

Browse files
committed
fix: add Python 3 compatiblitly
1 parent 849298f commit 1222ece

20 files changed

Lines changed: 66 additions & 46 deletions

File tree

asterisk4ucs-testasterisk/debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
asterisk4ucs-testasterisk (2.0.1) unstable; urgency=medium
2+
3+
* Add UCS 5.0 support. Migrate to Python 3
4+
5+
-- Florian Best <best@univention.de> Sun, 03 Apr 2022 20:56:35 +0200
6+
17
asterisk4ucs-testasterisk (1.0.1) unstable; urgency=low
28

39
* Nichtinteraktive Installation repariert

asterisk4ucs-udm/42asterisk4ucs-udm.inst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ umc_policy_append "default-umc-all" "udm-asterisk"
3030
joinscript_save_current_version
3131

3232
exit 0
33-
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
@%@UCRWARNING=# @%@
22
@!@
3-
if baseConfig['server/role'] == "domaincontroller_master":
4-
print "include /usr/share/univention-ldap/schema/asterisk4ucs.schema"
3+
if configRegistry['server/role'] == "domaincontroller_master":
4+
print("include /usr/share/univention-ldap/schema/asterisk4ucs.schema")
55
@!@
6-
7-

asterisk4ucs-udm/debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
asterisk4ucs-udm (2.0.1) unstable; urgency=medium
2+
3+
* Add UCS 5.0 support. Migrate to Python 3
4+
5+
-- Florian Best <best@univention.de> Sun, 03 Apr 2022 20:58:30 +0200
6+
17
asterisk4ucs-udm (1.0.0) unstable; urgency=low
28

39
* Einige Bugfixes, Vorbereitung auf Release

asterisk4ucs-udm/devscripts/hardrestart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
# with this program; if not, write to the Free Software Foundation, Inc.,
1616
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1717

18-
kill -9 `ps aux | grep management-console | cut -d\ -f 7` ; /etc/init.d/univention-management-console-server start && /etc/init.d/univention-management-console-web-server start
18+
systemctl restart univention-management-console-server

asterisk4ucs-udm/modules/univention/admin/handlers/asterisk/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def genSipconfEntry(co, lo, phone):
110110

111111

112112
def genSipconfFaxEntry(co, lo, phone):
113-
res = "[%s]\n" % (phone["extension"])
113+
res = "[%s]\n" % (phone["extension"],)
114114
res += "type=friend\n"
115115
res += "host=dynamic\n"
116-
res += "secret=%s\n" % (phone["password"])
116+
res += "secret=%s\n" % (phone["password"],)
117117
return res
118118

119119

@@ -159,7 +159,7 @@ def genSipconf(co, lo, srv):
159159
def genVoicemailconfEntry(co, lo, box):
160160
from univention.admin.handlers.users import user
161161
boxUser = user.lookup(co, lo, filter_format("(ast4ucsUserMailbox=%s)", (box.dn,)))
162-
if len(boxUser) == 0:
162+
if not boxUser:
163163
return ";; Mailbox %s has no user.\n" % box["id"]
164164
if len(boxUser) > 1:
165165
msg = ";; Mailbox %s has multiple users:\n" % box["id"]

asterisk4ucs-udm/modules/univention/admin/handlers/asterisk/agiscript.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818
"""
1919

20+
import base64
21+
2022
import univention.admin.filter
2123
import univention.admin.handlers
2224
import univention.admin.syntax
@@ -76,10 +78,10 @@ class object(simpleLdap):
7678
module = module
7779

7880
def getContent(self):
79-
return self.get("content", "").decode("base64")
81+
return base64.b64decode(self.get("content", "").encode('UTF-8')).decode("ascii")
8082

8183
def setContent(self, content):
82-
self["content"] = content.encode("base64").replace("\n", "")
84+
self["content"] = base64.b64encode(content.encode("utf-8")).decode('ascii')
8385

8486
def _ldap_addlist(self):
8587
return [('ast4ucsSrvchildServer', self.superordinate.dn)]

asterisk4ucs-udm/modules/univention/admin/handlers/asterisk/mailbox.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
childs = False
3838
superordinate = "asterisk/server"
3939

40-
# Definiert das Layout der Eingabefelder in der Weboberfläche
4140
layout = [
4241
Tab('Allgemein', 'Allgemeine Einstellungen', layout=[
4342
["id"],
@@ -46,8 +45,6 @@
4645
])
4746
]
4847

49-
# Definiert die verschiedenen UDM-Attribute
50-
# http://wiki.univention.de/index.php?title=Entwicklung_und_Integration_eigener_Module_in_Univention_Directory_Manager#property-descriptions
5148
property_descriptions = {
5249
"commonName": univention.admin.property(
5350
short_description="Name",
@@ -72,8 +69,6 @@
7269
),
7370
}
7471

75-
# Definiert die Zuordnung von UDM-Attributen zu LDAP-Attributen.
76-
# http://wiki.univention.de/index.php?title=Entwicklung_und_Integration_eigener_Module_in_Univention_Directory_Manager#mapping
7772
mapping = univention.admin.mapping.mapping()
7873
mapping.register("commonName", "cn", None, univention.admin.mapping.ListToString)
7974
mapping.register("id", "ast4ucsMailboxId", None, univention.admin.mapping.ListToString)

asterisk4ucs-udm/number2name.agi

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
"""
@@ -21,13 +21,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2121
import sys
2222
import ldap
2323
import logging
24-
import psycopg2
25-
import psycopg2.extras # noqa: F401
2624

2725
LOG_FILENAME = '/tmp/ast4ucs-number2name.log'
2826

2927
# read options from config file
30-
config = open("/etc/asterisk4ucs.ldapconfig").read().split("\n")
28+
config = open("/etc/asterisk4ucs.ldapconfig").read().splitlines()
3129
LDAP_IP = config[0]
3230
LDAP_SEARCH_BASE = config[1]
3331
ADMIN_DN = config[2]
@@ -44,7 +42,7 @@ logging.basicConfig(
4442
)
4543

4644
# Read and ignore AGI environment (read until blank line)
47-
env = dict()
45+
env = {}
4846
while len(sys.argv) < 2:
4947
line = sys.stdin.readline().strip()
5048
if not line:
@@ -92,25 +90,24 @@ if not result:
9290
sys.exit(0)
9391

9492
result = result[0][1]
95-
unwrap = lambda x: x[0] if x else None # noqa: E731
9693

97-
orga = unwrap(result.get('o'))
98-
last = unwrap(result.get('ast4ucsContactLastname'))
99-
first = unwrap(result.get('ast4ucsContactFirstname'))
94+
orga = result.get('o', [b''])[0].decode('UTF-8')
95+
last = result.get('ast4ucsContactLastname', [b''])[0].decode('UTF-8')
96+
first = result.get('ast4ucsContactFirstname', [b''])[0].decode('UTF-8')
10097

10198
if first and last:
10299
name = "%s %s" % (first, last)
103100
elif last:
104101
name = last
105102
else:
106-
name = first # could be string or None
103+
name = first
107104

108105
if orga and name:
109106
cn = "%s (%s)" % (name, orga)
110107
elif orga:
111108
cn = orga
112109
else:
113-
cn = name # could be string or None
110+
cn = name
114111

115112
if not cn:
116113
logging.info("Kontakt hat weder Name noch Organisation, exit")
@@ -135,7 +132,7 @@ for rule in rules:
135132

136133
# Namen an Asterisk senden
137134
logging.info("Setze Variable CALLERID auf " + cname)
138-
#cname = unicode(cname, 'utf-8').encode('iso-8859-1')
135+
#cname = cname.encode('iso-8859-1')
139136
sys.stdout.write('SET CALLERID "%s"\n' % (cname))
140137
sys.stdout.flush()
141138

asterisk4ucs-udm/osgaImport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22
# coding=utf-8
33

44
"""

0 commit comments

Comments
 (0)