Browse Source

* fixed some coding style issues

master
lars 13 years ago
parent
commit
38843516fa
  1. 1
      plugins/date/root_action.py
  2. 16
      plugins/help/unittests.py
  3. 18
      plugins/logs/logs.py
  4. 6
      plugins/network/network.py
  5. 6
      plugins/network/unittests.py
  6. 4
      plugins/plugin_manager/plugin_manager.py
  7. 40
      plugins/user_manager/unittests.py

1
plugins/date/root_action.py

@ -30,7 +30,6 @@ DATE_BIN = "/bin/date"
import subprocess
import re
import sys
import os
if __name__ == "__main__":
args = sys.argv[1:]

16
plugins/help/unittests.py

@ -32,7 +32,7 @@ class unittests(WebInterfaceTestClass):
self.cmd.go(self.url + "help?weblang=en")
self.cmd.find("Table of Contents")
self.cmd.find("Getting started")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(lang == "en")
self.assertTrue(page == "CryptoBoxUser")
@ -40,7 +40,7 @@ class unittests(WebInterfaceTestClass):
self.cmd.go(self.url + "help?weblang=de")
self.cmd.find("Table of Contents")
self.cmd.find("Wie geht es los")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(lang == "de")
self.assertTrue(page == "CryptoBoxUser")
@ -48,7 +48,7 @@ class unittests(WebInterfaceTestClass):
self.cmd.go(self.url + "help?weblang=sl")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
## add a slovene text here, as soon as the help is translated
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
## change this to "sl" as soon as the help is translated
self.assertTrue(lang == "en")
self.assertTrue(page == "CryptoBoxUser")
@ -57,7 +57,7 @@ class unittests(WebInterfaceTestClass):
self.cmd.go(self.url + "help?weblang=fr")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
## add a french text here, as soon as the help is translated
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
## change this to "fr" as soon as the help is translated
self.assertTrue(lang == "en")
self.assertTrue(page == "CryptoBoxUser")
@ -65,7 +65,7 @@ class unittests(WebInterfaceTestClass):
## test a random language - it should fall back to english
self.cmd.go(self.url + "help?weblang=foobar")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(lang == "en")
self.assertTrue(page == "CryptoBoxUser")
@ -73,18 +73,18 @@ class unittests(WebInterfaceTestClass):
def test_help_pages(self):
"""check invalid page requests"""
self.cmd.go(self.url + "help?page=foobar")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(page == "CryptoBoxUser")
self.cmd.go(self.url + "help?page=CryptoBoxUser")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(page == "CryptoBoxUser")
def test_help_default_languages(self):
"""check invalid page requests"""
self.cmd.go(self.url + "help?weblang=foobar")
(lang,page) = self._getHelpStatus()
(lang, page) = self._getHelpStatus()
self.assertTrue(lang == "en")

18
plugins/logs/logs.py

