X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=5c7164705ee4147fe7f07c67d1adf0180e438cea;hb=6be5aed8f454679a634d194d0dc41d5dc9e5cb22;hp=b1a34c92c9f26ba23f0415abf0f3633253cb6395;hpb=3d8f1f7a48b565b6d6a4b36c827e256586558e40;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index b1a34c92..5c716470 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -70,7 +70,7 @@ def dak_getstatusoutput(cmd): pipe = subprocess.Popen(cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - output = "".join(pipe.stdout.readlines()) + output, _ = pipe.communicate() if output[-1:] == '\n': output = output[:-1] @@ -730,20 +730,20 @@ def copy (src, dest, overwrite = 0, perms = 0664): ################################################################################ def where_am_i (): - res = socket.gethostbyaddr(socket.gethostname()) - database_hostname = Cnf.get("Config::" + res[0] + "::DatabaseHostname") + res = socket.getfqdn() + database_hostname = Cnf.get("Config::" + res + "::DatabaseHostname") if database_hostname: return database_hostname else: - return res[0] + return res def which_conf_file (): if os.getenv('DAK_CONFIG'): return os.getenv('DAK_CONFIG') - res = socket.gethostbyaddr(socket.gethostname()) + res = socket.getfqdn() # In case we allow local config files per user, try if one exists - if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"): + if Cnf.FindB("Config::" + res + "::AllowLocalConfig"): homedir = os.getenv("HOME") confpath = os.path.join(homedir, "/etc/dak.conf") if os.path.exists(confpath): @@ -751,27 +751,27 @@ def which_conf_file (): # We are still in here, so there is no local config file or we do # not allow local files. Do the normal stuff. - if Cnf.get("Config::" + res[0] + "::DakConfig"): - return Cnf["Config::" + res[0] + "::DakConfig"] + if Cnf.get("Config::" + res + "::DakConfig"): + return Cnf["Config::" + res + "::DakConfig"] return default_config def which_apt_conf_file (): - res = socket.gethostbyaddr(socket.gethostname()) + res = socket.getfqdn() # In case we allow local config files per user, try if one exists - if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"): + if Cnf.FindB("Config::" + res + "::AllowLocalConfig"): homedir = os.getenv("HOME") confpath = os.path.join(homedir, "/etc/dak.conf") if os.path.exists(confpath): apt_pkg.ReadConfigFileISC(Cnf,default_config) - if Cnf.get("Config::" + res[0] + "::AptConfig"): - return Cnf["Config::" + res[0] + "::AptConfig"] + if Cnf.get("Config::" + res + "::AptConfig"): + return Cnf["Config::" + res + "::AptConfig"] else: return default_apt_config def which_alias_file(): - hostname = socket.gethostbyaddr(socket.gethostname())[0] + hostname = socket.getfqdn() aliasfn = '/var/lib/misc/'+hostname+'/forward-alias' if os.path.exists(aliasfn): return aliasfn