Python 3.8 fixes.
This commit is contained in:
11
README.rst
11
README.rst
@@ -30,6 +30,17 @@ Usage::
|
||||
$ cd modoboa-installer
|
||||
$ sudo ./run.py <your domain>
|
||||
|
||||
.. note::
|
||||
|
||||
On some systems (Ubuntu 20.04 for example), you might encounter the
|
||||
following issue::
|
||||
|
||||
/usr/bin/env: 'python': No such file or directory
|
||||
|
||||
If so, try to run the command like this::
|
||||
|
||||
$ sudo python3 run.py <your domain>
|
||||
|
||||
A configuration file will be automatically generated the first time
|
||||
you run the installer, please don't copy the
|
||||
``installer.cfg.template`` file manually.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Database related tools."""
|
||||
|
||||
import os
|
||||
import platform
|
||||
import pwd
|
||||
import stat
|
||||
|
||||
@@ -143,7 +142,7 @@ class MySQL(Database):
|
||||
|
||||
def install_package(self):
|
||||
"""Preseed package installation."""
|
||||
name, version, _id = platform.linux_distribution()
|
||||
name, version, _id = utils.dist_info()
|
||||
name = name.lower()
|
||||
if name == "debian":
|
||||
mysql_name = "mysql" if version.startswith("8") else "mariadb"
|
||||
|
||||
@@ -35,9 +35,9 @@ class Postfix(base.Installer):
|
||||
def install_packages(self):
|
||||
"""Preconfigure postfix package installation."""
|
||||
if "centos" in utils.dist_name():
|
||||
config = configparser.SafeConfigParser()
|
||||
config = configparser.ConfigParser()
|
||||
with open("/etc/yum.repos.d/CentOS-Base.repo") as fp:
|
||||
config.readfp(fp)
|
||||
config.read_file(fp)
|
||||
config.set("centosplus", "enabled", "1")
|
||||
config.set("centosplus", "includepkgs", "postfix-*")
|
||||
config.set("base", "exclude", "postfix-*")
|
||||
|
||||
@@ -73,17 +73,26 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, login=True, **kwargs):
|
||||
return process.returncode, output
|
||||
|
||||
|
||||
def dist_name():
|
||||
"""Try to guess the distribution name."""
|
||||
def dist_info():
|
||||
"""Try to return information about the system we're running on."""
|
||||
try:
|
||||
# Python 3.8 and up way
|
||||
import distro
|
||||
name, version, _id = distro.linux_distribution()
|
||||
except ImportError as e:
|
||||
return distro.linux_distribution()
|
||||
except ImportError:
|
||||
# Python 3.7 and down way
|
||||
import platform
|
||||
name, version, _id = platform.linux_distribution()
|
||||
return "unknown" if not name else name.lower()
|
||||
return platform.linux_distribution()
|
||||
printcolor(
|
||||
"Failed to retrieve information about your system, aborting.",
|
||||
RED)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def dist_name():
|
||||
"""Try to guess the distribution name."""
|
||||
name, version, _id = dist_info()
|
||||
return name.lower()
|
||||
|
||||
|
||||
def mkdir(path, mode, uid, gid):
|
||||
|
||||
4
run.py
4
run.py
@@ -79,9 +79,9 @@ def main(input_args):
|
||||
utils.check_config_file(args.configfile, args.interactive, args.upgrade)
|
||||
if args.stop_after_configfile_check:
|
||||
return
|
||||
config = configparser.SafeConfigParser()
|
||||
config = configparser.ConfigParser()
|
||||
with open(args.configfile) as fp:
|
||||
config.readfp(fp)
|
||||
config.read_file(fp)
|
||||
if not config.has_section("general"):
|
||||
config.add_section("general")
|
||||
config.set("general", "domain", args.domain)
|
||||
|
||||
Reference in New Issue
Block a user