@ -84,17 +84,17 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
return ""
else:
return cherrypy.lib.cptools.serveFile(log_file,
disposition="attachment", name="cryptobox_logfile.txt")
disposition="attachment", name="cryptobox_logfile.txt")
def get_status(self):
"""The current status includes the log configuration details.
"""
return "%s:%s:%s" % (
self.cbox.prefs["Log"]["Level"],
self.cbox.prefs["Log"]["Destination"],
self.cbox.prefs["Log"]["Details"])
def get_status(self):
"""The current status includes the log configuration details.
"""
return "%s:%s:%s" % (
self.cbox.prefs["Log"]["Level"],
self.cbox.prefs["Log"]["Destination"],
self.cbox.prefs["Log"]["Details"])
def get_status(self):
"""The current status includes the log configuration details.

6
plugins/network/network.py

@ -214,7 +214,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
def __prepare_form_data(self):
"""Set some hdf values.
"""
(ip1, ip2, ip3, ip4),(nm1, nm2, nm3, nm4) = self.__get_current_ip()
(ip1, ip2, ip3, ip4), (nm1, nm2, nm3, nm4) = self.__get_current_ip()
self.hdf[self.hdf_prefix + "ip.oc1"] = ip1
self.hdf[self.hdf_prefix + "ip.oc2"] = ip2
self.hdf[self.hdf_prefix + "ip.oc3"] = ip3
@ -239,8 +239,8 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
def __get_current_ip(self):
"""Retrieve the current IP.
"""
ip = (0,0,0,0)
nm = (0,0,0,0)
ip = (0, 0, 0, 0)
nm = (0, 0, 0, 0)
## get the current IP/netmask of the network interface
proc = subprocess.Popen(
shell = False,

6
plugins/network/unittests.py

@ -54,11 +54,11 @@ class unittests(WebInterfaceTestClass):
## sleep a little bit longer than the delay necessary for ip-change
time.sleep(CHANGE_IP_DELAY + 3)
## set invalid IPs and check if the original IP stays the same
set_ip([1,-2,0,1])
set_ip([1, -2, 0, 1])
self.assertEquals(orig_ip_text, get_current_ip())
set_ip([1,0,0,256])
set_ip([1, 0, 0, 256])
self.assertEquals(orig_ip_text, get_current_ip())
set_ip([1,"foo",0,1])
set_ip([1, "foo", 0, 1])
self.assertEquals(orig_ip_text, get_current_ip())
new_ip = orig_ip_octs[:]
new_ip[3] = str((int(orig_ip_octs[3]) + 128) % 256)

4
plugins/plugin_manager/plugin_manager.py

@ -52,7 +52,7 @@ class plugin_manager(cryptobox.plugins.base.CryptoBoxPlugin):
elif store:
for key in args.keys():
if key.endswith("_listed"):
if not re.search(r'\W',key):
if not re.search(r'\W', key):
self.__set_config(key[:-7], args)
else:
self.cbox.log.info("plugin_manager: invalid plugin name (%s)" % \
@ -73,7 +73,7 @@ class plugin_manager(cryptobox.plugins.base.CryptoBoxPlugin):
def __sort_plugins(self):
"""sort all plugins in the list according to their rank"""
def cmp_func(x,y):
def cmp_func(x, y):
x_rank = x.get_rank()
y_rank = y.get_rank()
if x_rank < y_rank:

40
plugins/user_manager/unittests.py

@ -38,7 +38,7 @@ class unittests(WebInterfaceTestClass):
def test_test_wrong_credentials(self):
"""check if the user_manager is protected"""
url = self.url + "user_manager"
self.register_auth(url,"foo","bar")
self.register_auth(url, "foo", "bar")
self.cmd.go(url)
self.cmd.notfind("Manage users")
@ -47,7 +47,7 @@ class unittests(WebInterfaceTestClass):
"""adding an existing user should fail"""
url = self.url + "user_manager"
self.register_auth(url)
self._add_user("admin","foo","foo")
self._add_user("admin", "foo", "foo")
self.cmd.find("The choosen username does already exist")
@ -55,7 +55,7 @@ class unittests(WebInterfaceTestClass):
"""adding an invalid username should fail"""
url = self.url + "user_manager"
self.register_auth(url)
self._add_user("foo/bar","foo","foo")
self._add_user("foo/bar", "foo", "foo")
self.cmd.find("Invalid username")
self.assertFalse("foo/bar" in self._getUsers())
@ -65,7 +65,7 @@ class unittests(WebInterfaceTestClass):
url = self.url + "user_manager"
self.register_auth(url)
self.assertFalse("foo" in self._getUsers())
self._add_user("foo","","foo")
self._add_user("foo", "", "foo")
self.cmd.find("Missing new password")
self.assertFalse("foo" in self._getUsers())
@ -75,7 +75,7 @@ class unittests(WebInterfaceTestClass):
url = self.url + "user_manager"
self.register_auth(url)
self.assertFalse("foo" in self._getUsers())
self._add_user("foo","bar","foo")
self._add_user("foo", "bar", "foo")
self.cmd.find("Different passwords")
self.assertFalse("foo" in self._getUsers())
@ -94,9 +94,9 @@ class unittests(WebInterfaceTestClass):
url = self.url + "user_manager"
self.register_auth(url)
self.assertFalse("foo" in self._getUsers())
self._add_user("foo","bar","bar")
self._add_user("foo", "bar", "bar")
self.assertTrue("foo" in self._getUsers())
self._change_password("foo","","foo")
self._change_password("foo", "", "foo")
self.cmd.find("Missing new password")
self._del_user("foo")
self.assertFalse("foo" in self._getUsers())
@ -107,9 +107,9 @@ class unittests(WebInterfaceTestClass):
url = self.url + "user_manager"
self.register_auth(url)
self.assertFalse("foo" in self._getUsers())
self._add_user("foo","bar","bar")
self._add_user("foo", "bar", "bar")
self.assertTrue("foo" in self._getUsers())
self._change_password("foo","bar","foo")
self._change_password("foo", "bar", "foo")
self.cmd.find("Different passwords")
self._del_user("foo")
self.assertFalse("foo" in self._getUsers())
@ -142,16 +142,16 @@ class unittests(WebInterfaceTestClass):
## check its existence before
if "foobar" in self._getUsers(): self._del_user("foobar")
## add a new user
self._add_user("foobar","foo","foo")
self._add_user("foobar", "foo", "foo")
self.cmd.find("User added")
users = self._getUsers()
self.assertTrue("foobar" in users)
## change the password of the new user
self.register_auth(url,"foobar","foo")
self._change_password("foobar","bar","bar")
self.register_auth(url, "foobar", "foo")
self._change_password("foobar", "bar", "bar")
self.cmd.find("Password changed")
## remove the new user
self.register_auth(url,"foobar","bar")
self.register_auth(url, "foobar", "bar")
self._del_user("foobar")
self.cmd.find("User removed")
users = self._getUsers()
@ -167,23 +167,23 @@ class unittests(WebInterfaceTestClass):
def _add_user(self, username, pw, pw2):
self.cmd.go(self.url + "user_manager")
self.cmd.formvalue("add_user","user",username)
self.cmd.formvalue("add_user","new_pw",pw)
self.cmd.formvalue("add_user","new_pw2",pw2)
self.cmd.formvalue("add_user", "user", username)
self.cmd.formvalue("add_user", "new_pw", pw)
self.cmd.formvalue("add_user", "new_pw2", pw2)
self.cmd.submit()
def _del_user(self, username):
self.cmd.go(self.url + "user_manager")
self.cmd.formvalue("del_user","user",username)
self.cmd.formvalue("del_user", "user", username)
self.cmd.submit()
def _change_password(self, username, pw, pw2):
self.cmd.go(self.url + "user_manager")
self.cmd.formvalue("change_password","user",username)
self.cmd.formvalue("change_password","new_pw",pw)
self.cmd.formvalue("change_password","new_pw2",pw2)
self.cmd.formvalue("change_password", "user", username)
self.cmd.formvalue("change_password", "new_pw", pw)
self.cmd.formvalue("change_password", "new_pw2", pw2)
self.cmd.submit()

Loading…
Cancel
Save