mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 21:42:21 +03:00
return values added to install_with_apt_get and uninstall_with_apt_get methods because of method doesnt give any error even if its return code is unsuccessfull for install/uninstall process
This commit is contained in:
parent
3d350cff3b
commit
733ee95aa3
1 changed files with 16 additions and 19 deletions
|
@ -123,7 +123,8 @@ class Util:
|
||||||
try:
|
try:
|
||||||
if as_user is not None:
|
if as_user is not None:
|
||||||
command = 'su - {0} -c "{1}"'.format(as_user, command)
|
command = 'su - {0} -c "{1}"'.format(as_user, command)
|
||||||
process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=shell)
|
process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, shell=shell)
|
||||||
|
|
||||||
if result is True:
|
if result is True:
|
||||||
result_code = process.wait()
|
result_code = process.wait()
|
||||||
|
@ -202,27 +203,23 @@ class Util:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def install_with_apt_get(package_name, package_version=None):
|
def install_with_apt_get(package_name, package_version=None):
|
||||||
try:
|
|
||||||
if package_version is not None:
|
if package_version is not None:
|
||||||
process = subprocess.Popen('apt-get install --yes --force-yes {0}={1}'.format(package_name, package_version), shell=True)
|
command = 'apt-get install --yes --force-yes {0}={1}'.format(package_name, package_version)
|
||||||
process.wait()
|
|
||||||
else:
|
else:
|
||||||
process = subprocess.Popen('apt-get install --yes --force-yes {0}'.format(package_name), shell=True)
|
command = 'apt-get install --yes --force-yes {0}'.format(package_name)
|
||||||
process.wait()
|
|
||||||
except:
|
return Util.execute(command)
|
||||||
raise
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def uninstall_package(package_name, package_version=None):
|
def uninstall_package(package_name, package_version=None):
|
||||||
try:
|
|
||||||
if package_version is not None:
|
if package_version is not None:
|
||||||
process = subprocess.Popen('apt-get purge --yes --force-yes {0}={1}'.format(package_name, package_version), shell=True)
|
command = 'apt-get purge --yes --force-yes {0}={1}'.format(package_name, package_version)
|
||||||
process.wait()
|
|
||||||
else:
|
else:
|
||||||
process = subprocess.Popen('apt-get purge --yes --force-yes {0}'.format(package_name), shell=True)
|
command = 'apt-get purge --yes --force-yes {0}'.format(package_name)
|
||||||
process.wait()
|
|
||||||
except:
|
return Util.execute(command)
|
||||||
raise
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_installed(package_name):
|
def is_installed(package_name):
|
||||||
|
|
Loading…
Reference in a new issue