Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py-vmailmgr: add Python 3 support. NFCI for 2.7.
- Loading branch information
Showing
12 changed files
with
225 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
mail/vmailmgr-base/patches/patch-python_vmailmgr_Makefile.am
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$NetBSD: patch-python_vmailmgr_Makefile.am,v 1.1 2024/02/27 19:13:43 schmonz Exp $ | ||
|
||
Use pkgsrc-selected python. | ||
|
||
--- python/vmailmgr/Makefile.am.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/Makefile.am | ||
@@ -26,6 +26,6 @@ types.pyc: types.py local.py | ||
types.pyo: types.py local.py | ||
|
||
.py.pyc: | ||
- python -c 'import $*' && touch $@ | ||
+ env PYTHONPATH=.. @PYTHONBIN@ -c 'import vmailmgr.$*' && touch $@ | ||
.py.pyo: | ||
- python -O -c 'import $*' && touch $@ | ||
+ env PYTHONPATH=.. @PYTHONBIN@ -O -c 'import vmailmgr.$*' && touch $@ |
9 changes: 9 additions & 0 deletions
9
mail/vmailmgr-base/patches/patch-python_vmailmgr_____init____.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$NetBSD: patch-python_vmailmgr_____init____.py,v 1.1 2024/02/27 19:13:43 schmonz Exp $ | ||
|
||
Port to Python 3, maintaining 2.7 compatibility. | ||
|
||
--- python/vmailmgr/__init__.py.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/__init__.py | ||
@@ -1 +1 @@ | ||
-from commands import * | ||
+from vmailmgr.commands import * |
63 changes: 63 additions & 0 deletions
63
mail/vmailmgr-base/patches/patch-python_vmailmgr_commands.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
$NetBSD: patch-python_vmailmgr_commands.py,v 1.1 2024/02/27 19:13:44 schmonz Exp $ | ||
|
||
Port to Python 3, maintaining 2.7 compatibility. | ||
|
||
--- python/vmailmgr/commands.py.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/commands.py | ||
@@ -14,45 +14,44 @@ | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
-import daemon | ||
-import string | ||
-import types | ||
+import vmailmgr.daemon | ||
+import vmailmgr.types | ||
|
||
def execute(command, *args): | ||
- return daemon.execute(command, args) | ||
+ return vmailmgr.daemon.execute(command, args) | ||
|
||
def check(domain, username, password): | ||
return execute('check', domain, username, password) | ||
|
||
def listdomain(domain, password): | ||
- conn = daemon.Daemon() | ||
- response = conn.execute(daemon.Command('listdomain', (domain, password))) | ||
+ conn = vmailmgr.daemon.Daemon() | ||
+ response = conn.execute(vmailmgr.daemon.Command('listdomain', (domain, password))) | ||
users = [] | ||
while 1: | ||
r = conn.read_response() | ||
if not r: | ||
break | ||
- (username,data) = string.split(r, '\0', 1) | ||
- users.append(types.NamedVUser(username, types.VUser(data))) | ||
+ (username,data) = r.split('\0', 1) | ||
+ users.append(vmailmgr.types.NamedVUser(username, vmailmgr.types.VUser(data))) | ||
return users | ||
|
||
def adduser(domain, newuser, password, newpass, | ||
maildir=None, has_mailbox=None, forwards=[]): | ||
- return daemon.execute('adduser3', | ||
+ return vmailmgr.daemon.execute('adduser3', | ||
(domain, newuser, password, newpass, | ||
maildir or '', has_mailbox or '') + tuple(forwards)) | ||
|
||
def lookup(domain, username, password): | ||
- return types.VUser(execute('lookup', domain, username, password)) | ||
+ return vmailmgr.types.VUser(execute('lookup', domain, username, password)) | ||
|
||
def autoresponse(domain, user, password, action, message=None): | ||
cmd = [ domain, user, password, action ] | ||
if message: | ||
cmd.append(message) | ||
- return daemon.execute('autoresponse', cmd) | ||
+ return vmailmgr.daemon.execute('autoresponse', cmd) | ||
|
||
def deluser(domain, username, password): | ||
return execute('deluser', domain, username, password) | ||
|
||
def chattr(domain, username, password, attribute, *value): | ||
- return daemon.execute('chattr', (domain,username,password,attribute)+value) | ||
+ return vmailmgr.daemon.execute('chattr', (domain,username,password,attribute)+value) |
23 changes: 23 additions & 0 deletions
23
mail/vmailmgr-base/patches/patch-python_vmailmgr_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$NetBSD: patch-python_vmailmgr_config.py,v 1.1 2024/02/27 19:13:44 schmonz Exp $ | ||
|
||
Port to Python 3, maintaining 2.7 compatibility. | ||
|
||
--- python/vmailmgr/config.py.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/config.py | ||
@@ -15,13 +15,12 @@ | ||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
import os | ||
-import string | ||
-import local | ||
+import vmailmgr.local | ||
|
||
def read(name, default): | ||
try: | ||
- file = open(os.path.join(vmailmgr_local.sysconfdir, name)) | ||
- result = string.strip(file.readline()) | ||
+ file = open(os.path.join(vmailmgr.local.sysconfdir, name)) | ||
+ result = file.readline().strip() | ||
file.close() | ||
except: | ||
result = default |
24 changes: 24 additions & 0 deletions
24
mail/vmailmgr-base/patches/patch-python_vmailmgr_daemon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$NetBSD: patch-python_vmailmgr_daemon.py,v 1.1 2024/02/27 19:13:44 schmonz Exp $ | ||
|
||
Port to Python 3, maintaining 2.7 compatibility. | ||
|
||
--- python/vmailmgr/daemon.py.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/daemon.py | ||
@@ -14,7 +14,7 @@ | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
-import config | ||
+import vmailmgr.config | ||
|
||
ok = 0 | ||
bad = 1 | ||
@@ -47,7 +47,7 @@ class Command: | ||
|
||
class Daemon: | ||
def __init__(self): | ||
- self.socket_file = config.read('socket-file', '/tmp/.vmailmgrd') | ||
+ self.socket_file = vmailmgr.config.read('socket-file', '/tmp/.vmailmgrd') | ||
self.socket = None | ||
|
||
def connect(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
$NetBSD: patch-python_vmailmgr_types.py,v 1.1 2024/02/27 19:13:44 schmonz Exp $ | ||
|
||
Port to Python 3, maintaining 2.7 compatibility. | ||
|
||
--- python/vmailmgr/types.py.orig 2015-09-01 16:03:21.000000000 +0000 | ||
+++ python/vmailmgr/types.py | ||
@@ -14,13 +14,12 @@ | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
-import string | ||
import time | ||
|
||
class Limit: | ||
unlimited = -1 | ||
def __init__(self, str): | ||
- if str[0] == '-' or string.lower(str) == 'unlimited': | ||
+ if str[0] == '-' or str.lower() == 'unlimited': | ||
str = self.unlimited | ||
self.value = int(str) | ||
def __str__(self): | ||
@@ -84,18 +83,18 @@ class VUser: | ||
self.from_binary(bin) | ||
|
||
def from_binary(self, bin): | ||
- if bin[0] <> chr(2): | ||
- raise ValueError, "Virtual user data has invalid format number" | ||
+ if bin[0] != chr(2): | ||
+ raise ValueError("Virtual user data has invalid format number") | ||
i = 1 | ||
- while bin[i] <> chr(0): | ||
+ while bin[i] != chr(0): | ||
flag = ord(bin[i]) | ||
val = ord(bin[i+1]) | ||
i = i + 2 | ||
if flag == ATTR_MAILBOX_ENABLED: | ||
self.mailbox_enabled = Flag(val) | ||
else: | ||
- raise ValueError, "Invalid flag number %d in vuser data" % flag | ||
- bin = string.split(bin[i+1:], '\0') | ||
+ raise ValueError("Invalid flag number %d in vuser data" % flag) | ||
+ bin = bin[i+1:].split('\0') | ||
self.password = bin[0] | ||
self.mailbox = bin[1] | ||
self.forwards = [] | ||
@@ -124,12 +123,15 @@ class VUser: | ||
def items(self): return self.__dict__.items() | ||
def dict(self): return self.__dict__ | ||
|
||
+def my_cmp(a, b): | ||
+ return (a > b) - (a < b) | ||
+ | ||
class NamedVUser: | ||
def __init__(self, username, vuser): | ||
self.username = username | ||
self.vuser = vuser | ||
def __cmp__(self, other): | ||
- return cmp(self.username, other.username) | ||
+ return my_cmp(self.username, other.username) | ||
def __getitem__(self, key): | ||
if key == 'username': | ||
return self.username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters