summaryrefslogtreecommitdiff
path: root/installer/pluginhandler.py
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2016-01-06 12:15:26 +0100
committerDidier Raboud <odyx@debian.org>2016-01-06 12:15:26 +0100
commit72c0810f69589f4253a7ac5c88abb3d694bc0dec (patch)
tree0b8f6829f7b2a5917ef5d633f70471780f39c2f4 /installer/pluginhandler.py
parent86780323ce1e02c6e2295ce358d96172e0cd450f (diff)
Imported Upstream version 3.13.8
Diffstat (limited to 'installer/pluginhandler.py')
-rwxr-xr-xinstaller/pluginhandler.py53
1 files changed, 30 insertions, 23 deletions
diff --git a/installer/pluginhandler.py b/installer/pluginhandler.py
index bca442ad9..253d32877 100755
--- a/installer/pluginhandler.py
+++ b/installer/pluginhandler.py
@@ -60,7 +60,7 @@ PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS = 7
class PluginHandle(object):
- def __init__(self, pluginPath = "/tmp"):
+ def __init__(self, pluginPath = "/var/log/hp/tmp"):
self.__plugin_path = pluginPath
self.__required_version = ""
self.__plugin_name = ""
@@ -117,7 +117,6 @@ class PluginHandle(object):
for PRODUCT in products:
MODEL = PRODUCT.replace('hp-', '').replace('hp_', '')
- UDEV_SYSFS_RULES=sys_conf.get('configure','udev_sysfs_rules','no')
for s in plugin_spec.get("products", PRODUCT).split(','):
if not plugin_spec.has_section(s):
@@ -129,13 +128,6 @@ class PluginHandle(object):
trg = plugin_spec.get(s, 'trg', '')
link = plugin_spec.get(s, 'link', '')
- # In Cent os 5.x distro's SYSFS attribute will be used. and Other distro's uses ATTR/ATTRS attribute in rules.
- # Following condition to check this...
- if UDEV_SYSFS_RULES == 'no' and 'sysfs' in src:
- continue
- if UDEV_SYSFS_RULES == 'yes' and 'sysfs' not in src:
- continue
-
if not src:
log.error("Missing 'src=' value in section [%s]" % s)
os.chdir(cwd)
@@ -232,7 +224,7 @@ class PluginHandle(object):
finally:
os.close(local_conf_fp)
-# os.remove(local_conf)
+ os.remove(local_conf)
return status, url, check_sum
@@ -284,12 +276,12 @@ class PluginHandle(object):
def download(self, pluginPath='',callback = None):
core = core_install.CoreInstall()
- sts, url, checksum = self.__getPluginInformation(callback)
if pluginPath:# and os.path.exists(pluginPath):
src = pluginPath
- checksum = "" # TBD: Local copy may have different checksum. So ignoring checksume
+ checksum = "" # TBD: Local copy may have different checksum. So ignoring checksum
else:
+ sts, url, checksum = self.__getPluginInformation(callback)
src = url
if sts != PLUGIN_INSTALL_ERROR_NONE:
return sts, ""
@@ -307,10 +299,7 @@ class PluginHandle(object):
except (OSError, IOError), e:
log.error("Failed in OS operations:%s "%e.strerror)
- return status, url, check_sum
-
- #Check whether plugin is accessible in Openprinting.org website otherwise dowload plugin from alternate location.
-
+ return PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR, ""
try:
if src.startswith('file://'):
@@ -323,21 +312,26 @@ class PluginHandle(object):
status, output = utils.run(cmd)
log.debug("wget returned: %d" % status)
- if status != 0:
+ #Check whether plugin is accessible in Openprinting.org website otherwise dowload plugin from alternate location.
+ if status != 0 or os_utils.getFileSize(plugin_file) <= 0:
src = os.path.join(PLUGIN_FALLBACK_LOCATION, self.__plugin_name)
log.info("Plugin is not accessible. Trying to download it from fallback location: [%s]" % src)
cmd = "%s --cache=off -P %s %s" % (wget,self.__plugin_path,src)
log.debug(cmd)
status, output = utils.run(cmd)
+ if status != 0 or os_utils.getFileSize(plugin_file) <= 0:
+ log.error("Plug-in download is failed from both URL and fallback location.")
+ return PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND, ""
+
except IOError, e:
log.error("Plug-in download failed: %s" % e.strerror)
- return PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND, e.strerror
+ return PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND, ""
if core.isErrorPage(file(plugin_file, 'r').read(1024)):
log.debug(file(plugin_file, 'r').read(1024))
os.remove(plugin_file)
- return PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND, -1
+ return PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND, ""
# Try to download and check the GPG digital signature
digsig_url = src + '.asc'
@@ -366,17 +360,30 @@ class PluginHandle(object):
def run_plugin(self, plugin_file, mode=GUI_MODE):
+ result = False
log.debug("run_plugin plugin_file =%s mode=%d"%(plugin_file, mode))
+
+ cwd = os.getcwd()
+ os.chdir(self.__plugin_path)
+
if mode == GUI_MODE:
- cmd = "sh %s --nox11 -- -u" % plugin_file
+ cmd = "sh %s --keep --nox11 -- -u" % plugin_file
else:
- cmd = "sh %s --nox11 -- -i" % plugin_file
+ cmd = "sh %s --keep --nox11 -- -i" % plugin_file
if os_utils.execute(cmd) == 0:
- return True
+ result = True
else:
log.error("Python gobject/dbus may be not installed")
- return False
+ result = False
+
+ try:
+ shutil.rmtree('./plugin_tmp')
+ except OSError:
+ log.warn("Failed to remove the temporary files")
+
+ os.chdir(cwd)
+ return result
def copyFiles(self, src_dir):