summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2011-11-02 15:41:39 -0400
committerBarry Warsaw2011-11-02 15:41:39 -0400
commitf48ca2a1aa74a1b0fe14003d9ceb37e146b46738 (patch)
tree3df8d993612a41064d8a69b7de831bff2f57ff8e
parentf8456fef792eaa7b36a5b04072c5ad15d5fb6d48 (diff)
downloadmailman-f48ca2a1aa74a1b0fe14003d9ceb37e146b46738.tar.gz
mailman-f48ca2a1aa74a1b0fe14003d9ceb37e146b46738.tar.zst
mailman-f48ca2a1aa74a1b0fe14003d9ceb37e146b46738.zip
-rw-r--r--src/mailman/app/replybot.py2
-rw-r--r--src/mailman/archiving/mhonarc.py2
-rw-r--r--src/mailman/bin/arch.py2
-rw-r--r--src/mailman/bin/check_perms.py24
-rw-r--r--src/mailman/bin/cleanarch.py2
-rw-r--r--src/mailman/bin/config_list.py2
-rw-r--r--src/mailman/core/switchboard.py4
-rw-r--r--src/mailman/database/base.py24
-rw-r--r--src/mailman/database/sqlite.py13
-rw-r--r--src/mailman/utilities/filesystem.py2
10 files changed, 43 insertions, 34 deletions
diff --git a/src/mailman/app/replybot.py b/src/mailman/app/replybot.py
index 0fa73c601..97000c549 100644
--- a/src/mailman/app/replybot.py
+++ b/src/mailman/app/replybot.py
@@ -61,7 +61,7 @@ def can_acknowledge(msg):
return False
if msg.get('x-ack', '').lower() == 'no':
return False
- if msg.get('auto-submitted', 'no').lower() <> 'no':
+ if msg.get('auto-submitted', 'no').lower() != 'no':
return False
if msg.get('return-path') == '<>':
return False
diff --git a/src/mailman/archiving/mhonarc.py b/src/mailman/archiving/mhonarc.py
index 81baca7d3..c38c714b6 100644
--- a/src/mailman/archiving/mhonarc.py
+++ b/src/mailman/archiving/mhonarc.py
@@ -89,7 +89,7 @@ class MHonArc:
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True)
stdout, stderr = proc.communicate(msg.as_string())
- if proc.returncode <> 0:
+ if proc.returncode != 0:
log.error('%s: mhonarc subprocess had non-zero exit code: %s' %
(msg['message-id'], proc.returncode))
log.info(stdout)
diff --git a/src/mailman/bin/arch.py b/src/mailman/bin/arch.py
index cb7a81dae..1f2d6b626 100644
--- a/src/mailman/bin/arch.py
+++ b/src/mailman/bin/arch.py
@@ -135,7 +135,7 @@ def main():
os.rename(atchdir, savedir)
saved = True
except OSError, e:
- if e.errno <> errno.ENOENT:
+ if e.errno != errno.ENOENT:
raise
shutil.rmtree(mlist.archive_dir())
if mlist.scrub_nondigest and saved:
diff --git a/src/mailman/bin/check_perms.py b/src/mailman/bin/check_perms.py
index 5cf009f37..47aff41d4 100644
--- a/src/mailman/bin/check_perms.py
+++ b/src/mailman/bin/check_perms.py
@@ -84,9 +84,9 @@ def checkwalk(arg, dirname, names):
try:
mode, gid = statgidmode(path)
except OSError, e:
- if e.errno <> errno.ENOENT: raise
+ if e.errno != errno.ENOENT: raise
continue
- if gid <> MAILMAN_GID:
+ if gid != MAILMAN_GID:
try:
groupname = getgrgid(gid)[0]
except KeyError:
@@ -119,7 +119,7 @@ def checkwalk(arg, dirname, names):
else:
targetperms = DIRPERMS
octperms = oct(targetperms)
- if S_ISDIR(mode) and (mode & targetperms) <> targetperms:
+ if S_ISDIR(mode) and (mode & targetperms) != targetperms:
arg.ERRORS += 1
print _('directory permissions must be $octperms: $path'),
if STATE.FIX:
@@ -129,7 +129,7 @@ def checkwalk(arg, dirname, names):
print
elif os.path.splitext(path)[1] in ('.py', '.pyc', '.pyo'):
octperms = oct(PYFILEPERMS)
- if mode & PYFILEPERMS <> PYFILEPERMS:
+ if mode & PYFILEPERMS != PYFILEPERMS:
print _('source perms must be $octperms: $path'),
arg.ERRORS += 1
if STATE.FIX:
@@ -140,7 +140,7 @@ def checkwalk(arg, dirname, names):
elif path.endswith('-article'):
# Article files must be group writeable
octperms = oct(ARTICLEFILEPERMS)
- if mode & ARTICLEFILEPERMS <> ARTICLEFILEPERMS:
+ if mode & ARTICLEFILEPERMS != ARTICLEFILEPERMS:
print _('article db files must be $octperms: $path'),
arg.ERRORS += 1
if STATE.FIX:
@@ -164,10 +164,10 @@ def checkall():
try:
mode = statmode(d)
except OSError, e:
- if e.errno <> errno.ENOENT: raise
+ if e.errno != errno.ENOENT: raise
print _('WARNING: directory does not exist: $d')
continue
- if (mode & DIRPERMS) <> DIRPERMS:
+ if (mode & DIRPERMS) != DIRPERMS:
STATE.ERRORS += 1
print _('directory must be at least 02775: $d'),
if STATE.FIX:
@@ -212,7 +212,7 @@ def checkmboxfile(mboxdir):
continue
mboxfile = os.path.join(absdir, f)
mode = statmode(mboxfile)
- if (mode & MBOXPERMS) <> MBOXPERMS:
+ if (mode & MBOXPERMS) != MBOXPERMS:
STATE.ERRORS = STATE.ERRORS + 1
print _('mbox file must be at least 0660:'), mboxfile
if STATE.FIX:
@@ -292,10 +292,10 @@ def checkadminpw():
try:
mode = statmode(pwfile)
except OSError, e:
- if e.errno <> errno.ENOENT:
+ if e.errno != errno.ENOENT:
raise
return
- if mode <> targetmode:
+ if mode != targetmode:
STATE.ERRORS += 1
octmode = oct(mode)
print _('$pwfile permissions must be exactly 0640 (got $octmode)'),
@@ -334,10 +334,10 @@ def checkdata():
try:
mode = statmode(path)
except OSError, e:
- if e.errno <> errno.ENOENT:
+ if e.errno != errno.ENOENT:
raise
continue
- if (mode & targetmode) <> targetmode:
+ if (mode & targetmode) != targetmode:
STATE.ERRORS += 1
print _('file permissions must be at least 660: $path'),
if STATE.FIX:
diff --git a/src/mailman/bin/cleanarch.py b/src/mailman/bin/cleanarch.py
index 5bae3244d..1bf530a0f 100644
--- a/src/mailman/bin/cleanarch.py
+++ b/src/mailman/bin/cleanarch.py
@@ -113,7 +113,7 @@ def main():
if output:
# Before we spit out the From_ line, make sure the
# previous line was blank.
- if prevline is not None and prevline <> '\n':
+ if prevline is not None and prevline != '\n':
sys.stdout.write('\n')
sys.stdout.write(line)
sys.stdout.write(nextline)
diff --git a/src/mailman/bin/config_list.py b/src/mailman/bin/config_list.py
index a40f4ee52..94870b6a8 100644
--- a/src/mailman/bin/config_list.py
+++ b/src/mailman/bin/config_list.py
@@ -177,7 +177,7 @@ def do_list_categories(mlist, k, subcat, outfp):
if not lines:
print >> outfp, "''"
elif len(lines) == 1:
- if charset <> 'us-ascii' and nonasciipat.search(lines[0]):
+ if charset != 'us-ascii' and nonasciipat.search(lines[0]):
# This is more readable for non-english list.
print >> outfp, '"' + lines[0].replace('"', '\\"') + '"'
else:
diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py
index 4c7b31a67..8f5dcabea 100644
--- a/src/mailman/core/switchboard.py
+++ b/src/mailman/core/switchboard.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-"""Queing and dequeuing message/metadata pickle files.
+"""Queuing and dequeuing message/metadata pickle files.
Messages are represented as email.message.Message objects (or an instance ofa
subclass). Metadata is represented as a Python dictionary. For every
@@ -49,7 +49,7 @@ from mailman.utilities.filesystem import makedirs
from mailman.utilities.string import expand
-# 20 bytes of all bits set, maximum hashlib.sha.digest() value
+# 20 bytes of all bits set, maximum hashlib.sha.digest() value.
shamax = 0xffffffffffffffffffffffffffffffffffffffffL
# Small increment to add to time in case two entries have the same time. This
# prevents skipping one of two entries with the same time until the next pass.
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py
index 1e71341e0..bf5afd5d4 100644
--- a/src/mailman/database/base.py
+++ b/src/mailman/database/base.py
@@ -30,7 +30,6 @@ from flufl.lock import Lock
from lazr.config import as_boolean
from storm.cache import GenerationalCache
from storm.locals import create_database, Store
-from urlparse import urlparse
from zope.interface import implements
import mailman.version
@@ -115,6 +114,15 @@ class StormBaseDatabase:
"""
pass
+ def _prepare(self, url):
+ """Prepare the database for creation.
+
+ Some database backends need to do so me prep work before letting Storm
+ create the database. For example, we have to touch the SQLite .db
+ file first so that it has the proper file modes.
+ """
+ pass
+
def _create(self, debug):
# Calculate the engine url.
url = expand(config.database.url, config.paths)
@@ -134,7 +142,7 @@ class StormBaseDatabase:
# engines, and yes, we could have chmod'd the file after the fact, but
# half dozen and all...
self.url = url
- touch(url)
+ self._prepare(url)
database = create_database(url)
store = Store(database, GenerationalCache())
database.DEBUG = (as_boolean(config.database.debug)
@@ -170,15 +178,3 @@ class StormBaseDatabase:
from mailman.database.model import ModelMeta
self.store.rollback()
ModelMeta._reset(self.store)
-
-
-
-def touch(url):
- parts = urlparse(url)
- if parts.scheme <> 'sqlite':
- return
- path = os.path.normpath(parts.path)
- fd = os.open(path, os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, 0666)
- # Ignore errors
- if fd > 0:
- os.close(fd)
diff --git a/src/mailman/database/sqlite.py b/src/mailman/database/sqlite.py
index 30c4959b7..a68dc1eea 100644
--- a/src/mailman/database/sqlite.py
+++ b/src/mailman/database/sqlite.py
@@ -25,7 +25,10 @@ __all__ = [
]
+import os
+
from pkg_resources import resource_string
+from urlparse import urlparse
from mailman.database.base import StormBaseDatabase
@@ -41,6 +44,16 @@ class SQLiteDatabase(StormBaseDatabase):
store.execute(table_query))
return 'version' in table_names
+ def _prepare(self, url):
+ parts = urlparse(url)
+ assert parts.scheme == 'sqlite', (
+ 'Database url mismatch (expected sqlite prefix): {0}'.format(url))
+ path = os.path.normpath(parts.path)
+ fd = os.open(path, os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, 0666)
+ # Ignore errors
+ if fd > 0:
+ os.close(fd)
+
def _get_schema(self):
"""See `BaseDatabase`."""
return resource_string('mailman.database.sql', 'sqlite.sql')
diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py
index 3296a4a6c..0234f2def 100644
--- a/src/mailman/utilities/filesystem.py
+++ b/src/mailman/utilities/filesystem.py
@@ -66,7 +66,7 @@ def makedirs(path, mode=02775):
os.makedirs(path, mode)
except OSError as error:
# Ignore the exceptions if the directory already exists.
- if error.errno <> errno.EEXIST:
+ if error.errno != errno.EEXIST:
raise
# Some systems such as FreeBSD ignore mkdir's mode, so walk the just
# created directories and try to set the mode, ignoring any OSErrors that