Esempio n. 1
0
 def install(self, pid):
     """ Install a product in a Plone site """
     qi = getToolByName(self.context, 'portal_quickinstaller')
     error_msg = translate(_("msg_error_install",
                           default=u"An error occurred during installation of ${product} on site ${site}. Please check the log.",
                           mapping={'product': pid,
                                    'site': self.context.getId()}),
                          context=self.request)
     try:
         result = qi.installProduct(pid)
         if not result:
             return json.dumps({'result': 'ok',
                                'new_state': 'installed'})
         else:
             return json.dumps({'msg': result,
                                'result': 'nok'})
     except Exception:
         logger.exception("Error in install step")
         return json.dumps({'msg': error_msg,
                            'result': 'nok'})
Esempio n. 2
0
 def getProductState(self, site, product_id):
     """
     return info about given product
     """
     qi = getToolByName(site, 'portal_quickinstaller')
     if not qi.isProductInstalled(product_id):
         return {'status': "notInstalled"}
     try:
         upgrade_info = qi.upgradeInfo(product_id)
     except Exception:
         logger.exception("Unable to retrieve infos")
         return {'status': 'error'}
     res_dict = {}
     res_dict['installed_version'] = upgrade_info.get('installedVersion')
     res_dict['new_version'] = upgrade_info.get('newVersion')
     if upgrade_info.get('available') and upgrade_info.get('required'):
         res_dict['status'] = "toBeUpgraded"
     else:
         res_dict['status'] = "installed"
     return res_dict