本文整理汇总了Python中ee.core.aptget.EEAptGet.auto_remove方法的典型用法代码示例。如果您正苦于以下问题:Python EEAptGet.auto_remove方法的具体用法?Python EEAptGet.auto_remove怎么用?Python EEAptGet.auto_remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ee.core.aptget.EEAptGet
的用法示例。
在下文中一共展示了EEAptGet.auto_remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_mariadb
# 需要导入模块: from ee.core.aptget import EEAptGet [as 别名]
# 或者: from ee.core.aptget.EEAptGet import auto_remove [as 别名]
def migrate_mariadb(self):
# Backup all database
EEMysql.backupAll(self)
# Add MariaDB repo
Log.info(self, "Adding repository for MariaDB, please wait ...")
mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
"\nPin-Priority: 1000\n")
with open('/etc/apt/preferences.d/'
'MariaDB.pref', 'w') as mysql_pref_file:
mysql_pref_file.write(mysql_pref)
EERepo.add(self, repo_url=EEVariables.ee_mysql_repo)
Log.debug(self, 'Adding key for {0}'
.format(EEVariables.ee_mysql_repo))
EERepo.add_key(self, '0xcbcb082a1bb943db',
keyserver="keyserver.ubuntu.com")
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.my.cnf')
try:
chars = config['client']['password']
except Exception as e:
Log.error(self, "Error: process exited with error %s"
% e)
Log.debug(self, "Pre-seeding MariaDB")
Log.debug(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password "
"password \" | "
"debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password "
"password {chars}\" | "
"debconf-set-selections"
.format(chars=chars),
log=False)
Log.debug(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password_again "
"password \" | "
"debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password_again "
"password {chars}\" | "
"debconf-set-selections"
.format(chars=chars),
log=False)
# Install MariaDB
apt_packages = EEVariables.ee_mysql + ["php5-mysql"]
Log.info(self, "Updating apt-cache, please wait ...")
EEAptGet.update(self)
Log.info(self, "Installing MariaDB, please wait ...")
EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"])
EEAptGet.auto_remove(self)
EEAptGet.install(self, apt_packages)
示例2: migrate_mariadb
# 需要导入模块: from ee.core.aptget import EEAptGet [as 别名]
# 或者: from ee.core.aptget.EEAptGet import auto_remove [as 别名]
def migrate_mariadb(self):
# Backup all database
EEMysql.backupAll(self)
# Add MariaDB repo
Log.info(self, "Adding repository for MariaDB, please wait...")
mysql_pref = ("Package: *\nPin: origin sfo1.mirrors.digitalocean.com"
"\nPin-Priority: 1000\n")
with open('/etc/apt/preferences.d/'
'MariaDB.pref', 'w') as mysql_pref_file:
mysql_pref_file.write(mysql_pref)
EERepo.add(self, repo_url=EEVariables.ee_mysql_repo)
Log.debug(self, 'Adding key for {0}'
.format(EEVariables.ee_mysql_repo))
EERepo.add_key(self, '0xcbcb082a1bb943db',
keyserver="keyserver.ubuntu.com")
config = configparser.ConfigParser()
if os.path.exists('/etc/mysql/conf.d/my.cnf'):
config.read('/etc/mysql/conf.d/my.cnf')
else:
config.read(os.path.expanduser("~")+'/.my.cnf')
try:
chars = config['client']['password']
except Exception as e:
Log.error(self, "Error: process exited with error %s"
% e)
Log.debug(self, "Pre-seeding MariaDB")
Log.debug(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password "
"password \" | "
"debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password "
"password {chars}\" | "
"debconf-set-selections"
.format(chars=chars),
log=False)
Log.debug(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password_again "
"password \" | "
"debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password_again "
"password {chars}\" | "
"debconf-set-selections"
.format(chars=chars),
log=False)
# Install MariaDB
apt_packages = EEVariables.ee_mysql
# If PHP is installed then install php5-mysql
if EEAptGet.is_installed(self, "php5-fpm"):
apt_packages = apt_packages + ["php5-mysql"]
# If mail server is installed then install dovecot-sql and postfix-sql
if EEAptGet.is_installed(self, "dovecot-core"):
apt_packages = apt_packages + ["dovecot-mysql", "postfix-mysql",
"libclass-dbi-mysql-perl"]
Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self)
Log.info(self, "Installing MariaDB, please wait...")
EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"])
EEAptGet.auto_remove(self)
EEAptGet.install(self, apt_packages)
# Restart dovecot and postfix if installed
if EEAptGet.is_installed(self, "dovecot-core"):
EEService.restart_service(self, 'dovecot')
EEService.restart_service(self, 'postfix')