def invoke(self, request): function = request.options.get("function") application_id = request.options.get("application") application = Application.find(application_id) force = request.options.get("force") try: # make sure that the application cane be installed/updated can_continue = True result = {"install": [], "remove": [], "broken": []} if not application: MODULE.info("Application not found: %s" % application_id) can_continue = False elif function == "install" and not application.can_be_installed(self.package_manager): MODULE.info("Application cannot be installed: %s" % application_id) can_continue = False elif function == "update" and not application.can_be_updated(): MODULE.info("Application cannot be updated: %s" % application_id) can_continue = False if can_continue and function in ("install", "update"): result = application.install_dry_run( self.package_manager, self.component_manager, remove_component=False ) if result["broken"] or (result["remove"] and not force): MODULE.info("Remove component: %s" % application_id) self.component_manager.remove_app(application) self.package_manager.update() can_continue = False elif can_continue and function in ("uninstall",) and not force: result["remove"] = application.uninstall_dry_run(self.package_manager) can_continue = False result["can_continue"] = can_continue self.finished(request.id, result) if can_continue: def _thread(module, application, function): with module.package_manager.locked(reset_status=True, set_finished=True): with module.package_manager.no_umc_restart(): if function in ("install", "update"): # dont have to add component: already added during dry_run return application.install( module.package_manager, module.component_manager, add_component=False ) else: return application.uninstall(module.package_manager, module.component_manager) def _finished(thread, result): if isinstance(result, BaseException): MODULE.warn("Exception during %s %s: %s" % (function, application_id, str(result))) thread = notifier.threads.Simple( "invoke", notifier.Callback(_thread, self, application, function), _finished ) thread.run() except LockError: # make it thread safe: another process started a package manager # this module instance already has a running package manager raise umcm.UMC_CommandError(_("Another package operation is in progress"))
def app_center_app_license(self, application): application = Application.find(application) if not application or not application.get("licensefile"): raise umcm.UMC_CommandError(_("No license file available for application: %s") % (application.id)) # open the license file and replace line breaks with BR-tags fp = util.urlopen(application.get("licensefile")) txt = "".join(fp.readlines()).strip() txt = txt.replace("\n\n\n", "\n<br>\n<br>\n<br>\n") txt = txt.replace("\n\n", "\n<br>\n<br>\n") return txt
def app_center_app_license(self, application): application = Application.find(application) if not application or not application.get('licensefile'): raise umcm.UMC_CommandError( _('No license file available for application: %s') % (application.id)) # open the license file and replace line breaks with BR-tags fp = util.urlopen(application.get('licensefile')) txt = ''.join(fp.readlines()).strip() txt = txt.replace('\n\n\n', '\n<br>\n<br>\n<br>\n') txt = txt.replace('\n\n', '\n<br>\n<br>\n') return txt
def get(self, application): LICENSE.reload() application = Application.find(application) self.package_manager.reopen_cache() return application.to_dict(self.package_manager)
def invoke(self, request): function = request.options.get('function') application_id = request.options.get('application') application = Application.find(application_id) force = request.options.get('force') try: # make sure that the application cane be installed/updated can_continue = True result = { 'install': [], 'remove': [], 'broken': [], } if not application: MODULE.info('Application not found: %s' % application_id) can_continue = False elif function == 'install' and not application.can_be_installed( self.package_manager): MODULE.info('Application cannot be installed: %s' % application_id) can_continue = False elif function == 'update' and not application.can_be_updated(): MODULE.info('Application cannot be updated: %s' % application_id) can_continue = False if can_continue and function in ('install', 'update'): result = application.install_dry_run(self.package_manager, self.component_manager, remove_component=False) if result['broken'] or (result['remove'] and not force): MODULE.info('Remove component: %s' % application_id) self.component_manager.remove_app(application) self.package_manager.update() can_continue = False elif can_continue and function in ('uninstall', ) and not force: result['remove'] = application.uninstall_dry_run( self.package_manager) can_continue = False result['can_continue'] = can_continue self.finished(request.id, result) if can_continue: def _thread(module, application, function): with module.package_manager.locked(reset_status=True, set_finished=True): with module.package_manager.no_umc_restart(): if function in ('install', 'update'): # dont have to add component: already added during dry_run return application.install( module.package_manager, module.component_manager, add_component=False) else: return application.uninstall( module.package_manager, module.component_manager) def _finished(thread, result): if isinstance(result, BaseException): MODULE.warn('Exception during %s %s: %s' % (function, application_id, str(result))) thread = notifier.threads.Simple( 'invoke', notifier.Callback(_thread, self, application, function), _finished) thread.run() except LockError: # make it thread safe: another process started a package manager # this module instance already has a running package manager raise umcm.UMC_CommandError( _('Another package operation is in progress'))