sabayon r939 - in trunk: . lib
- From: jrobeson svn gnome org
- To: svn-commits-list gnome org
- Subject: sabayon r939 - in trunk: . lib
- Date: Fri, 15 Feb 2008 21:43:58 +0000 (GMT)
Author: jrobeson
Date: Fri Feb 15 21:43:58 2008
New Revision: 939
URL: http://svn.gnome.org/viewvc/sabayon?rev=939&view=rev
Log:
* TABS to spaces
lib/cache.py
lib/userdb.py
Modified:
trunk/ChangeLog
trunk/lib/cache.py
trunk/lib/userdb.py
Modified: trunk/lib/cache.py
==============================================================================
--- trunk/lib/cache.py (original)
+++ trunk/lib/cache.py Fri Feb 15 21:43:58 2008
@@ -38,11 +38,11 @@
try to transfer only files remotely modified from the cache."""
def __init__(self, directory = None):
info = None
- self.directory = None
- self.catalog = None
- self.root = None
- # delay the directory check/creation until needed
- self.orig_directory = directory
+ self.directory = None
+ self.catalog = None
+ self.root = None
+ # delay the directory check/creation until needed
+ self.orig_directory = directory
def __ensure_directory(self, directory, remove_old):
try:
@@ -78,193 +78,193 @@
if info == None:
directory = None
- if directory == None:
+ if directory == None:
parent_info = self.__ensure_directory (get_home_dir() + "/.sabayon", True)
if parent_info:
directory = get_home_dir() + "/.sabayon/profile_cache"
info = self.__ensure_directory (directory, True)
- if info == None:
- dprint("Running with cache deactivated")
- self.directory = None
- return
- else:
- self.directory = directory
- if stat.S_IMODE(info[0]) != stat.S_IRUSR + stat.S_IWUSR + stat.S_IXUSR:
- dprint("Wrong mode for %s", directory)
- try:
- os.chmod(directory, stat.S_IRUSR + stat.S_IWUSR + stat.S_IXUSR)
- except:
- dprint("Failed to chmod %s, ignored", directory)
- self.directory = None
- return
- if self.directory == None:
- dprint("Running with cache deactivated")
- return
-
- catalogfile = self.directory + "/catalog.xml"
- try:
- self.catalog = libxml2.readFile(catalogfile, None,
- libxml2.XML_PARSE_NOBLANKS)
- except:
- dprint("Failed to load catalog from %s" %(catalogfile))
- self.catalog = None
-
- if self.catalog != None:
- root = self.catalog.getRootElement()
- if not root or root.name != "catalog":
- dprint("Discarding corrupted catalog")
- self.catalog.freeDoc ()
- self.catalog = None
- else:
- self.root = root
-
- # remove empty catalogs
- if self.catalog == None or self.root == None or \
- self.root.children == None:
- try:
- os.unlink(self.directory + "/catalog.xml")
- except:
- pass
+ if info == None:
+ dprint("Running with cache deactivated")
+ self.directory = None
+ return
+ else:
+ self.directory = directory
+ if stat.S_IMODE(info[0]) != stat.S_IRUSR + stat.S_IWUSR + stat.S_IXUSR:
+ dprint("Wrong mode for %s", directory)
+ try:
+ os.chmod(directory, stat.S_IRUSR + stat.S_IWUSR + stat.S_IXUSR)
+ except:
+ dprint("Failed to chmod %s, ignored", directory)
+ self.directory = None
+ return
+ if self.directory == None:
+ dprint("Running with cache deactivated")
+ return
+
+ catalogfile = self.directory + "/catalog.xml"
+ try:
+ self.catalog = libxml2.readFile(catalogfile, None,
+ libxml2.XML_PARSE_NOBLANKS)
+ except:
+ dprint("Failed to load catalog from %s" %(catalogfile))
+ self.catalog = None
+
+ if self.catalog != None:
+ root = self.catalog.getRootElement()
+ if not root or root.name != "catalog":
+ dprint("Discarding corrupted catalog")
+ self.catalog.freeDoc ()
+ self.catalog = None
+ else:
+ self.root = root
+
+ # remove empty catalogs
+ if self.catalog == None or self.root == None or \
+ self.root.children == None:
+ try:
+ os.unlink(self.directory + "/catalog.xml")
+ except:
+ pass
def __URL_mapping(self, URL):
"""Function to convert an URL to a local name in the cache"""
- URL = string.replace(URL, '//', "_")
- URL = string.replace(URL, '/', "_")
- return URL
+ URL = string.replace(URL, '//', "_")
+ URL = string.replace(URL, '/', "_")
+ return URL
def __save_catalog(self):
"""Save the on disk catalog in XML format"""
- # don't save an empty catalog, and remove it if empty
- if self.catalog == None or self.root == None or \
- self.root.children == None:
- try:
- os.unlink(self.directory + "/catalog.xml")
- except:
- pass
- return
+ # don't save an empty catalog, and remove it if empty
+ if self.catalog == None or self.root == None or \
+ self.root.children == None:
+ try:
+ os.unlink(self.directory + "/catalog.xml")
+ except:
+ pass
+ return
if self.catalog != None and self.directory != None:
- f = open(self.directory + "/catalog.xml", "w")
- f.write(self.catalog.serialize(format = 1))
- f.close()
+ f = open(self.directory + "/catalog.xml", "w")
+ f.write(self.catalog.serialize(format = 1))
+ f.close()
def __update_catalog(self, URL, timestamp = None):
"""Update the catalog of resources in the cache with an updated entry"""
- if URL == None:
- return
- modified = 0
+ if URL == None:
+ return
+ modified = 0
# create the catalog if needed
- if self.catalog == None:
- self.catalog = libxml2.newDoc("1.0")
- self.root = self.catalog.newChild (None, "catalog", None)
- modified = 1
- if self.root == None:
- return
-
- try:
- child = self.root.xpathEval("/catalog/entry[ URL = '%s']" % URL)[0]
- except:
- child = None
- if child == None:
- child = self.root.newChild(None, "entry", None)
- child.setProp("URL", URL)
- if timestamp == None:
- timestamp = ""
- child.setProp("timestamp", timestamp)
- modified = 1
- else:
- if child.prop("URL") == URL:
- if timestamp != None:
- if timestamp != child.prop("timestamp"):
- child.setProp("timestamp", timestamp)
- modified = 1
- else:
- child.setProp("timestamp", "")
- modified = 1
- if modified == 1:
- self.__save_catalog()
+ if self.catalog == None:
+ self.catalog = libxml2.newDoc("1.0")
+ self.root = self.catalog.newChild (None, "catalog", None)
+ modified = 1
+ if self.root == None:
+ return
+
+ try:
+ child = self.root.xpathEval("/catalog/entry[ URL = '%s']" % URL)[0]
+ except:
+ child = None
+ if child == None:
+ child = self.root.newChild(None, "entry", None)
+ child.setProp("URL", URL)
+ if timestamp == None:
+ timestamp = ""
+ child.setProp("timestamp", timestamp)
+ modified = 1
+ else:
+ if child.prop("URL") == URL:
+ if timestamp != None:
+ if timestamp != child.prop("timestamp"):
+ child.setProp("timestamp", timestamp)
+ modified = 1
+ else:
+ child.setProp("timestamp", "")
+ modified = 1
+ if modified == 1:
+ self.__save_catalog()
def __catalog_lookup(self, URL):
"""lookup an entry in the catalog, it will return a tuple of the
- file path and the timestamp if found, None otherwise. If the
- file is referenced in the cache but has not timestamp then it
- will return an empty string."""
- if self.root == None:
- return None
- try:
- child = self.root.xpathEval("/catalog/entry[ URL = '%s']" % URL)[0]
- except:
- return None
- filename = self.directory + "/" + self.__URL_mapping(URL)
- try:
- info = os.stat(filename)
- except:
- dprint("Local cache file for %s disapeared", URL)
- child.unlinkNode()
- child.freeNode()
- return None
- return child.prop("timestamp")
+ file path and the timestamp if found, None otherwise. If the
+ file is referenced in the cache but has not timestamp then it
+ will return an empty string."""
+ if self.root == None:
+ return None
+ try:
+ child = self.root.xpathEval("/catalog/entry[ URL = '%s']" % URL)[0]
+ except:
+ return None
+ filename = self.directory + "/" + self.__URL_mapping(URL)
+ try:
+ info = os.stat(filename)
+ except:
+ dprint("Local cache file for %s disapeared", URL)
+ child.unlinkNode()
+ child.freeNode()
+ return None
+ return child.prop("timestamp")
def get_resource(self, URL):
"""Get a resource from the cache. It may fetch it from the network
- or use a local copy. It returns a Python file liek open() would.
- If passed a filename it will accept it if absolute.
- The return value is an absolute path to a local file."""
- file = None
- try:
- decomp = urlparse.urlparse(URL)
- if decomp[2] == URL:
- file = URL
- except:
- file = URL
- if file != None:
- if file[0] != '/':
- return None
- try:
- return file
- except:
- dprint("Failed to read %s", file)
- return None
- else:
- self.__check_directory()
- filename = self.directory + "/" + self.__URL_mapping(URL)
- timestamp = self.__catalog_lookup(URL)
- last_modified = None
- try:
- request = urllib2.Request(URL)
- if timestamp != None and timestamp != "":
- request.add_header('If-Modified-Since', timestamp)
+ or use a local copy. It returns a Python file liek open() would.
+ If passed a filename it will accept it if absolute.
+ The return value is an absolute path to a local file."""
+ file = None
+ try:
+ decomp = urlparse.urlparse(URL)
+ if decomp[2] == URL:
+ file = URL
+ except:
+ file = URL
+ if file != None:
+ if file[0] != '/':
+ return None
+ try:
+ return file
except:
- dprint("Failed to create request for %s", URL)
- return None
- try:
- opener = urllib2.build_opener()
- # TODO handle time outs there ....
- datastream = opener.open(request)
- try:
- last_modified = datastream.headers.dict['last-modified']
- except:
- last_modified = None
- data = datastream.read()
- datastream.close()
- except:
- dprint("Resource not available or older using cache")
- try:
- info = os.stat(filename)
- return filename
- except:
- dprint("Failed to find cache file %s", filename)
- return None
+ dprint("Failed to read %s", file)
+ return None
+ else:
+ self.__check_directory()
+ filename = self.directory + "/" + self.__URL_mapping(URL)
+ timestamp = self.__catalog_lookup(URL)
+ last_modified = None
try:
- fd = open(filename, "w")
- fd.write(data)
- fd.close()
- self.__update_catalog(URL, last_modified)
- except:
- dprint("Failed to write cache file %s", filename)
- return None
- return filename
+ request = urllib2.Request(URL)
+ if timestamp != None and timestamp != "":
+ request.add_header('If-Modified-Since', timestamp)
+ except:
+ dprint("Failed to create request for %s", URL)
+ return None
+ try:
+ opener = urllib2.build_opener()
+ # TODO handle time outs there ....
+ datastream = opener.open(request)
+ try:
+ last_modified = datastream.headers.dict['last-modified']
+ except:
+ last_modified = None
+ data = datastream.read()
+ datastream.close()
+ except:
+ dprint("Resource not available or older using cache")
+ try:
+ info = os.stat(filename)
+ return filename
+ except:
+ dprint("Failed to find cache file %s", filename)
+ return None
+ try:
+ fd = open(filename, "w")
+ fd.write(data)
+ fd.close()
+ self.__update_catalog(URL, last_modified)
+ except:
+ dprint("Failed to write cache file %s", filename)
+ return None
+ return filename
default_cache = None
@@ -273,8 +273,8 @@
if default_cache == None:
default_cache = cacheRepository()
- # now we can activate the entity loader
- libxml2.setEntityLoader(libxml2_entity_loader)
+ # now we can activate the entity loader
+ libxml2.setEntityLoader(libxml2_entity_loader)
return default_cache
@@ -285,7 +285,7 @@
file = the_cache.get_resource(URL)
try:
fd = open(file)
- dprint("Cache entity loader resolved to %s", file)
+ dprint("Cache entity loader resolved to %s", file)
except:
fd = None
return fd
@@ -311,18 +311,18 @@
class test_http_handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
- SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+ SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
- def log_message(self, format, *args):
- pass
+ def log_message(self, format, *args):
+ pass
def run_http_server(www):
- os.chdir(www)
- server_address = ('', 8000)
- httpd = BaseHTTPServer.HTTPServer(server_address,test_http_handler)
- dprint("starting HTTP on %s" % (www))
- httpd.handle_request()
- dprint("stopping HTTP server")
+ os.chdir(www)
+ server_address = ('', 8000)
+ httpd = BaseHTTPServer.HTTPServer(server_address,test_http_handler)
+ dprint("starting HTTP on %s" % (www))
+ httpd.handle_request()
+ dprint("stopping HTTP server")
www = "/tmp/sabayon_http_test"
shutil.rmtree(www, True)
@@ -359,8 +359,7 @@
assert(data == "content")
dprint("second cached HTTP access okay")
- # shutdown the cache, restart a new instance and try to get the
- # resource
+ # shutdown the cache, restart a new instance and try to get the resource
del cache
cache = cacheRepository(dir)
Modified: trunk/lib/userdb.py
==============================================================================
--- trunk/lib/userdb.py (original)
+++ trunk/lib/userdb.py Fri Feb 15 21:43:58 2008
@@ -47,7 +47,7 @@
try:
return convert_to (a.content)
except:
- np = node.nodePath()
+ np = node.nodePath()
# Translators: You may move the "%(setting)s" and "%(np)s" items as you wish, but
# do not change the way they are written. The intended string is
# something like "invalid type for setting blah in /ldap/path/to/blah"
@@ -97,31 +97,31 @@
"""
if db_file is None:
file = os.path.join (config.PROFILESDIR, "users.xml")
- elif db_file[0] != '/':
+ elif db_file[0] != '/':
file = os.path.join (config.PROFILESDIR, db_file)
- else:
- file = db_file
- self.file = file;
- self.modified = 0
- dprint("New UserDatabase(%s) object\n" % self.file)
-
- try:
- self.doc = libxml2.readFile(file, None, libxml2.XML_PARSE_NOBLANKS)
- # Process XInclude statements
- self.doc.xincludeProcess()
- except:
- # TODO add fallback to last good database
- dprint("failed to parse %s falling back to default conf\n" %
- self.file)
- self.doc = None
- if self.doc == None:
- self.doc = libxml2.readMemory(defaultConf, len(defaultConf),
- None, None,
- libxml2.XML_PARSE_NOBLANKS);
+ else:
+ file = db_file
+ self.file = file;
+ self.modified = 0
+ dprint("New UserDatabase(%s) object\n" % self.file)
+
+ try:
+ self.doc = libxml2.readFile(file, None, libxml2.XML_PARSE_NOBLANKS)
+ # Process XInclude statements
+ self.doc.xincludeProcess()
+ except:
+ # TODO add fallback to last good database
+ dprint("failed to parse %s falling back to default conf\n" %
+ self.file)
+ self.doc = None
+ if self.doc == None:
+ self.doc = libxml2.readMemory(defaultConf, len(defaultConf),
+ None, None,
+ libxml2.XML_PARSE_NOBLANKS);
def __del__ (self):
if self.doc != None:
- self.doc.freeDoc()
+ self.doc.freeDoc()
def __profile_name_to_location (self, profile, node):
if not profile:
@@ -131,45 +131,45 @@
if uri:
return uri
- # do the necessary URI escaping of the profile name if needed
+ # do the necessary URI escaping of the profile name if needed
orig_profile = profile
- try:
- tmp = parseURI(profile)
- except:
- profile = libxml2.URIEscapeStr(profile, "/:")
-
- # if there is a base on the node, then use
- if node != None:
- try:
- base = node.getBase(None)
- if base != None and base != "" and \
- base != os.path.join (config.PROFILESDIR, "users.xml"):
- # URI composition from the base
+ try:
+ tmp = parseURI(profile)
+ except:
+ profile = libxml2.URIEscapeStr(profile, "/:")
+
+ # if there is a base on the node, then use
+ if node != None:
+ try:
+ base = node.getBase(None)
+ if base != None and base != "" and \
+ base != os.path.join (config.PROFILESDIR, "users.xml"):
+ # URI composition from the base
ret = libxml2.buildURI(profile, base)
- if ret[0] == '/':
- ret = libxml2.URIUnescapeString(ret, len(ret), None)
- dprint("Converted profile name '%s' to location '%s'\n",
+ if ret[0] == '/':
+ ret = libxml2.URIUnescapeString(ret, len(ret), None)
+ dprint("Converted profile name '%s' to location '%s'\n",
orig_profile, ret)
return ret
- except:
- pass
- try:
- uri = libxml2.parseURI(profile);
- if uri.scheme() is None:
- # it is a file path
- if profile[0] != '/':
- profile = os.path.join (config.PROFILESDIR, profile)
- if profile[-4:] != ".zip":
- profile = profile + ".zip"
- else:
- # TODO need to make a local copy or use the local copy
- profile = profile
- except:
- # we really expect an URI there
- profile = None
+ except:
+ pass
+ try:
+ uri = libxml2.parseURI(profile);
+ if uri.scheme() is None:
+ # it is a file path
+ if profile[0] != '/':
+ profile = os.path.join (config.PROFILESDIR, profile)
+ if profile[-4:] != ".zip":
+ profile = profile + ".zip"
+ else:
+ # TODO need to make a local copy or use the local copy
+ profile = profile
+ except:
+ # we really expect an URI there
+ profile = None
- if profile[0] == '/':
- profile = libxml2.URIUnescapeString(profile, len(profile), None)
+ if profile[0] == '/':
+ profile = libxml2.URIUnescapeString(profile, len(profile), None)
dprint("Converted profile name '%s' to location '%s'\n",
orig_profile, profile)
return profile
@@ -265,12 +265,12 @@
object, or the default profile name if @profile_location is
False.
"""
- default = None
- try:
- default = self.doc.xpathEval("/profiles/default")[0]
- profile = default.prop("profile")
- except:
- profile = None
+ default = None
+ try:
+ default = self.doc.xpathEval("/profiles/default")[0]
+ profile = default.prop("profile")
+ except:
+ profile = None
if not profile_location:
return profile
@@ -301,13 +301,13 @@
profile = user.prop("profile")
except:
profile = None
- if not profile and not ignore_default:
- try:
- query = "/profiles/default[1][ profile]"
- user = self.doc.xpathEval(query)[0]
- profile = user.prop("profile")
- except:
- profile = None
+ if not profile and not ignore_default:
+ try:
+ query = "/profiles/default[1][ profile]"
+ user = self.doc.xpathEval(query)[0]
+ profile = user.prop("profile")
+ except:
+ profile = None
if not profile_location:
return profile
@@ -317,44 +317,44 @@
def __save_as(self, filename = None):
"""Save the current version to the given filename"""
- if filename == None:
- filename = self.file
+ if filename == None:
+ filename = self.file
+
+ dprint("Saving UserDatabase to %s\n", filename)
+ try:
+ os.rename(filename, filename + ".bak")
+ backup = 1
+ except:
+ backup = 0
+ pass
+
+ try:
+ f = open(filename, 'w')
+ except:
+ if backup == 1:
+ try:
+ os.rename(filename + ".bak", filename)
+ dprint("Restore from %s.bak\n", filename)
+ except:
+ dprint("Failed to restore from %s.bak\n", filename)
+
+ raise UserDatabaseException(
+ _("Could not open %s for writing") % filename)
+ try:
+ f.write(self.doc.serialize("UTF-8", format=1))
+ f.close()
+ except:
+ if backup == 1:
+ try:
+ os.rename(filename + ".bak", filename)
+ dprint("Restore from %s.bak\n", filename)
+ except:
+ dprint("Failed to restore from %s.bak\n", filename)
- dprint("Saving UserDatabase to %s\n", filename)
- try:
- os.rename(filename, filename + ".bak")
- backup = 1
- except:
- backup = 0
- pass
-
- try:
- f = open(filename, 'w')
- except:
- if backup == 1:
- try:
- os.rename(filename + ".bak", filename)
- dprint("Restore from %s.bak\n", filename)
- except:
- dprint("Failed to restore from %s.bak\n", filename)
-
- raise UserDatabaseException(
- _("Could not open %s for writing") % filename)
- try:
- f.write(self.doc.serialize("UTF-8", format=1))
- f.close()
- except:
- if backup == 1:
- try:
- os.rename(filename + ".bak", filename)
- dprint("Restore from %s.bak\n", filename)
- except:
- dprint("Failed to restore from %s.bak\n", filename)
-
- raise UserDatabaseException(
- _("Failed to save UserDatabase to %s") % filename)
-
- self.modified = 0
+ raise UserDatabaseException(
+ _("Failed to save UserDatabase to %s") % filename)
+
+ self.modified = 0
def set_default_profile (self, profile):
"""Set the default profile to be used for all users.
@@ -363,30 +363,30 @@
"""
if profile is None:
profile = ""
- self.modified = 0
- try:
- default = self.doc.xpathEval("/profiles/default")[0]
- oldprofile = default.prop("profile")
- if oldprofile != profile:
- default.setProp("profile", profile)
- self.modified = 1
- except:
- try:
- profiles = self.doc.xpathEval("/profiles")[0]
- except:
- raise UserDatabaseException(
- _("File %s is not a profile configuration") %
+ self.modified = 0
+ try:
+ default = self.doc.xpathEval("/profiles/default")[0]
+ oldprofile = default.prop("profile")
+ if oldprofile != profile:
+ default.setProp("profile", profile)
+ self.modified = 1
+ except:
+ try:
+ profiles = self.doc.xpathEval("/profiles")[0]
+ except:
+ raise UserDatabaseException(
+ _("File %s is not a profile configuration") %
(self.file))
- try:
- default = profiles.newChild(None, "default", None)
- default.setProp("profile", profile)
- except:
- raise UserDatabaseException(
- _("Failed to add default profile %s to configuration") %
+ try:
+ default = profiles.newChild(None, "default", None)
+ default.setProp("profile", profile)
+ except:
+ raise UserDatabaseException(
+ _("Failed to add default profile %s to configuration") %
(profile))
- self.modified = 1
- if self.modified == 1:
- self.__save_as()
+ self.modified = 1
+ if self.modified == 1:
+ self.__save_as()
def set_profile (self, username, profile):
"""Set the profile for a given username.
@@ -397,48 +397,48 @@
"""
if profile is None:
profile = ""
- self.modified = 0
- try:
- query = "/profiles/user[ name='%s']" % username
- user = self.doc.xpathEval(query)[0]
- oldprofile = user.prop("profile")
- if oldprofile != profile:
- user.setProp("profile", profile)
- self.modified = 1
- except:
- try:
- profiles = self.doc.xpathEval("/profiles")[0]
- except:
- raise UserDatabaseException(
- _("File %s is not a profile configuration") %
+ self.modified = 0
+ try:
+ query = "/profiles/user[ name='%s']" % username
+ user = self.doc.xpathEval(query)[0]
+ oldprofile = user.prop("profile")
+ if oldprofile != profile:
+ user.setProp("profile", profile)
+ self.modified = 1
+ except:
+ try:
+ profiles = self.doc.xpathEval("/profiles")[0]
+ except:
+ raise UserDatabaseException(
+ _("File %s is not a profile configuration") %
(self.file))
- try:
- user = profiles.newChild(None, "user", None)
- user.setProp("name", username)
- user.setProp("profile", profile)
- except:
- raise UserDatabaseException(
- _("Failed to add user %s to profile configuration") %
+ try:
+ user = profiles.newChild(None, "user", None)
+ user.setProp("name", username)
+ user.setProp("profile", profile)
+ except:
+ raise UserDatabaseException(
+ _("Failed to add user %s to profile configuration") %
(username))
- self.modified = 1
- if self.modified == 1:
- self.__save_as()
-
+ self.modified = 1
+ if self.modified == 1:
+ self.__save_as()
+
def get_profiles (self):
"""Return the list of currently available profiles.
This is basically just list of zip files in
/etc/desktop-profiles, each without the .zip extension.
"""
- list = []
- try:
- for file in os.listdir(config.PROFILESDIR):
- if file[-4:] != ".zip":
- continue
- list.append(file[0:-4])
- except:
- dprint("Failed to read directory(%s)\n" % (config.PROFILESDIR))
- # TODO: also list remote profiles as found in self.doc
- return list
+ list = []
+ try:
+ for file in os.listdir(config.PROFILESDIR):
+ if file[-4:] != ".zip":
+ continue
+ list.append(file[0:-4])
+ except:
+ dprint("Failed to read directory(%s)\n" % (config.PROFILESDIR))
+ # TODO: also list remote profiles as found in self.doc
+ return list
def is_sabayon_controlled (self, username):
"""Return True if user's configuration was ever under Sabayon's
@@ -465,27 +465,27 @@
be real users - i.e. should not include system users
like nobody, gdm, nfsnobody etc.
"""
- list = []
- try:
- users = pwd.getpwall()
- except:
- raise UserDatabaseException(_("Failed to get the user list"))
-
- for user in pwd.getpwall():
- try:
- # remove non-users
- if user[2] < 500:
- continue
- if user[0] in list:
- continue
- if user[6] == "" or string.find(user[6], "nologin") != -1:
- continue
+ list = []
+ try:
+ users = pwd.getpwall()
+ except:
+ raise UserDatabaseException(_("Failed to get the user list"))
+
+ for user in pwd.getpwall():
+ try:
+ # remove non-users
+ if user[2] < 500:
+ continue
+ if user[0] in list:
+ continue
+ if user[6] == "" or string.find(user[6], "nologin") != -1:
+ continue
if user[0][len (user[0]) - 1] == "$": # Active Directory hosts end in "$"; we don't want to show those as users
continue
- list.append(user[0])
- except:
- pass
- return list
+ list.append(user[0])
+ except:
+ pass
+ return list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]