Skip to content

Commit 9c524ec

Browse files
committed
redirected apt cache update logs to log file
1 parent b373152 commit 9c524ec

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

ee/cli/plugins/site.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""EasyEngine site controller."""
1+
# """EasyEngine site controller."""
22
from cement.core.controller import CementBaseController, expose
33
from cement.core import handler, hook
44
from ee.core.variables import EEVariables
@@ -913,7 +913,7 @@ def default(self):
913913
msg="{0} updated with {1} {2}"
914914
.format(ee_www_domain, stype, cache))
915915
# Setup Permissions for webroot
916-
# setwebrootpermissions(self, data['webroot'])
916+
setwebrootpermissions(self, data['webroot'])
917917
if ee_auth and len(ee_auth):
918918
for msg in ee_auth:
919919
Log.info(self, Log.ENDC + msg)

ee/core/aptget.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ def update(self):
1515
"""
1616
try:
1717
apt_cache = apt.cache.Cache()
18-
apt_cache.update()
19-
success = (apt_cache.commit(
20-
apt.progress.text.AcquireProgress(),
21-
apt.progress.base.InstallProgress()))
22-
#apt_cache.close()
23-
return success
18+
import sys
19+
orig_out = sys.stdout
20+
sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a')
21+
apt_cache.update(apt.progress.text.AcquireProgress())
22+
sys.stdout = orig_out
23+
# success = (apt_cache.commit(
24+
# apt.progress.text.AcquireProgress(),
25+
# apt.progress.base.InstallProgress()))
26+
# #apt_cache.close()
27+
# return success
2428
except AttributeError as e:
2529
Log.error(self, 'AttributeError: ' + str(e))
26-
except FetchFailedException as e:
30+
except Exception as e:
2731
Log.debug(self, 'SystemError: ' + str(e))
2832
Log.error(self, 'Unable to Fetch update')
2933

@@ -85,7 +89,12 @@ def install_package(self, package_name):
8589
if apt_cache.install_count > 0:
8690
try:
8791
#apt_pkg.PkgSystemUnLock()
88-
result = apt_cache.commit()
92+
orig_out = sys.stdout
93+
sys.stdout = open(self.app.config.get('log.logging', 'file'),
94+
'a')
95+
result = apt_cache.commit(apt.progress.text.AcquireProgress(),
96+
apt.progress.base.InstallProgress())
97+
sys.stdout = orig_out
8998
#apt_cache.close()
9099
return result
91100
except SystemError as e:
@@ -134,7 +143,12 @@ def remove_package(self, package_name, purge=False):
134143
if apt_cache.delete_count > 0:
135144
try:
136145
# apt_pkg.PkgSystemUnLock()
137-
result = apt_cache.commit()
146+
orig_out = sys.stdout
147+
sys.stdout = open(self.app.config.get('log.logging', 'file'),
148+
'a')
149+
result = apt_cache.commit(apt.progress.text.AcquireProgress(),
150+
apt.progress.base.InstallProgress())
151+
sys.stdout = orig_out
138152
# apt_cache.close()
139153
return result
140154
except SystemError as e:
@@ -150,7 +164,10 @@ def auto_clean(self):
150164
Similar to `apt-get autoclean`
151165
"""
152166
try:
167+
orig_out = sys.stdout
168+
sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a')
153169
apt_get.autoclean("-y")
170+
sys.stdout = orig_out
154171
except ErrorReturnCode as e:
155172
Log.debug(self, "{0}".format(e))
156173
Log.error(self, "Unable to apt-get autoclean")

0 commit comments

Comments
 (0)