From 48eb14dc2991d16f00167c0e4f55664e353a8c04 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 6 Jan 2015 13:16:50 +0530 Subject: [PATCH] added urllib in clean_opcache --- ee/cli/plugins/clean.py | 24 +++++++++++++----------- ee/core/fileutils.py | 4 +--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 02444987..2971d942 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -4,6 +4,7 @@ from ee.core.services import EEService from cement.core.controller import CementBaseController, expose from cement.core import handler, hook import os +import urllib.request def clean_plugin_hook(app): @@ -51,29 +52,30 @@ class EECleanController(CementBaseController): print("in memcache..") pkg = EEAptGet() if(pkg.is_installed("memcached")): - print("memcache is installed...") + self.app.log.info("memcache is installed...") EEService.restart_service(self, "memcached") - print("Cleaning memcache..") + self.app.log.info("Cleaning memcache..") else: - print("memcache is not installed..") + self.app.log.info("memcache is not installed..") @expose(hide=True) def clean_fastcgi(self): if(os.path.isdir("/var/run/nginx-cache")): - print("Cleaning fastcgi...") + self.app.log.info("Cleaning fastcgi...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - print("Error occur while Cleaning fastcgi..") + self.app.log.info("Error occur while Cleaning fastcgi..") @expose(hide=True) def clean_opcache(self): + #try: try: - print("Cleaning opcache.... ") - EEShellExec.cmd_exec(self, "wget --no-check-certificate --spider" - " -q https://127.0.0.1:22222/cache/opcache" - "/opgui.php?page=reset") - except OSError: - print("Unable to clean opache..") + self.app.log.info("Cleaning opcache.... ") + wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" + "/opcache/opgui.php?page=reset").read() + except Exception as e: + self.app.log.info("Unable to clean opacache\n {0}{1}" + .format(e.errno, e.strerror)) def load(app): diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 9740ca42..c74ab885 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -15,15 +15,13 @@ class EEFileUtils(): def remove(self, filelist): for file in filelist: if os.path.isfile(file): - self.app.log.debug('Removing file') self.app.log.info("Removing "+os.path.basename(file)+" ...") os.remove(file) self.app.log.debug('file Removed') self.app.log.info("Done") if os.path.isdir(file): try: - self.app.log.debug('Removing file') - print("Removing "+os.path.basename(file)+" ...") + print("Removing "+os.path.basename(file)+"...") shutil.rmtree(file) self.app.log.info("Done") except shutil.Error as e: