This commit is contained in:
Volkan Şahin 2016-08-09 16:51:13 +03:00
commit 3650608a19

View file

@ -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):