From 9c524ec3cb8f072c9a1eba98d941cd430b6c2f26 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 10 Feb 2015 20:32:07 +0530 Subject: [PATCH] redirected apt cache update logs to log file --- ee/cli/plugins/site.py | 4 ++-- ee/core/aptget.py | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index e3d603c9..f73ea40c 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1,4 +1,4 @@ -"""EasyEngine site controller.""" +# """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.variables import EEVariables @@ -913,7 +913,7 @@ class EESiteUpdateController(CementBaseController): msg="{0} updated with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - # setwebrootpermissions(self, data['webroot']) + setwebrootpermissions(self, data['webroot']) if ee_auth and len(ee_auth): for msg in ee_auth: Log.info(self, Log.ENDC + msg) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 04fce81c..b33b3d1d 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -15,15 +15,19 @@ class EEAptGet(): """ try: apt_cache = apt.cache.Cache() - apt_cache.update() - success = (apt_cache.commit( - apt.progress.text.AcquireProgress(), - apt.progress.base.InstallProgress())) - #apt_cache.close() - return success + import sys + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a') + apt_cache.update(apt.progress.text.AcquireProgress()) + sys.stdout = orig_out + # success = (apt_cache.commit( + # apt.progress.text.AcquireProgress(), + # apt.progress.base.InstallProgress())) + # #apt_cache.close() + # return success except AttributeError as e: Log.error(self, 'AttributeError: ' + str(e)) - except FetchFailedException as e: + except Exception as e: Log.debug(self, 'SystemError: ' + str(e)) Log.error(self, 'Unable to Fetch update') @@ -85,7 +89,12 @@ class EEAptGet(): if apt_cache.install_count > 0: try: #apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), + 'a') + result = apt_cache.commit(apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress()) + sys.stdout = orig_out #apt_cache.close() return result except SystemError as e: @@ -134,7 +143,12 @@ class EEAptGet(): if apt_cache.delete_count > 0: try: # apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), + 'a') + result = apt_cache.commit(apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress()) + sys.stdout = orig_out # apt_cache.close() return result except SystemError as e: @@ -150,7 +164,10 @@ class EEAptGet(): Similar to `apt-get autoclean` """ try: + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a') apt_get.autoclean("-y") + sys.stdout = orig_out except ErrorReturnCode as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to apt-get autoclean")