summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab/auth/__init__.py6
-rw-r--r--pykolab/auth/ldap/__init__.py104
-rw-r--r--pykolab/cli/cmd_export_mailbox.py12
-rw-r--r--pykolab/cli/cmd_list_domains.py4
-rw-r--r--pykolab/cli/cmd_list_mailboxes.py2
-rw-r--r--pykolab/cli/cmd_sync.py6
-rw-r--r--pykolab/cli/cmd_transfer_mailbox.py2
-rw-r--r--pykolab/cli/commands.py36
-rw-r--r--pykolab/cli/telemetry/cmd_examine_command_issue.py6
-rw-r--r--pykolab/cli/telemetry/cmd_examine_session.py6
-rw-r--r--pykolab/cli/telemetry/cmd_list_sessions.py2
-rw-r--r--pykolab/conf/__init__.py66
-rw-r--r--pykolab/conf/entitlement.py18
-rw-r--r--pykolab/imap/__init__.py92
-rw-r--r--pykolab/imap/cyrus.py44
-rw-r--r--pykolab/logger.py2
-rw-r--r--pykolab/plugins/__init__.py16
-rw-r--r--pykolab/plugins/defaultfolders/__init__.py4
-rw-r--r--pykolab/plugins/dynamicquota/__init__.py4
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py6
-rw-r--r--pykolab/setup/components.py36
-rw-r--r--pykolab/setup/ldap_setup.py4
-rw-r--r--pykolab/setup/setup_ldap.py2
-rw-r--r--pykolab/telemetry.py10
-rw-r--r--pykolab/tests/imap/test_login.py10
-rw-r--r--pykolab/tests/tests.py38
-rw-r--r--pykolab/utils.py10
-rw-r--r--pykolab/wap_client/__init__.py18
28 files changed, 283 insertions, 283 deletions
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py
index 66eb993..36e9600 100644
--- a/pykolab/auth/__init__.py
+++ b/pykolab/auth/__init__.py
@@ -104,7 +104,7 @@ class Auth(object):
domain = self.secondary_domains[domain]
log.debug(
- _("Connecting to Authentication backend for domain %s") %(
+ _("Connecting to Authentication backend for domain %s") % (
domain
),
level=8
@@ -150,7 +150,7 @@ class Auth(object):
if self.secondary_domains.has_key(domain):
log.debug(
_("Using primary domain %s instead of secondary domain %s")
- %(
+ % (
self.secondary_domains[domain],
domain
),
@@ -167,7 +167,7 @@ class Auth(object):
if self.secondary_domains.has_key(domain):
log.debug(
_("Using primary domain %s instead of secondary domain %s")
- %(
+ % (
self.secondary_domains[domain],
domain
),
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 727c395..ae06a5f 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -107,13 +107,13 @@ class LDAP(object):
def _authenticate(self, login, domain):
log.debug(_("Attempting to authenticate user %s in domain %s")
- %(login, domain), level=8)
+ % (login, domain), level=8)
self._connect()
user_dn = self._find_dn(login[0], domain)
try:
log.debug(_("Binding with user_dn %s and password %s")
- %(user_dn, login[1]))
+ % (user_dn, login[1]))
# Needs to be synchronous or succeeds and continues setting retval
# to True!!
@@ -121,7 +121,7 @@ class LDAP(object):
retval = True
except:
log.debug(
- _("Failed to authenticate as user %s") %(user_dn),
+ _("Failed to authenticate as user %s") % (user_dn),
level=8
)
@@ -144,7 +144,7 @@ class LDAP(object):
key = 'uri'
if conf.has_option(domain, 'uri'):
- log.warning(_("Deprecation: Setting 'uri' for LDAP in section %s needs to be updated to 'ldap_uri'") %(domain))
+ log.warning(_("Deprecation: Setting 'uri' for LDAP in section %s needs to be updated to 'ldap_uri'") % (domain))
section = domain
key = 'uri'
elif conf.has_option(domain, 'ldap_uri'):
@@ -155,7 +155,7 @@ class LDAP(object):
uri = conf.get(section, key)
- log.debug(_("Attempting to use LDAP URI %s") %(uri), level=8)
+ log.debug(_("Attempting to use LDAP URI %s") % (uri), level=8)
trace_level = 0
@@ -241,7 +241,7 @@ class LDAP(object):
_("Deprecation warning: The setting " + \
"kolab_smtp_access_policy.address_search_attrs " + \
"is to be replaced with the 'auth_attrs' key in " + \
- "the 'ldap' or '%s' domain section.") %(domain)
+ "the 'ldap' or '%s' domain section.") % (domain)
)
auth_search_attrs = conf.get_list(
@@ -260,14 +260,14 @@ class LDAP(object):
auth_search_filter = [ '(|' ]
for auth_search_attr in auth_search_attrs:
- auth_search_filter.append('(%s=%s)' %(auth_search_attr,login))
- auth_search_filter.append('(%s=%s@%s)' %(auth_search_attr,login,domain))
+ auth_search_filter.append('(%s=%s)' % (auth_search_attr,login))
+ auth_search_filter.append('(%s=%s@%s)' % (auth_search_attr,login,domain))
auth_search_filter.append(')')
auth_search_filter = ''.join(auth_search_filter)
- search_filter = "(&%s%s)" %(
+ search_filter = "(&%s%s)" % (
auth_search_filter,
user_filter
)
@@ -285,7 +285,7 @@ class LDAP(object):
# Retry to find the user_dn with just uid=%s against the root_dn,
# if the login is not fully qualified
if len(login.split('@')) < 2:
- search_filter = "(uid=%s)" %(login)
+ search_filter = "(uid=%s)" % (login)
_results = self._search(
domain,
filterstr=search_filter,
@@ -320,20 +320,20 @@ class LDAP(object):
user_base_dn = conf.get_raw(
section,
'user_base_dn'
- ) %({'base_dn': domain_root_dn})
+ ) % ({'base_dn': domain_root_dn})
else:
user_base_dn = base_dn
if type(attr) == str:
- search_filter = "(%s=%s)" %(
+ search_filter = "(%s=%s)" % (
attr,
value
)
elif type(attr) == list:
search_filter = "(|"
for _attr in attr:
- search_filter = "%s(%s=%s)" %(search_filter, _attr, value)
- search_filter = "%s)" %(search_filter)
+ search_filter = "%s(%s=%s)" % (search_filter, _attr, value)
+ search_filter = "%s)" % (search_filter)
if additional_filter:
search_filter = additional_filter % {
@@ -341,7 +341,7 @@ class LDAP(object):
}
log.debug(
- _("Attempting to find the user with search filter: %s") %(
+ _("Attempting to find the user with search filter: %s") % (
search_filter
),
level=8
@@ -379,20 +379,20 @@ class LDAP(object):
user_base_dn = conf.get_raw(
section,
'user_base_dn'
- ) %({'base_dn': domain_root_dn})
+ ) % ({'base_dn': domain_root_dn})
else:
user_base_dn = base_dn
if type(attr) == str:
- search_filter = "(%s=%s)" %(
+ search_filter = "(%s=%s)" % (
attr,
value
)
elif type(attr) == list:
search_filter = "(|"
for _attr in attr:
- search_filter = "%s(%s=%s)" %(search_filter, _attr, value)
- search_filter = "%s)" %(search_filter)
+ search_filter = "%s(%s=%s)" % (search_filter, _attr, value)
+ search_filter = "%s)" % (search_filter)
if additional_filter:
search_filter = additional_filter % {
@@ -400,7 +400,7 @@ class LDAP(object):
}
log.debug(
- _("Attempting to find entries with search filter: %s") %(
+ _("Attempting to find entries with search filter: %s") % (
search_filter
),
level=8
@@ -471,8 +471,8 @@ class LDAP(object):
for dn,entry,srv_ctrls in res_data:
log.debug(_("LDAP Search Result Data Entry:"), level=8)
- log.debug(" DN: %r" %(dn), level=8)
- log.debug(" Entry: %r" %(entry), level=8)
+ log.debug(" DN: %r" % (dn), level=8)
+ log.debug(" Entry: %r" % (entry), level=8)
ecn_ctrls = [
c for c in srv_ctrls
@@ -491,7 +491,7 @@ class LDAP(object):
)
log.debug(
- " " + _("Change Type: %r (%r)") %(
+ " " + _("Change Type: %r (%r)") % (
change_type,
change_type_desc
),
@@ -499,7 +499,7 @@ class LDAP(object):
)
log.debug(
- " " + _("Previous DN: %r") %(previous_dn),
+ " " + _("Previous DN: %r") % (previous_dn),
level=8
)
@@ -553,7 +553,7 @@ class LDAP(object):
) = self.ldap.result3(_search)
except ldap.NO_SUCH_OBJECT, e:
- log.warning(_("Object %s searched no longer exists") %(base_dn))
+ log.warning(_("Object %s searched no longer exists") % (base_dn))
break
if callback:
@@ -565,7 +565,7 @@ class LDAP(object):
_results.extend(_result_data)
if (pages % 2) == 0:
- log.debug(_("%d results...") %(len(_results)))
+ log.debug(_("%d results...") % (len(_results)))
pctrls = [
c for c in _result_controls
@@ -699,7 +699,7 @@ class LDAP(object):
if len(self.ldap.supported_controls) < 1:
for control_num in SUPPORTED_LDAP_CONTROLS.keys():
log.debug(
- _("Checking for support for %s") %(
+ _("Checking for support for %s") % (
SUPPORTED_LDAP_CONTROLS[control_num]['desc']
),
level=8
@@ -739,7 +739,7 @@ class LDAP(object):
callback=callback,
primary_domain=%r,
secondary_domains=%r
- )""" %(
+ )""" % (
supported_control,
base_dn,
scope,
@@ -777,7 +777,7 @@ class LDAP(object):
attribute = attribute.lower()
log.debug(
- _("Getting attribute %s for user %s") %(attribute,user),
+ _("Getting attribute %s for user %s") % (attribute,user),
level=8
)
@@ -801,7 +801,7 @@ class LDAP(object):
(user_dn, user_attrs) = _result_data[0]
else:
log.warning(_("Could not get attribute %s for user %s")
- %(attribute,user['dn']))
+ % (attribute,user['dn']))
return None
@@ -810,7 +810,7 @@ class LDAP(object):
if not user_attrs.has_key(attribute):
log.debug(
_("Wanted attribute %s, which does not exist for user " + \
- "%r") %(
+ "%r") % (
attribute,
user_dn
),
@@ -838,7 +838,7 @@ class LDAP(object):
domain_root_dn,
ldap.SCOPE_SUBTREE,
# TODO: Configurable
- '(|(mail=%s)(mailalternateaddress=%s))' %(
+ '(|(mail=%s)(mailalternateaddress=%s))' % (
mail_address,
mail_address
),
@@ -886,7 +886,7 @@ class LDAP(object):
except:
log.warning(
_("LDAP modification of attribute %s for %s to value " + \
- "%s failed") %(attribute,user_dn,value)
+ "%s failed") % (attribute,user_dn,value)
)
def _list_domains(self):
@@ -952,7 +952,7 @@ class LDAP(object):
def _kolab_domain_root_dn(self, domain):
self._bind()
- log.debug(_("Finding domain root dn for domain %s") %(domain), level=8)
+ log.debug(_("Finding domain root dn for domain %s") % (domain), level=8)
bind_dn = conf.get('ldap', 'bind_dn')
bind_pw = conf.get('ldap', 'bind_pw')
@@ -967,7 +967,7 @@ class LDAP(object):
_results = self._search(
domain_base_dn,
ldap.SCOPE_SUBTREE,
- "(%s=%s)" %(domain_name_attribute,domain),
+ "(%s=%s)" % (domain_name_attribute,domain),
override_search='_regular_search'
)
@@ -994,7 +994,7 @@ class LDAP(object):
self._initial_sync_done = False
log.info(_("Listing users for domain %s (and %s)")
- %(primary_domain, ', '.join(secondary_domains)))
+ % (primary_domain, ', '.join(secondary_domains)))
self._bind()
@@ -1014,7 +1014,7 @@ class LDAP(object):
user_base_dn = conf.get_raw(
section,
'user_base_dn'
- ) %({'base_dn': domain_root_dn})
+ ) % ({'base_dn': domain_root_dn})
if conf.has_option(primary_domain, 'kolab_user_filter'):
section = primary_domain
@@ -1034,7 +1034,7 @@ class LDAP(object):
kolab_user_scope = LDAP_SCOPE[_kolab_user_scope]
else:
log.warning(
- _("LDAP Search scope %s not found, using 'sub'") %(
+ _("LDAP Search scope %s not found, using 'sub'") % (
_kolab_user_scope
)
)
@@ -1051,8 +1051,8 @@ class LDAP(object):
try:
self.ldap.simple_bind_s(bind_dn, bind_pw)
except ldap.SERVER_DOWN, e:
- error = eval("%s" %(e))
- log.error(_("Error binding to LDAP: %s") %(error['desc']))
+ error = eval("%s" % (e))
+ log.error(_("Error binding to LDAP: %s") % (error['desc']))
# TODO: Exit the fork (if fork!)
return
@@ -1077,10 +1077,10 @@ class LDAP(object):
)
if callback == None:
- log.info(_("Found %d users") %(len(_search)))
+ log.info(_("Found %d users") % (len(_search)))
log.debug(_("Iterating over %d users, making sure we have the " + \
- "necessary attributes...") %(len(_search)), level=6)
+ "necessary attributes...") % (len(_search)), level=6)
users = []
@@ -1106,7 +1106,7 @@ class LDAP(object):
if (num_user % 1000) == 0:
log.debug(
_("Done iterating over user %d of %d")
- %(num_user,num_users),
+ % (num_user,num_users),
level=3
)
@@ -1189,7 +1189,7 @@ class LDAP(object):
# or 1 (which should be the entry we're looking at here)
if len(results) == 0:
log.debug(
- _("No results for mail address %s found") %(
+ _("No results for mail address %s found") % (
_primary_mail
),
level=8
@@ -1200,7 +1200,7 @@ class LDAP(object):
if len(results) == 1:
log.debug(
- _("1 result for address %s found, verifying") %(
+ _("1 result for address %s found, verifying") % (
_primary_mail
),
level=8
@@ -1211,7 +1211,7 @@ class LDAP(object):
if not result[0] == user['dn']:
log.debug(
_("Too bad, primary email address %s " + \
- "already in use for %s (we are %s)") %(
+ "already in use for %s (we are %s)") % (
_primary_mail,
result[0],
user['dn']
@@ -1226,7 +1226,7 @@ class LDAP(object):
continue
i += 1
- _primary_mail = "%s%d@%s" %(
+ _primary_mail = "%s%d@%s" % (
primary_mail.split('@')[0],
i,
primary_mail.split('@')[1]
@@ -1289,7 +1289,7 @@ class LDAP(object):
# or 1 (which should be the entry we're looking at here)
if len(results) == 0:
log.debug(
- _("No results for address %s found") %(
+ _("No results for address %s found") % (
__secondary_mail
),
level=8
@@ -1301,7 +1301,7 @@ class LDAP(object):
if len(results) == 1:
log.debug(
_("1 result for address %s found, " + \
- "verifying...") %(
+ "verifying...") % (
__secondary_mail
),
level=8
@@ -1313,7 +1313,7 @@ class LDAP(object):
log.debug(
_("Too bad, secondary email " + \
"address %s already in use for " + \
- "%s (we are %s)") %(
+ "%s (we are %s)") % (
__secondary_mail,
result[0],
user['dn']
@@ -1328,7 +1328,7 @@ class LDAP(object):
continue
i += 1
- __secondary_mail = "%s%d@%s" %(
+ __secondary_mail = "%s%d@%s" % (
_secondary_mail.split('@')[0],
i,
_secondary_mail.split('@')[1]
@@ -1437,7 +1437,7 @@ class LDAP(object):
elif kw['change_type'] == 2:
# TODO: Use Cyrus SASL authorization ID
- folder = 'user/%s' %(user['mail'].lower())
+ folder = 'user/%s' % (user['mail'].lower())
# TODO: Verify if folder exists
pykolab.imap.delete_mailfolder(folder)
done = True
diff --git a/pykolab/cli/cmd_export_mailbox.py b/pykolab/cli/cmd_export_mailbox.py
index eab89d0..2e0875c 100644
--- a/pykolab/cli/cmd_export_mailbox.py
+++ b/pykolab/cli/cmd_export_mailbox.py
@@ -68,7 +68,7 @@ def execute(*args, **kw):
)
mboxlist_proc = subprocess.Popen(
- ['grep', '-E', '\s*%s\s*.*i.*p.*' %(user)],
+ ['grep', '-E', '\s*%s\s*.*i.*p.*' % (user)],
stdin=ctl_mboxlist.stdout,
stdout=subprocess.PIPE
)
@@ -78,7 +78,7 @@ def execute(*args, **kw):
# TODO: Handle errors from ctl_mboxlist process (stderr)
mboxlist_output = mboxlist_proc.communicate()[0]
- zipper_args = [ 'zip', '-r', '%s.zip' %(user) ]
+ zipper_args = [ 'zip', '-r', '%s.zip' % (user) ]
directories = []
for mbox_internal in mboxlist_output.split('\n'):
@@ -95,7 +95,7 @@ def execute(*args, **kw):
)
for partition in partitions:
- mbox_dir = '%s/domain/%s/%s/%s/user/%s/' %(
+ mbox_dir = '%s/domain/%s/%s/%s/user/%s/' % (
partition,
domain[0],
domain,
@@ -108,7 +108,7 @@ def execute(*args, **kw):
else:
log.debug(
- _('%s is not a directory') %(mbox_dir),
+ _('%s is not a directory') % (mbox_dir),
level=5
)
@@ -118,8 +118,8 @@ def execute(*args, **kw):
stdout=subprocess.PIPE
).communicate()[0]
- print >> sys.stderr, _("ZIP file at %s.zip") %(user)
+ print >> sys.stderr, _("ZIP file at %s.zip") % (user)
else:
- print >> sys.stderr, _("No directories found for user %s") %(user)
+ print >> sys.stderr, _("No directories found for user %s") % (user)
sys.exit(1)
diff --git a/pykolab/cli/cmd_list_domains.py b/pykolab/cli/cmd_list_domains.py
index 0bc2d27..cf12ee4 100644
--- a/pykolab/cli/cmd_list_domains.py
+++ b/pykolab/cli/cmd_list_domains.py
@@ -38,7 +38,7 @@ def execute(*args, **kw):
#print "domains:", domains['list']
- print "%-39s %-40s" %("Primary Domain Name Space","Secondary Domain Name Space(s)")
+ print "%-39s %-40s" % ("Primary Domain Name Space","Secondary Domain Name Space(s)")
# TODO: Take a hint in --quiet, and otherwise print out a nice table
# with headers and such.
@@ -46,6 +46,6 @@ def execute(*args, **kw):
if isinstance(domains['list'][domain_dn]['associateddomain'], list):
print domains['list'][domain_dn]['associateddomain'][0]
for domain_alias in domains['list'][domain_dn]['associateddomain'][1:]:
- print "%-39s %-40s" %('', domain_alias)
+ print "%-39s %-40s" % ('', domain_alias)
else:
print domains['list'][domain_dn]['associateddomain']
diff --git a/pykolab/cli/cmd_list_mailboxes.py b/pykolab/cli/cmd_list_mailboxes.py
index ae0444e..547eb74 100644
--- a/pykolab/cli/cmd_list_mailboxes.py
+++ b/pykolab/cli/cmd_list_mailboxes.py
@@ -31,7 +31,7 @@ imap = pykolab.imap
def __init__():
commands.register('list_mailboxes', execute, description="List mailboxes.\n" + \
- "%-28s" %('') + \
+ "%-28s" % ('') + \
"Use wildcards '*' and '%' for more control.\n")
def cli_options():
diff --git a/pykolab/cli/cmd_sync.py b/pykolab/cli/cmd_sync.py
index 14dd87d..348c010 100644
--- a/pykolab/cli/cmd_sync.py
+++ b/pykolab/cli/cmd_sync.py
@@ -38,7 +38,7 @@ def execute(*args, **kw):
domains = auth.list_domains()
end_time = time.time()
log.debug(
- _("Found %d domains in %d seconds") %(
+ _("Found %d domains in %d seconds") % (
len(domains),
(end_time-start_time)
),
@@ -48,13 +48,13 @@ def execute(*args, **kw):
all_folders = []
for primary_domain,secondary_domains in domains:
- log.debug(_("Running for domain %s") %(primary_domain), level=8)
+ log.debug(_("Running for domain %s") % (primary_domain), level=8)
auth.connect(primary_domain)
start_time = time.time()
auth.synchronize(primary_domain, secondary_domains)
end_time = time.time()
log.info(_("Synchronizing users for %s took %d seconds")
- %(primary_domain, (end_time-start_time))
+ % (primary_domain, (end_time-start_time))
)
diff --git a/pykolab/cli/cmd_transfer_mailbox.py b/pykolab/cli/cmd_transfer_mailbox.py
index 4f0de09..e7a7acc 100644
--- a/pykolab/cli/cmd_transfer_mailbox.py
+++ b/pykolab/cli/cmd_transfer_mailbox.py
@@ -51,7 +51,7 @@ def execute(*args, **kw):
if mbox_parts['domain'] == None:
user_identifier = mbox_parts['path_parts'][1]
else:
- user_identifier = "%s@%s" %(mbox_parts['path_parts'][1], mbox_parts['domain'])
+ user_identifier = "%s@%s" % (mbox_parts['path_parts'][1], mbox_parts['domain'])
print "User Identifier:", user_identifier
diff --git a/pykolab/cli/commands.py b/pykolab/cli/commands.py
index ea083ed..7236b0b 100644
--- a/pykolab/cli/commands.py
+++ b/pykolab/cli/commands.py
@@ -42,9 +42,9 @@ def __init__():
if filename.startswith('cmd_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
cmd_name = module_name.replace('cmd_', '')
- #print "exec(\"from %s import __init__ as %s_register\"" %(module_name,cmd_name)
- exec("from %s import __init__ as %s_register" %(module_name,cmd_name))
- exec("%s_register()" %(cmd_name))
+ #print "exec(\"from %s import __init__ as %s_register\"" % (module_name,cmd_name)
+ exec("from %s import __init__ as %s_register" % (module_name,cmd_name))
+ exec("%s_register()" % (cmd_name))
for dirname in dirnames:
register_group(commands_path, dirname)
@@ -85,21 +85,21 @@ def list_commands(*args, **kw):
if __commands[_command].has_key('function'):
# This is a top-level command
if not __commands[_command]['description'] == None:
- print "%-25s - %s" %(_command.replace('_','-'),__commands[_command]['description'])
+ print "%-25s - %s" % (_command.replace('_','-'),__commands[_command]['description'])
else:
- print "%-25s" %(_command.replace('_','-'))
+ print "%-25s" % (_command.replace('_','-'))
for _command in _commands:
if not __commands[_command].has_key('function'):
# This is a nested command
- print "\n" + _("Command Group: %s") %(_command) + "\n"
+ print "\n" + _("Command Group: %s") % (_command) + "\n"
___commands = __commands[_command].keys()
___commands.sort()
for __command in ___commands:
if not __commands[_command][__command]['description'] == None:
- print "%-4s%-21s - %s" %('',__command.replace('_','-'),__commands[_command][__command]['description'])
+ print "%-4s%-21s - %s" % ('',__command.replace('_','-'),__commands[_command][__command]['description'])
else:
- print "%-4s%-21s" %('',__command.replace('_','-'))
+ print "%-4s%-21s" % ('',__command.replace('_','-'))
def execute(cmd_name, *args, **kw):
if not commands.has_key(cmd_name):
@@ -115,15 +115,15 @@ def execute(cmd_name, *args, **kw):
group = commands[cmd_name]['group']
command_name = commands[cmd_name]['cmd_name']
try:
- exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" %(group,command_name,group,command_name))
- exec("%s_%s_cli_options()" %(group,command_name))
+ exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" % (group,command_name,group,command_name))
+ exec("%s_%s_cli_options()" % (group,command_name))
except ImportError, e:
pass
else:
try:
- exec("from cmd_%s import cli_options as %s_cli_options" %(cmd_name,cmd_name))
- exec("%s_cli_options()" %(cmd_name))
+ exec("from cmd_%s import cli_options as %s_cli_options" % (cmd_name,cmd_name))
+ exec("%s_cli_options()" % (cmd_name))
except ImportError, e:
pass
@@ -144,13 +144,13 @@ def register_group(dirname, module):
if filename.startswith('cmd_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
cmd_name = module_name.replace('cmd_', '')
- #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" %(module,module_name,module,cmd_name)
- exec("from %s.%s import __init__ as %s_%s_register" %(module,module_name,module,cmd_name))
- exec("%s_%s_register()" %(module,cmd_name))
+ #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" % (module,module_name,module,cmd_name)
+ exec("from %s.%s import __init__ as %s_%s_register" % (module,module_name,module,cmd_name))
+ exec("%s_%s_register()" % (module,cmd_name))
def register(cmd_name, func, group=None, description=None, aliases=[]):
if not group == None:
- command = "%s_%s" %(group,cmd_name)
+ command = "%s_%s" % (group,cmd_name)
else:
command = cmd_name
@@ -158,7 +158,7 @@ def register(cmd_name, func, group=None, description=None, aliases=[]):
aliases = [aliases]
if commands.has_key(command):
- log.fatal(_("Command '%s' already registered") %(command))
+ log.fatal(_("Command '%s' already registered") % (command))
sys.exit(1)
if callable(func):
@@ -180,7 +180,7 @@ def register(cmd_name, func, group=None, description=None, aliases=[]):
for alias in aliases:
commands[alias] = {
'function': func,
- 'description': _("Alias for %s") %(cmd_name)
+ 'description': _("Alias for %s") % (cmd_name)
}
##
diff --git a/pykolab/cli/telemetry/cmd_examine_command_issue.py b/pykolab/cli/telemetry/cmd_examine_command_issue.py
index f4248a0..fc8d3f7 100644
--- a/pykolab/cli/telemetry/cmd_examine_command_issue.py
+++ b/pykolab/cli/telemetry/cmd_examine_command_issue.py
@@ -75,7 +75,7 @@ def execute(*args, **kw):
id=session.server_id
).first()
- print _("Session by %s on server %s") %(user.sasl_username,server.fqdn)
+ print _("Session by %s on server %s") % (user.sasl_username,server.fqdn)
command_issues = db.query(
telemetry.TelemetryCommandIssue
@@ -99,7 +99,7 @@ def execute(*args, **kw):
if command_issue.id == _command_issue.id:
print "========="
- print "Client(%d): %s %s %s" %(
+ print "Client(%d): %s %s %s" % (
_command_issue.id,
_command_issue.command_tag,
command.command,
@@ -116,7 +116,7 @@ def execute(*args, **kw):
server_response_lines = server_response.response.split('\n');
for server_response_line in server_response_lines:
- print "Server(%d): %s" %(
+ print "Server(%d): %s" % (
server_response.id,
server_response_line
)
diff --git a/pykolab/cli/telemetry/cmd_examine_session.py b/pykolab/cli/telemetry/cmd_examine_session.py
index a1273fd..38dac94 100644
--- a/pykolab/cli/telemetry/cmd_examine_session.py
+++ b/pykolab/cli/telemetry/cmd_examine_session.py
@@ -100,7 +100,7 @@ def execute(*args, **kw):
return
- print _("Session by %s on server %s") %(user.sasl_username,server.fqdn)
+ print _("Session by %s on server %s") % (user.sasl_username,server.fqdn)
command_issues = db.query(
telemetry.TelemetryCommandIssue
@@ -121,7 +121,7 @@ def execute(*args, **kw):
id=command_issue.command_arg_id
).first()
- print "Client(%d): %s %s %s" %(
+ print "Client(%d): %s %s %s" % (
command_issue.id,
command_issue.command_tag,
command.command,
@@ -137,7 +137,7 @@ def execute(*args, **kw):
for server_response in server_responses:
server_response_lines = server_response.response.split('\n');
for server_response_line in server_response_lines:
- print "Server(%d): %s" %(
+ print "Server(%d): %s" % (
server_response.id,
server_response_line
)
diff --git a/pykolab/cli/telemetry/cmd_list_sessions.py b/pykolab/cli/telemetry/cmd_list_sessions.py
index 1f6503e..c90ef9d 100644
--- a/pykolab/cli/telemetry/cmd_list_sessions.py
+++ b/pykolab/cli/telemetry/cmd_list_sessions.py
@@ -58,7 +58,7 @@ def execute(*args, **kw):
id=session.user_id
).first()
- print _("Session for user %s started at %s with ID %s") %(
+ print _("Session for user %s started at %s with ID %s") % (
user.sasl_username,
session.start,
session.id
diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py
index 01282f2..7d850b6 100644
--- a/pykolab/conf/__init__.py
+++ b/pykolab/conf/__init__.py
@@ -82,7 +82,7 @@ class Conf(object):
# But, they should be available in our class as well
for option in self.defaults.__dict__.keys():
- log.debug(_("Setting %s to %r (from defaults)") %(option, self.defaults.__dict__[option]), level=8)
+ log.debug(_("Setting %s to %r (from defaults)") % (option, self.defaults.__dict__[option]), level=8)
setattr(self,option,self.defaults.__dict__[option])
# This is where we check our parser for the defaults being set there.
@@ -94,17 +94,17 @@ class Conf(object):
if hasattr(self,'cli_keywords') and not self.cli_keywords == None:
for option in self.cli_keywords.__dict__.keys():
retval = False
- if hasattr(self, "check_setting_%s" %(option)):
+ if hasattr(self, "check_setting_%s" % (option)):
exec("retval = self.check_setting_%s(%r)" % (option, self.cli_keywords.__dict__[option]))
# The warning, error or confirmation dialog is in the check_setting_%s() function
if not retval:
continue
- log.debug(_("Setting %s to %r (from CLI, verified)") %(option, self.cli_keywords.__dict__[option]), level=8)
+ log.debug(_("Setting %s to %r (from CLI, verified)") % (option, self.cli_keywords.__dict__[option]), level=8)
setattr(self,option,self.cli_keywords.__dict__[option])
else:
- log.debug(_("Setting %s to %r (from CLI, not checked)") %(option, self.cli_keywords.__dict__[option]), level=8)
+ log.debug(_("Setting %s to %r (from CLI, not checked)") % (option, self.cli_keywords.__dict__[option]), level=8)
setattr(self,option,self.cli_keywords.__dict__[option])
def load_config(self, config):
@@ -136,8 +136,8 @@ class Conf(object):
elif isinstance(self.defaults.__dict__[section][key], dict):
value = eval(config.get(section,key))
- if hasattr(self,"check_setting_%s_%s" %(section,key)):
- exec("retval = self.check_setting_%s_%s(%r)" %(section,key,value))
+ if hasattr(self,"check_setting_%s_%s" % (section,key)):
+ exec("retval = self.check_setting_%s_%s(%r)" % (section,key,value))
if not retval:
# We just don't set it, check_setting_%s should have
# taken care of the error messages
@@ -145,10 +145,10 @@ class Conf(object):
if not self.defaults.__dict__[section][key] == value:
if key.count('password') >= 1:
- log.debug(_("Setting %s_%s to '****' (from configuration file)") %(section,key), level=8)
+ log.debug(_("Setting %s_%s to '****' (from configuration file)") % (section,key), level=8)
else:
- log.debug(_("Setting %s_%s to %r (from configuration file)") %(section,key,value), level=8)
- setattr(self,"%s_%s" %(section,key),value)
+ log.debug(_("Setting %s_%s to %r (from configuration file)") % (section,key,value), level=8)
+ setattr(self,"%s_%s" % (section,key),value)
def options_set_from_config(self):
"""
@@ -193,18 +193,18 @@ class Conf(object):
elif isinstance(self.defaults.__dict__['testing'][key], dict):
value = eval(config.get('testing',key))
- if hasattr(self,"check_setting_%s_%s" %('testing',key)):
+ if hasattr(self,"check_setting_%s_%s" % ('testing',key)):
exec("retval = self.check_setting_%s_%s(%r)" % ('testing',key,value))
if not retval:
# We just don't set it, check_setting_%s should have
# taken care of the error messages
continue
- setattr(self,"%s_%s" %('testing',key),value)
+ setattr(self,"%s_%s" % ('testing',key),value)
if key.count('password') >= 1:
- log.debug(_("Setting %s_%s to '****' (from configuration file)") %('testing',key), level=8)
+ log.debug(_("Setting %s_%s to '****' (from configuration file)") % ('testing',key), level=8)
else:
- log.debug(_("Setting %s_%s to %r (from configuration file)") %('testing',key,value), level=8)
+ log.debug(_("Setting %s_%s to %r (from configuration file)") % ('testing',key,value), level=8)
def check_config(self, val=None):
"""
@@ -345,21 +345,21 @@ class Conf(object):
for item in items:
mode = self.cfg_parser.get('kolab',item)
- print "%s = %s" %(item,mode)
+ print "%s = %s" % (item,mode)
if not self.cfg_parser.has_section(mode):
- print "WARNING: No configuration section %s for item %s" %(mode,item)
+ print "WARNING: No configuration section %s for item %s" % (mode,item)
continue
keys = self.cfg_parser.options(mode)
keys.sort()
if self.cfg_parser.has_option(mode, 'leave_this_one_to_me'):
- print "Ignoring section %s" %(mode,)
+ print "Ignoring section %s" % (mode,)
continue
for key in keys:
- print "%s_%s = %s" %(mode, key ,self.cfg_parser.get(mode,key))
+ print "%s_%s = %s" % (mode, key ,self.cfg_parser.get(mode,key))
def read_config(self, value=None):
"""
@@ -384,7 +384,7 @@ class Conf(object):
exec("args = %r" % args)
- print "%s/%s: %r" %(args[0],args[1],self.get(args[0], args[1]))
+ print "%s/%s: %r" % (args[0],args[1],self.get(args[0], args[1]))
# if len(args) == 3:
# # Return non-zero if no match
@@ -411,7 +411,7 @@ class Conf(object):
log.error(_("Insufficient options. Need section, key and value -in that order."))
if not self.cfg_parser.has_section(args[0]):
- log.error(_("No section '%s' exists.") %(args[0]))
+ log.error(_("No section '%s' exists.") % (args[0]))
self.cfg_parser.set(args[0], args[1], args[2])
fp = open(self.cli_keywords.config_file, "w+")
@@ -442,7 +442,7 @@ class Conf(object):
# But, they should be available in our class as well
for option in self.cli_parser.defaults.keys():
- log.debug(_("Setting %s to %r (from the default values for CLI options)") %(option, self.cli_parser.defaults[option]), level=8)
+ log.debug(_("Setting %s to %r (from the default values for CLI options)") % (option, self.cli_parser.defaults[option]), level=8)
setattr(self,option,self.cli_parser.defaults[option])
def has_section(self, section):
@@ -501,11 +501,11 @@ class Conf(object):
if self.cfg_parser.has_option(section, key):
return self.cfg_parser.get(section,key)
- if hasattr(self, "get_%s_%s" %(section,key)):
+ if hasattr(self, "get_%s_%s" % (section,key)):
try:
- exec("retval = self.get_%s_%s(quiet)" %(section,key))
+ exec("retval = self.get_%s_%s(quiet)" % (section,key))
except Exception, e:
- log.error(_("Could not execute configuration function: %s") %("get_%s_%s(quiet=%r)" %(section,key,quiet)))
+ log.error(_("Could not execute configuration function: %s") % ("get_%s_%s(quiet=%r)" % (section,key,quiet)))
return None
return retval
@@ -513,12 +513,12 @@ class Conf(object):
if quiet:
return ""
else:
- log.warning(_("Option %s/%s does not exist in config file %s, pulling from defaults") %(section, key, self.config_file))
- if hasattr(self.defaults, "%s_%s" %(section,key)):
- return getattr(self.defaults, "%s_%s" %(section,key))
- elif hasattr(self.defaults, "%s" %(section)):
- if key in getattr(self.defaults, "%s" %(section)):
- _dict = getattr(self.defaults, "%s" %(section))
+ log.warning(_("Option %s/%s does not exist in config file %s, pulling from defaults") % (section, key, self.config_file))
+ if hasattr(self.defaults, "%s_%s" % (section,key)):
+ return getattr(self.defaults, "%s_%s" % (section,key))
+ elif hasattr(self.defaults, "%s" % (section)):
+ if key in getattr(self.defaults, "%s" % (section)):
+ _dict = getattr(self.defaults, "%s" % (section))
return _dict[key]
else:
log.warning(_("Option does not exist in defaults."))
@@ -534,10 +534,10 @@ class Conf(object):
self.config_file = value
return True
else:
- log.error(_("Configuration file %s not readable.") %(value))
+ log.error(_("Configuration file %s not readable.") % (value))
return False
else:
- log.error(_("Configuration file %s does not exist.") %(value))
+ log.error(_("Configuration file %s does not exist.") % (value))
return False
def check_setting_debuglevel(self, value):
@@ -607,7 +607,7 @@ class Conf(object):
selectively = False
for item in [ 'calendar', 'contacts', 'mail' ]:
if self.cli_keywords.__dict__[item]:
- log.debug(_("Found you specified a specific set of items to test: %s") %(item), level=8)
+ log.debug(_("Found you specified a specific set of items to test: %s") % (item), level=8)
selectively = item
if not selectively:
@@ -615,7 +615,7 @@ class Conf(object):
self.contacts = True
self.mail = True
else:
- log.debug(_("Selectively selecting: %s") %(selectively), level=8)
+ log.debug(_("Selectively selecting: %s") % (selectively), level=8)
setattr(self, selectively, True)
self.test_suites.append('zpush')
diff --git a/pykolab/conf/entitlement.py b/pykolab/conf/entitlement.py
index 6a85711..54370c7 100644
--- a/pykolab/conf/entitlement.py
+++ b/pykolab/conf/entitlement.py
@@ -55,7 +55,7 @@ class Entitlement(object):
if (bool)(ca_cert.has_expired()):
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s" %(ca_cert_file))
+ "certificate at %s" % (ca_cert_file))
# TODO: Check validity and warn ~1-2 months in advance.
@@ -78,7 +78,7 @@ class Entitlement(object):
if not ca_cert_issuer_hash_digest in self.entitlement_verification:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(ca_cert_file)
+ "certificate at %s") % (ca_cert_file)
ca_cert_subject_hash = subprocess.Popen(
[
@@ -96,7 +96,7 @@ class Entitlement(object):
if not ca_cert_subject_hash_digest in self.entitlement_verification:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(ca_cert_file)
+ "certificate at %s") % (ca_cert_file)
customer_cert_issuer_hash = subprocess.Popen(
[
@@ -114,7 +114,7 @@ class Entitlement(object):
if not customer_cert_issuer_hash_digest in self.entitlement_verification:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(customer_cert_file)
+ "certificate at %s") % (customer_cert_file)
if not ca_cert_issuer.countryName == ca_cert_subject.countryName:
raise Exception, _("Invalid entitlement certificate")
@@ -129,7 +129,7 @@ class Entitlement(object):
if not root == '/etc/kolab/entitlement.d/':
continue
for entitlement_file in files:
- log.debug(_("Parsing entitlement file %s") %(entitlement_file), level=8)
+ log.debug(_("Parsing entitlement file %s") % (entitlement_file), level=8)
if os.access(os.path.join(root, entitlement_file), os.R_OK):
self.entitlement_files.append(
@@ -138,7 +138,7 @@ class Entitlement(object):
else:
print >> sys.stderr, \
- _("License file %s not readable!") %(
+ _("License file %s not readable!") % (
os.path.join(root, entitlement_file)
)
@@ -227,7 +227,7 @@ class License(object):
if not customer_cert_serial == cert_serial:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(customer_cert_file)
+ "certificate at %s") % (customer_cert_file)
customer_cert_issuer_hash = subprocess.Popen(
[
@@ -243,7 +243,7 @@ class License(object):
if not customer_cert_issuer_hash == cert_issuer_hash:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(customer_cert_file)
+ "certificate at %s") % (customer_cert_file)
customer_cert_subject_hash = subprocess.Popen(
[
@@ -259,7 +259,7 @@ class License(object):
if not customer_cert_subject_hash == cert_subject_hash:
raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") %(customer_cert_file)
+ "certificate at %s") % (customer_cert_file)
def get(self):
return self.entitlement
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index da592c4..0c77a54 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -98,7 +98,7 @@ class IMAP(object):
self._imap[hostname] = cyrus.Cyrus(uri)
# Actually connect
if login:
- log.debug(_("Logging on to Cyrus IMAP server %s") %(hostname), level=8)
+ log.debug(_("Logging on to Cyrus IMAP server %s") % (hostname), level=8)
self._imap[hostname].login(admin_login, admin_password)
self._imap[hostname].logged_in = True
@@ -107,7 +107,7 @@ class IMAP(object):
self._imap[hostname] = dovecot.Dovecot(uri)
# Actually connect
if login:
- log.debug(_("Logging on to Dovecot IMAP server %s") %(hostname), level=8)
+ log.debug(_("Logging on to Dovecot IMAP server %s") % (hostname), level=8)
self._imap[hostname].login(admin_login, admin_password)
self._imap[hostname].logged_in = True
@@ -116,7 +116,7 @@ class IMAP(object):
self._imap[hostname] = imaplib.IMAP4(hostname, port)
# Actually connect
if login:
- log.debug(_("Logging on to generic IMAP server %s") %(hostname), level=8)
+ log.debug(_("Logging on to generic IMAP server %s") % (hostname), level=8)
self._imap[hostname].login(admin_login, admin_password)
self._imap[hostname].logged_in = True
@@ -134,9 +134,9 @@ class IMAP(object):
elif hasattr(self._imap[hostname], 'noop') and callable(self._imap[hostname].noop):
self._imap[hostname].noop()
- log.debug(_("Reusing existing IMAP server connection to %s") %(hostname), level=8)
+ log.debug(_("Reusing existing IMAP server connection to %s") % (hostname), level=8)
except:
- log.debug(_("Reconnecting to IMAP server %s") %(hostname), level=8)
+ log.debug(_("Reconnecting to IMAP server %s") % (hostname), level=8)
self.disconnect(hostname)
self.connect()
@@ -159,11 +159,11 @@ class IMAP(object):
if hasattr(self.imap, name):
return getattr(self.imap, name)
else:
- raise AttributeError, _("%r has no attribute %s") %(self,name)
+ raise AttributeError, _("%r has no attribute %s") % (self,name)
def has_folder(self, folder):
folders = self.imap.lm(folder)
- log.debug(_("Looking for folder '%s', we found folders: %r") %(folder,folders), level=8)
+ log.debug(_("Looking for folder '%s', we found folders: %r") % (folder,folders), level=8)
# Greater then one, this folder may have subfolders.
if len(folders) > 0:
return True
@@ -176,20 +176,20 @@ class IMAP(object):
for user in users:
if type(user) == dict:
if user.has_key('old_mail'):
- inbox = "user/%s" %(user['mail'])
- old_inbox = "user/%s" %(user['old_mail'])
+ inbox = "user/%s" % (user['mail'])
+ old_inbox = "user/%s" % (user['old_mail'])
if self.has_folder(old_inbox):
- log.debug(_("Found old INBOX folder %s") %(old_inbox), level=8)
+ log.debug(_("Found old INBOX folder %s") % (old_inbox), level=8)
if not self.has_folder(inbox):
- log.info(_("Renaming INBOX from %s to %s") %(old_inbox,inbox))
+ log.info(_("Renaming INBOX from %s to %s") % (old_inbox,inbox))
self.imap.rename(old_inbox,inbox)
self.inbox_folders.append(inbox)
else:
- log.warning(_("Moving INBOX folder %s won't succeed as target folder %s already exists") %(old_inbox,inbox))
+ log.warning(_("Moving INBOX folder %s won't succeed as target folder %s already exists") % (old_inbox,inbox))
else:
- log.debug(_("Did not find old folder user/%s to rename") %(user['old_mail']), level=8)
+ log.debug(_("Did not find old folder user/%s to rename") % (user['old_mail']), level=8)
else:
log.debug(_("Value for user is not a dictionary"), level=8)
@@ -223,15 +223,15 @@ class IMAP(object):
for folder in inbox_folders:
additional_folders = None
- if not self.has_folder("user%s%s" %(self.imap.separator, folder)):
+ if not self.has_folder("user%s%s" % (self.imap.separator, folder)):
# TODO: Perhaps this block is moot
log.info(_("Creating new INBOX for user (%d): %s")
- %(1,folder))
+ % (1,folder))
try:
- self.imap.cm("user%s%s" %(self.imap.separator, folder))
+ self.imap.cm("user%s%s" % (self.imap.separator, folder))
except:
log.warning(
- _("Mailbox already exists: user%s%s") %(
+ _("Mailbox already exists: user%s%s") % (
self.imap.separator,folder
)
)
@@ -240,7 +240,7 @@ class IMAP(object):
if conf.get('kolab', 'imap_backend') == 'cyrus-imap':
self.imap._setquota(
- "user%s%s" %(self.imap.separator, folder),
+ "user%s%s" % (self.imap.separator, folder),
0
)
@@ -283,15 +283,15 @@ class IMAP(object):
try:
self.imap.cm(folder_name)
except:
- log.warning(_("Mailbox already exists: user/%s") %(folder))
+ log.warning(_("Mailbox already exists: user/%s") % (folder))
if additional_folders[additional_folder].has_key("annotations"):
for annotation in additional_folders[additional_folder]["annotations"].keys():
if conf.get('kolab', 'imap_backend') == 'cyrus-imap':
self.imap._setannotation(
folder_name,
- "%s" %(annotation),
- "%s" %(additional_folders[additional_folder]["annotations"][annotation])
+ "%s" % (annotation),
+ "%s" % (additional_folders[additional_folder]["annotations"][annotation])
)
if additional_folders[additional_folder].has_key("quota"):
@@ -304,8 +304,8 @@ class IMAP(object):
for acl in additional_folders[additional_folder]["acls"].keys():
self.imap.sam(
folder_name,
- "%s" %(acl),
- "%s" %(additional_folders[additional_folder]["acls"][acl])
+ "%s" % (acl),
+ "%s" % (additional_folders[additional_folder]["acls"][acl])
)
backend = conf.get('kolab', 'imap_backend')
@@ -386,7 +386,7 @@ class IMAP(object):
folder = "user/%s" % user[_inbox_folder_attr]
elif type(user) == str:
quota = auth.get_user_attribute(user, 'quota')
- folder = "user/%s" %(user)
+ folder = "user/%s" % (user)
folder = folder.lower()
@@ -394,7 +394,7 @@ class IMAP(object):
(used,current_quota) = self.imap.lq(folder)
except:
# TODO: Go in fact correct the quota.
- log.warning(_("Cannot get current IMAP quota for folder %s") %(folder))
+ log.warning(_("Cannot get current IMAP quota for folder %s") % (folder))
used = 0
current_quota = 0
@@ -407,18 +407,18 @@ class IMAP(object):
}
)
- log.debug(_("Quota for %s currently is %s") %(folder, current_quota), level=7)
+ log.debug(_("Quota for %s currently is %s") % (folder, current_quota), level=7)
if new_quota == None:
continue
if not int(new_quota) == int(quota):
- log.info(_("Adjusting authentication database quota for folder %s to %d") %(folder,int(new_quota)))
+ log.info(_("Adjusting authentication database quota for folder %s to %d") % (folder,int(new_quota)))
quota = int(new_quota)
auth.set_user_attribute(primary_domain, user, _quota_attr, new_quota)
if not int(current_quota) == int(quota):
- log.info(_("Correcting quota for %s to %s (currently %s)") %(folder, quota, current_quota))
+ log.info(_("Correcting quota for %s to %s (currently %s)") % (folder, quota, current_quota))
self.imap._setquota(folder, quota)
def set_user_mailhost(self, users=[], primary_domain=None, secondary_domain=[], folders=[]):
@@ -457,7 +457,7 @@ class IMAP(object):
elif type(user) == str:
_mailserver = auth.get_user_attribute(user, _mailserver_attr)
- folder = "user/%s" %(user)
+ folder = "user/%s" % (user)
folder = folder.lower()
@@ -500,17 +500,17 @@ class IMAP(object):
folders = self.list_user_folders()
for folder in folders:
- log.debug(_("Checking folder: %s") %(folder), level=1)
+ log.debug(_("Checking folder: %s") % (folder), level=1)
try:
if inbox_folders.index(folder) > -1:
continue
else:
- log.info(_("Folder has no corresponding user (1): %s") %(folder))
- self.delete_mailfolder("user/%s" %(folder))
+ log.info(_("Folder has no corresponding user (1): %s") % (folder))
+ self.delete_mailfolder("user/%s" % (folder))
except:
- log.info(_("Folder has no corresponding user (2): %s") %(folder))
+ log.info(_("Folder has no corresponding user (2): %s") % (folder))
try:
- self.delete_mailfolder("user/%s" %(folder))
+ self.delete_mailfolder("user/%s" % (folder))
except:
pass
@@ -526,7 +526,7 @@ class IMAP(object):
log.error(_("Please don't give us just a user identifier"))
return
- log.info(_("Deleting folder %s") %(mailfolder_path))
+ log.info(_("Deleting folder %s") % (mailfolder_path))
self.imap.dm(mailfolder_path)
@@ -551,14 +551,14 @@ class IMAP(object):
if mbox_parts['domain']:
# List the shared and user folders
shared_folders = self.imap.lm(
- "shared/*@%s" %(mbox_parts['domain'])
+ "shared/*@%s" % (mbox_parts['domain'])
)
user_folders = self.imap.lm(
- "user/*@%s" %(mbox_parts['domain'])
+ "user/*@%s" % (mbox_parts['domain'])
)
- aci_identifier = "%s@%s" %(
+ aci_identifier = "%s@%s" % (
mbox_parts['path_parts'][1],
mbox_parts['domain']
)
@@ -566,10 +566,10 @@ class IMAP(object):
else:
shared_folders = self.imap.lm("shared/*")
user_folders = self.imap.lm("user/*")
- aci_identifier = "%s" %(mbox_parts['path_parts'][1])
+ aci_identifier = "%s" % (mbox_parts['path_parts'][1])
log.debug(
- _("Cleaning up ACL entries referring to identifier %s") %(
+ _("Cleaning up ACL entries referring to identifier %s") % (
aci_identifier
),
level=5
@@ -578,7 +578,7 @@ class IMAP(object):
# For all folders (shared and user), ...
folders = user_folders + shared_folders
- log.debug(_("Iterating over %d folders") %(len(folders)), level=5)
+ log.debug(_("Iterating over %d folders") % (len(folders)), level=5)
# ... loop through them and ...
for folder in folders:
@@ -609,7 +609,7 @@ class IMAP(object):
if not primary_domain == None:
for domain in [ primary_domain ] + secondary_domains:
- acceptable_domain_name_res.append(domain_re %(domain))
+ acceptable_domain_name_res.append(domain_re % (domain))
folders = []
@@ -624,14 +624,14 @@ class IMAP(object):
#print "Acceptable indeed"
#acceptable = True
#if not acceptable:
- #print "%s is not acceptable against %s yet using %s" %(folder.split('@')[1],folder,domain_name_re)
+ #print "%s is not acceptable against %s yet using %s" % (folder.split('@')[1],folder,domain_name_re)
#if acceptable:
- #folder_name = "%s@%s" %(folder.split(self.separator)[1].split('@')[0],folder.split('@')[1])
+ #folder_name = "%s@%s" % (folder.split(self.separator)[1].split('@')[0],folder.split('@')[1])
- folder_name = "%s@%s" %(folder.split(self.imap.separator)[1].split('@')[0],folder.split('@')[1])
+ folder_name = "%s@%s" % (folder.split(self.imap.separator)[1].split('@')[0],folder.split('@')[1])
else:
- folder_name = "%s" %(folder.split(self.imap.separator)[1])
+ folder_name = "%s" % (folder.split(self.imap.separator)[1])
if not folder_name == None:
if not folder_name in folders:
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index b9fb6e3..1515222 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -70,7 +70,7 @@ class Cyrus(cyruslib.CYRUS):
self.server = hostname
- self.uri = "%s://%s:%s" %(scheme,hostname,port)
+ self.uri = "%s://%s:%s" % (scheme,hostname,port)
cyruslib.CYRUS.__init__(self, self.uri)
@@ -115,7 +115,7 @@ class Cyrus(cyruslib.CYRUS):
prefix = _mailfolder['path_parts'].pop(0)
mbox = _mailfolder['path_parts'].pop(0)
if not _mailfolder['domain'] == None:
- mailfolder = "%s%s%s@%s" %(prefix,self.separator,mbox,_mailfolder['domain'])
+ mailfolder = "%s%s%s@%s" % (prefix,self.separator,mbox,_mailfolder['domain'])
# TODO: Workaround for undelete
if len(self.lm(mailfolder)) < 1:
@@ -126,7 +126,7 @@ class Cyrus(cyruslib.CYRUS):
if not self.murder:
return self.server
- log.debug(_("Checking actual backend server for folder %s through annotations") %(mailfolder), level=8)
+ log.debug(_("Checking actual backend server for folder %s through annotations") % (mailfolder), level=8)
if self.mbox.has_key(mailfolder):
return self.mbox[mailfolder]
@@ -140,11 +140,11 @@ class Cyrus(cyruslib.CYRUS):
break
if max_tries <= num_try:
- log.error(_("Could not get the annotations after %s tries.") %(num_try))
+ log.error(_("Could not get the annotations after %s tries.") % (num_try))
annotations = { mailfolder: { '/vendor/cmu/cyrus-imapd/server': self.server }}
break
- log.warning(_("No annotations for %s: %r") %(mailfolder,annotations))
+ log.warning(_("No annotations for %s: %r") % (mailfolder,annotations))
time.sleep(1)
@@ -156,7 +156,7 @@ class Cyrus(cyruslib.CYRUS):
if not imap._imap[server].mbox.has_key(mailfolder):
imap._imap[server].mbox[mailfolder] = server
- log.debug(_("Server for INBOX folder %s is %s") %(mailfolder,server), level=8)
+ log.debug(_("Server for INBOX folder %s is %s") % (mailfolder,server), level=8)
return server
@@ -166,22 +166,22 @@ class Cyrus(cyruslib.CYRUS):
"""
server = self.find_mailfolder_server(mailfolder)
#print "server:", server
- imap.connect('imap://%s:143' %(server))
+ imap.connect('imap://%s:143' % (server))
- log.debug(_("Setting quota for INBOX folder %s to %s") %(mailfolder,quota), level=8)
+ log.debug(_("Setting quota for INBOX folder %s to %s") % (mailfolder,quota), level=8)
try:
imap.setquota(mailfolder, quota)
except:
- log.error(_("Could not set quota for mailfolder %s") %(mailfolder))
+ log.error(_("Could not set quota for mailfolder %s") % (mailfolder))
def _rename(self, from_mailfolder, to_mailfolder, partition=None):
"""
Login to the actual backend server, then rename.
"""
server = self.find_mailfolder_server(from_mailfolder)
- imap.connect('imap://%s:143' %(server))
+ imap.connect('imap://%s:143' % (server))
- log.debug(_("Moving INBOX folder %s to %s") %(from_mailfolder,to_mailfolder), level=8)
+ log.debug(_("Moving INBOX folder %s to %s") % (from_mailfolder,to_mailfolder), level=8)
imap.rename(from_mailfolder, to_mailfolder, partition)
def _getannotation(self, *args, **kw):
@@ -193,17 +193,17 @@ class Cyrus(cyruslib.CYRUS):
Login to the actual backend server, then set annotation.
"""
server = self.find_mailfolder_server(mailfolder)
- imap.connect('imap://%s:143' %(server))
+ imap.connect('imap://%s:143' % (server))
- log.debug(_("Setting annotation %s on folder %s") %(annotation,mailfolder), level=8)
+ log.debug(_("Setting annotation %s on folder %s") % (annotation,mailfolder), level=8)
#if annotation.startswith('/private'):
imap.setannotation(mailfolder, annotation, value)
def _xfer(self, mailfolder, current_server, new_server):
- imap.connect('imap://%s:143' %(current_server))
- log.debug(_("Transferring folder %s from %s to %s") %(mailfolder, current_server, new_server), level=8)
+ imap.connect('imap://%s:143' % (current_server))
+ log.debug(_("Transferring folder %s from %s to %s") % (mailfolder, current_server, new_server), level=8)
imap.xfer(mailfolder, new_server)
def undelete_mailfolder(self, mailfolder, to_mailfolder=None, recursive=True):
@@ -250,20 +250,20 @@ class Cyrus(cyruslib.CYRUS):
target_folder = self.separator.join(target_mbox['path_parts'])
if not to_mailfolder == None:
- target_folder = "%s%s%s" %(target_folder,self.separator,mbox)
+ target_folder = "%s%s%s" % (target_folder,self.separator,mbox)
if not len(undelete_mbox['path_parts']) == 0:
- target_folder = "%s%s%s" %(target_folder,self.separator,self.separator.join(undelete_mbox['path_parts']))
+ target_folder = "%s%s%s" % (target_folder,self.separator,self.separator.join(undelete_mbox['path_parts']))
if target_folder in target_folders:
- target_folder = "%s%s%s" %(target_folder,self.separator,undelete_mbox['hex_timestamp'])
+ target_folder = "%s%s%s" % (target_folder,self.separator,undelete_mbox['hex_timestamp'])
target_folders.append(target_folder)
if not target_mbox['domain'] == None:
- target_folder = "%s@%s" %(target_folder,target_mbox['domain'])
+ target_folder = "%s@%s" % (target_folder,target_mbox['domain'])
- log.info(_("Undeleting %s to %s") %(undelete_folder,target_folder))
+ log.info(_("Undeleting %s to %s") % (undelete_folder,target_folder))
target_server = self.find_mailfolder_server(target_folder)
@@ -315,7 +315,7 @@ class Cyrus(cyruslib.CYRUS):
}
if not mbox['domain'] == None:
- verify_folder_search = "%s@%s" %(verify_folder_search, mbox['domain'])
+ verify_folder_search = "%s@%s" % (verify_folder_search, mbox['domain'])
folders = self.lm(verify_folder_search)
@@ -353,7 +353,7 @@ class Cyrus(cyruslib.CYRUS):
}
if not mbox['domain'] == None:
- deleted_folder_search = "%s@%s" %(deleted_folder_search,mbox['domain'])
+ deleted_folder_search = "%s@%s" % (deleted_folder_search,mbox['domain'])
folders = self.lm(deleted_folder_search)
diff --git a/pykolab/logger.py b/pykolab/logger.py
index 2a517a8..e1d1189 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -99,6 +99,6 @@ class Logger(logging.Logger):
if level <= self.debuglevel:
# TODO: Not the way it's supposed to work!
- self.log(logging.DEBUG, '[%d]: %s' %(os.getpid(),msg))
+ self.log(logging.DEBUG, '[%d]: %s' % (os.getpid(),msg))
logging.setLoggerClass(Logger)
diff --git a/pykolab/plugins/__init__.py b/pykolab/plugins/__init__.py
index e21c1cc..d0ba88e 100644
--- a/pykolab/plugins/__init__.py
+++ b/pykolab/plugins/__init__.py
@@ -50,7 +50,7 @@ class KolabPlugins(object):
if os.path.isdir(plugin_path):
for plugin in os.listdir(plugin_path):
- if os.path.isdir('%s/%s/' %(plugin_path,plugin,)):
+ if os.path.isdir('%s/%s/' % (plugin_path,plugin,)):
self.plugins[plugin] = False
self.check_plugins()
@@ -63,7 +63,7 @@ class KolabPlugins(object):
"""
for plugin in self.plugins:
try:
- exec("from pykolab.plugins import %s" %(plugin))
+ exec("from pykolab.plugins import %s" % (plugin))
self.plugins[plugin] = True
self.load_plugins(plugins=[plugin])
except ImportError, e:
@@ -186,7 +186,7 @@ class KolabPlugins(object):
except AttributeError, e:
log.error(_("Cannot check options for plugin %s: %s") % (plugin,e))
else:
- log.debug(_("Not checking options for plugin %s: No function 'check_options()'") %(plugin), level=5)
+ log.debug(_("Not checking options for plugin %s: No function 'check_options()'") % (plugin), level=5)
def plugin_check_setting(self, func, option, val, plugins=[]):
"""
@@ -224,13 +224,13 @@ class KolabPlugins(object):
if hasattr(getattr(self,plugin),hook):
try:
- log.debug(_("Executing hook %s for plugin %s") %(hook,plugin), level=8)
- #print "retval = self.%s.%s(%r, %r)" %(plugin,hook, args, kw)
- exec("retval = self.%s.%s(*args, **kw)" %(plugin,hook))
+ log.debug(_("Executing hook %s for plugin %s") % (hook,plugin), level=8)
+ #print "retval = self.%s.%s(%r, %r)" % (plugin,hook, args, kw)
+ exec("retval = self.%s.%s(*args, **kw)" % (plugin,hook))
except TypeError, e:
- log.error(_("Cannot execute hook %s for plugin %s: %s") %(hook,plugin,e))
+ log.error(_("Cannot execute hook %s for plugin %s: %s") % (hook,plugin,e))
except AttributeError, e:
- log.error(_("Cannot execute hook %s for plugin %s: %s") %(hook,plugin,e))
+ log.error(_("Cannot execute hook %s for plugin %s: %s") % (hook,plugin,e))
return retval
diff --git a/pykolab/plugins/defaultfolders/__init__.py b/pykolab/plugins/defaultfolders/__init__.py
index 1d53406..cee1b02 100644
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -44,11 +44,11 @@ class KolabDefaultfolders(object):
"""
if not kw.has_key('additional_folders'):
- log.error(_("Plugin %s called without required keyword %s.") %("defaultfolders", "additional_folders"))
+ log.error(_("Plugin %s called without required keyword %s.") % ("defaultfolders", "additional_folders"))
return {}
try:
- exec("additional_folders = %s" %(kw['additional_folders']))
+ exec("additional_folders = %s" % (kw['additional_folders']))
except Exception, e:
log.error(_("Could not parse additional_folders"))
return {}
diff --git a/pykolab/plugins/dynamicquota/__init__.py b/pykolab/plugins/dynamicquota/__init__.py
index d19a811..6115dcd 100644
--- a/pykolab/plugins/dynamicquota/__init__.py
+++ b/pykolab/plugins/dynamicquota/__init__.py
@@ -47,13 +47,13 @@ class KolabDynamicquota(object):
for keyword in [ 'used', 'current_quota', 'new_quota', 'default_quota' ]:
if not kw.has_key(keyword):
- log.warning(_("No keyword %s passed to set_user_folder_quota") %(keyword))
+ log.warning(_("No keyword %s passed to set_user_folder_quota") % (keyword))
return 0
else:
try:
kw[keyword] = (int)(kw[keyword])
except:
- log.error(_("Quota '%s' not an integer!") %(keyword))
+ log.error(_("Quota '%s' not an integer!") % (keyword))
return 0
# Escape the user without quota
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 89f05d0..6621947 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -98,7 +98,7 @@ class KolabRecipientpolicy(object):
alternative_mail = []
- #print "%r" %(alternative_mail_routines)
+ #print "%r" % (alternative_mail_routines)
_domains = [ kw['primary_domain'] ] + kw['secondary_domains']
for number in alternative_mail_routines.keys():
@@ -108,7 +108,7 @@ class KolabRecipientpolicy(object):
except KeyError, e:
log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
- #log.debug(_("Appending additional mail address: %s") %(retval), level=8)
+ #log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(utils.translate(retval, user_attrs['preferredlanguage']))
for _domain in kw['secondary_domains']:
@@ -118,7 +118,7 @@ class KolabRecipientpolicy(object):
except KeyError, e:
log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
- #log.debug(_("Appending additional mail address: %s") %(retval), level=8)
+ #log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(utils.translate(retval, user_attrs['preferredlanguage']))
alternative_mail = utils.normalize(alternative_mail)
diff --git a/pykolab/setup/components.py b/pykolab/setup/components.py
index d13e21a..d17a357 100644
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -43,9 +43,9 @@ def __init__():
if filename.startswith('setup_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
component_name = module_name.replace('setup_', '')
- #print "exec(\"from %s import __init__ as %s_register\"" %(module_name,component_name)
- exec("from %s import __init__ as %s_register" %(module_name,component_name))
- exec("%s_register()" %(component_name))
+ #print "exec(\"from %s import __init__ as %s_register\"" % (module_name,component_name)
+ exec("from %s import __init__ as %s_register" % (module_name,component_name))
+ exec("%s_register()" % (component_name))
for dirname in dirnames:
register_group(components_path, dirname)
@@ -75,21 +75,21 @@ def list_setup(*args, **kw):
if __components[_component].has_key('function'):
# This is a top-level component
if not __components[_component]['description'] == None:
- print "%-25s - %s" %(_component.replace('_','-'),__components[_component]['description'])
+ print "%-25s - %s" % (_component.replace('_','-'),__components[_component]['description'])
else:
- print "%-25s" %(_component.replace('_','-'))
+ print "%-25s" % (_component.replace('_','-'))
for _component in _components:
if not __components[_component].has_key('function'):
# This is a nested component
- print "\n" + _("Command Group: %s") %(_component) + "\n"
+ print "\n" + _("Command Group: %s") % (_component) + "\n"
___components = __components[_component].keys()
___components.sort()
for __component in ___components:
if not __components[_component][__component]['description'] == None:
- print "%-4s%-21s - %s" %('',__component.replace('_','-'),__components[_component][__component]['description'])
+ print "%-4s%-21s - %s" % ('',__component.replace('_','-'),__components[_component][__component]['description'])
else:
- print "%-4s%-21s" %('',__component.replace('_','-'))
+ print "%-4s%-21s" % ('',__component.replace('_','-'))
def execute(component_name, *args, **kw):
if not components.has_key(component_name):
@@ -105,15 +105,15 @@ def execute(component_name, *args, **kw):
group = components[component_name]['group']
component_name = components[component_name]['component_name']
try:
- exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" %(group,component_name,group,component_name))
- exec("%s_%s_cli_options()" %(group,component_name))
+ exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" % (group,component_name,group,component_name))
+ exec("%s_%s_cli_options()" % (group,component_name))
except ImportError, e:
pass
else:
try:
- exec("from cmd_%s import cli_options as %s_cli_options" %(component_name,component_name))
- exec("%s_cli_options()" %(component_name))
+ exec("from cmd_%s import cli_options as %s_cli_options" % (component_name,component_name))
+ exec("%s_cli_options()" % (component_name))
except ImportError, e:
pass
@@ -134,13 +134,13 @@ def register_group(dirname, module):
if filename.startswith('cmd_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
component_name = module_name.replace('cmd_', '')
- #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" %(module,module_name,module,component_name)
- exec("from %s.%s import __init__ as %s_%s_register" %(module,module_name,module,component_name))
- exec("%s_%s_register()" %(module,component_name))
+ #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" % (module,module_name,module,component_name)
+ exec("from %s.%s import __init__ as %s_%s_register" % (module,module_name,module,component_name))
+ exec("%s_%s_register()" % (module,component_name))
def register(component_name, func, group=None, description=None, aliases=[]):
if not group == None:
- component = "%s_%s" %(group,component_name)
+ component = "%s_%s" % (group,component_name)
else:
component = component_name
@@ -148,7 +148,7 @@ def register(component_name, func, group=None, description=None, aliases=[]):
aliases = [aliases]
if components.has_key(component):
- log.fatal(_("Command '%s' already registered") %(component))
+ log.fatal(_("Command '%s' already registered") % (component))
sys.exit(1)
if callable(func):
@@ -170,7 +170,7 @@ def register(component_name, func, group=None, description=None, aliases=[]):
for alias in aliases:
components[alias] = {
'function': func,
- 'description': _("Alias for %s") %(component_name)
+ 'description': _("Alias for %s") % (component_name)
}
##
diff --git a/pykolab/setup/ldap_setup.py b/pykolab/setup/ldap_setup.py
index 8349b16..a99351f 100644
--- a/pykolab/setup/ldap_setup.py
+++ b/pykolab/setup/ldap_setup.py
@@ -49,10 +49,10 @@ def setup():
for item in other_services:
log.warning(_("Warning: LDAP Service '%s' is available on " + \
- "this system as well.") %(item))
+ "this system as well.") % (item))
if not service == None:
- log.info(_("Found system service %s.") %(service))
+ log.info(_("Found system service %s.") % (service))
else:
package.Package('openldap-servers')
diff --git a/pykolab/setup/setup_ldap.py b/pykolab/setup/setup_ldap.py
index 59672c5..1d85da7 100644
--- a/pykolab/setup/setup_ldap.py
+++ b/pykolab/setup/setup_ldap.py
@@ -76,4 +76,4 @@ AddSampleEntries = No
Port = 9830
ServerAdminID = admin
ServerAdminPwd = %(admin_pass)s
-""" %(_input)
+""" % (_input)
diff --git a/pykolab/telemetry.py b/pykolab/telemetry.py
index 6df1192..66bd1ae 100644
--- a/pykolab/telemetry.py
+++ b/pykolab/telemetry.py
@@ -189,7 +189,7 @@ class TelemetryLog(object):
line_num += 1
- log.debug("%s (%d): %s" %(self.log_file,line_num,line), level=8)
+ log.debug("%s (%d): %s" % (self.log_file,line_num,line), level=8)
if line.startswith('---------- '):
# This is the actual start of a session
@@ -585,7 +585,7 @@ def expire_sessions(retention=7):
"""
start_max = ((int)(time.time()) - (retention * 24 * 60 * 60))
#start_max = (int)(time.time())
- log.info(_("Expiring sessions that started before or on %d") %(start_max))
+ log.info(_("Expiring sessions that started before or on %d") % (start_max))
db = init_db()
@@ -598,7 +598,7 @@ def expire_sessions(retention=7):
)
for session in sessions:
- log.debug(_("Expiring session ID: %d") %(session.id), level=8)
+ log.debug(_("Expiring session ID: %d") % (session.id), level=8)
# Expire related information
command_issue_ids = db.query(
@@ -617,7 +617,7 @@ def expire_sessions(retention=7):
db.commit()
log.debug(
- _("Session with ID %d expired from database") %(session.id),
+ _("Session with ID %d expired from database") % (session.id),
level=8
)
@@ -643,7 +643,7 @@ def init_db():
try:
metadata.create_all(engine)
except sqlalchemy.exc.OperationalError, e:
- log.error(_("Operational Error in telemetry database: %s" %(e)))
+ log.error(_("Operational Error in telemetry database: %s" % (e)))
Session = sessionmaker(bind=engine)
db = Session()
diff --git a/pykolab/tests/imap/test_login.py b/pykolab/tests/imap/test_login.py
index 951abd9..7042415 100644
--- a/pykolab/tests/imap/test_login.py
+++ b/pykolab/tests/imap/test_login.py
@@ -41,21 +41,21 @@ def description():
def execute(*args, **kw):
try:
- log.debug(_("Connecting at %s") %(time.time()), level=8)
+ log.debug(_("Connecting at %s") % (time.time()), level=8)
imap.connect(login=False)
- log.debug(_("Connected at %s") %(time.time()), level=8)
+ log.debug(_("Connected at %s") % (time.time()), level=8)
except:
raise TestFailureException, __file__
try:
- log.debug(_("Logging in at %s") %(time.time()), level=8)
+ log.debug(_("Logging in at %s") % (time.time()), level=8)
imap.login('doe', password='0cvRKSdluPU4ewN')
- log.debug(_("Logged in at %s") %(time.time()), level=8)
+ log.debug(_("Logged in at %s") % (time.time()), level=8)
#imap.login('doe', password='bla')
except:
raise TestFailureException(__file__)
class TestFailureException(BaseException):
def __init__(self, test_file):
- log.error(_("Test failure in %s") %(test_file))
+ log.error(_("Test failure in %s") % (test_file))
utils.ask_confirmation('Would you like to log this as a bug?') \ No newline at end of file
diff --git a/pykolab/tests/tests.py b/pykolab/tests/tests.py
index 8a3c915..1f72f3f 100644
--- a/pykolab/tests/tests.py
+++ b/pykolab/tests/tests.py
@@ -43,9 +43,9 @@ def __init__():
if filename.startswith('test_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
test_name = module_name.replace('test_', '')
- #print "exec(\"from %s import __init__ as %s_register\"" %(module_name,test_name)
- exec("from %s import __init__ as %s_register" %(module_name,test_name))
- exec("%s_register()" %(test_name))
+ #print "exec(\"from %s import __init__ as %s_register\"" % (module_name,test_name)
+ exec("from %s import __init__ as %s_register" % (module_name,test_name))
+ exec("%s_register()" % (test_name))
for dirname in dirnames:
register_group(tests_path, dirname)
@@ -76,21 +76,21 @@ def list_tests(*args, **kw):
if __tests[_test].has_key('function'):
# This is a top-level test
if not __tests[_test]['description'] == None:
- print "%-25s - %s" %(_test.replace('_','-'),__tests[_test]['description'])
+ print "%-25s - %s" % (_test.replace('_','-'),__tests[_test]['description'])
else:
- print "%-25s" %(_test.replace('_','-'))
+ print "%-25s" % (_test.replace('_','-'))
for _test in _tests:
if not __tests[_test].has_key('function'):
# This is a nested test
- print "\n" + _("Test Suite: %s") %(_test) + "\n"
+ print "\n" + _("Test Suite: %s") % (_test) + "\n"
___tests = __tests[_test].keys()
___tests.sort()
for __test in ___tests:
if not __tests[_test][__test]['description'] == None:
- print "%-4s%-21s - %s" %('',__test.replace('_','-'),__tests[_test][__test]['description'])
+ print "%-4s%-21s - %s" % ('',__test.replace('_','-'),__tests[_test][__test]['description'])
else:
- print "%-4s%-21s" %('',__test.replace('_','-'))
+ print "%-4s%-21s" % ('',__test.replace('_','-'))
def execute(test_name, *args, **kw):
print "tests:", tests
@@ -109,15 +109,15 @@ def execute(test_name, *args, **kw):
group = tests[test_name]['group']
_test_name = tests[test_name]['test_name']
try:
- exec("from %s.test_%s import cli_options as %s_%s_cli_options" %(group,_test_name,group,test_name))
- exec("%s_%s_cli_options()" %(group,test_name))
+ exec("from %s.test_%s import cli_options as %s_%s_cli_options" % (group,_test_name,group,test_name))
+ exec("%s_%s_cli_options()" % (group,test_name))
except ImportError, e:
pass
else:
try:
- exec("from test_%s import cli_options as %s_cli_options" %(test_name,test_name))
- exec("%s_cli_options()" %(test_name))
+ exec("from test_%s import cli_options as %s_cli_options" % (test_name,test_name))
+ exec("%s_cli_options()" % (test_name))
except ImportError, e:
pass
@@ -138,13 +138,13 @@ def register_group(dirname, module):
if filename.startswith('test_') and filename.endswith('.py'):
module_name = filename.replace('.py','')
test_name = module_name.replace('test_', '')
- #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" %(module,module_name,module,test_name)
- exec("from %s.%s import __init__ as %s_%s_register" %(module,module_name,module,test_name))
- exec("%s_%s_register()" %(module,test_name))
+ #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" % (module,module_name,module,test_name)
+ exec("from %s.%s import __init__ as %s_%s_register" % (module,module_name,module,test_name))
+ exec("%s_%s_register()" % (module,test_name))
def register(test_name, func, group=None, description=None, aliases=[]):
if not group == None:
- test = "%s_%s" %(group,test_name)
+ test = "%s_%s" % (group,test_name)
else:
test = test_name
@@ -154,11 +154,11 @@ def register(test_name, func, group=None, description=None, aliases=[]):
aliases = [aliases]
if tests.has_key(test):
- log.fatal(_("Test '%s' already registered") %(test))
+ log.fatal(_("Test '%s' already registered") % (test))
sys.exit(1)
if tests.has_key(test):
- log.fatal(_("Test '%s' already registered") %(test))
+ log.fatal(_("Test '%s' already registered") % (test))
sys.exit(1)
if callable(func):
@@ -180,7 +180,7 @@ def register(test_name, func, group=None, description=None, aliases=[]):
for alias in aliases:
tests[alias] = {
'function': func,
- 'description': _("Alias for %s") %(test_name)
+ 'description': _("Alias for %s") % (test_name)
}
##
diff --git a/pykolab/utils.py b/pykolab/utils.py
index bd94a02..9198c82 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -36,12 +36,12 @@ def ask_question(question, default="", password=False):
Usage: pykolab.utils.ask_question("What is the server?", default="localhost")
"""
if password:
- answer = getpass.getpass("%s: " %(question))
+ answer = getpass.getpass("%s: " % (question))
else:
if default == "":
- answer = raw_input("%s: " %(question))
+ answer = raw_input("%s: " % (question))
else:
- answer = raw_input("%s [%s]: " %(question, default))
+ answer = raw_input("%s [%s]: " % (question, default))
if answer == "":
return default
@@ -71,7 +71,7 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
answer = False
while answer == False:
- answer = raw_input("%s [%s/%s]: " %(question,default_yes,default_no))
+ answer = raw_input("%s [%s/%s]: " % (question,default_yes,default_no))
# Parse answer and set back to False if not appropriate
if all_inclusive_no:
if not answer in [ "y", "Y", "yes" ]:
@@ -206,7 +206,7 @@ def pop_empty_from_list(_input_list):
_output_list.append(item)
def standard_root_dn(domain):
- return 'dc=%s' %(',dc='.join(domain.split('.')))
+ return 'dc=%s' % (',dc='.join(domain.split('.')))
def translate(mystring, locale_name='en_US'):
import locale
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index c84790d..5462961 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -58,7 +58,7 @@ def get_group_input():
if len(group_types.keys()) > 1:
for key in group_types.keys():
if not key == "status":
- print "%s) %s" %(key,group_types[key]['name'])
+ print "%s) %s" % (key,group_types[key]['name'])
group_type_id = utils.ask_question("Please select the group type")
@@ -84,7 +84,7 @@ def get_group_input():
params[attribute] = utils.ask_question(attribute)
for attribute in group_type_info['auto_form_fields'].keys():
- exec("retval = group_form_value_generate_%s(params)" %(attribute))
+ exec("retval = group_form_value_generate_%s(params)" % (attribute))
params[attribute] = retval[attribute]
return params
@@ -95,7 +95,7 @@ def get_user_input():
if len(user_types.keys()) > 1:
for key in user_types.keys():
if not key == "status":
- print "%s) %s" %(key,user_types[key]['name'])
+ print "%s) %s" % (key,user_types[key]['name'])
user_type_id = utils.ask_question("Please select the user type")
@@ -121,7 +121,7 @@ def get_user_input():
params[attribute] = utils.ask_question(attribute)
for attribute in user_type_info['auto_form_fields'].keys():
- exec("retval = form_value_generate_%s(params)" %(attribute))
+ exec("retval = form_value_generate_%s(params)" % (attribute))
params[attribute] = retval[attribute]
return params
@@ -144,13 +144,13 @@ def group_form_value_generate_mail(params=None):
def group_info():
group = utils.ask_question("Group email address")
- group = request('GET', 'group.info?group=%s' %(group))
+ group = request('GET', 'group.info?group=%s' % (group))
return group
def group_members_list(group=None):
if group == None:
group = utils.ask_question("Group email address")
- group = request('GET', 'group.members_list?group=%s' %(group))
+ group = request('GET', 'group.members_list?group=%s' % (group))
return group
def group_types_list():
@@ -166,7 +166,7 @@ def request(method, api_uri, params=None, headers={}):
headers["X-Session-Token"] = session_id
conn = connect()
- conn.request(method.upper(), "%s/%s" %(API_BASE,api_uri), params, headers)
+ conn.request(method.upper(), "%s/%s" % (API_BASE,api_uri), params, headers)
response = conn.getresponse()
data = response.read()
@@ -197,7 +197,7 @@ def system_get_domain():
def system_select_domain(domain=None):
if domain == None:
domain = utils.ask_question("Domain name")
- return request('GET', 'system.select_domain?domain=%s' %(domain))
+ return request('GET', 'system.select_domain?domain=%s' % (domain))
def user_add(params=None):
if params == None:
@@ -270,7 +270,7 @@ def user_form_value_generate_userpassword(*args, **kw):
def user_info():
user = utils.ask_question("User email address")
- user = request('GET', 'user.info?user=%s' %(user))
+ user = request('GET', 'user.info?user=%s' % (user))
return user
def user_types_list():