Ejemplo n.º 1
0
    def send(self, cr, uid, tb, explanations, remarks=None):
        status = self.status(cr, uid)
        if status['status'] != 'full':
            raise osv.except_osv(_('Error'), _("Your can't submit bug reports due to uncovered modules: %s") % (', '.join(status['uncovered_modules']),))
        
        dbmsg = _('This error occurs on database %s') % (cr.dbname,)
        if not remarks:
            remarks = dbmsg
        else:
            remarks += '\n\n-----\n' + dbmsg

        valid_contracts = self._get_valid_contracts(cr, uid)

        crm_case_id = None
        rc = None
        try:
            for contract in valid_contracts: 
                rc = tm.remote_contract(contract.name, contract.password)
                if rc.id:
                    break
                rc = None
        
            if not rc:
                raise osv.except_osv(_('Error'), _('Unable to find a valid contract'))
            
            origin = 'client'
            crm_case_id = rc.submit(rc.id, tb, explanations, remarks or '', origin)

        except tm.RemoteContractException, rce:
            netsvc.Logger().notifyChannel('maintenance', netsvc.LOG_INFO, rce)
Ejemplo n.º 2
0
    def send(self, cr, uid, tb, explanations, remarks=None):
        status = self.status(cr, uid)
        if status['status'] != 'full':
            raise osv.except_osv(
                _('Error'),
                _("Your can't submit bug reports due to uncovered modules: %s")
                % (', '.join(status['uncovered_modules']), ))

        dbmsg = _('This error occurs on database %s') % (cr.dbname, )
        if not remarks:
            remarks = dbmsg
        else:
            remarks += '\n\n-----\n' + dbmsg

        valid_contracts = self._get_valid_contracts(cr, uid)

        crm_case_id = None
        rc = None
        try:
            for contract in valid_contracts:
                rc = tm.remote_contract(contract.name, contract.password)
                if rc.id:
                    break
                rc = None

            if not rc:
                raise osv.except_osv(_('Error'),
                                     _('Unable to find a valid contract'))

            origin = 'client'
            crm_case_id = rc.submit(rc.id, tb, explanations, remarks or '',
                                    origin)

        except tm.RemoteContractException, rce:
            netsvc.Logger().notifyChannel('maintenance', netsvc.LOG_INFO, rce)
Ejemplo n.º 3
0
    def exp_get_available_updates(self, contract_id, contract_password):
        import tools.maintenance as tm
        try:
            rc = tm.remote_contract(contract_id, contract_password)
            if not rc.id:
                raise tm.RemoteContractException('This contract does not exist or is not active')

            return rc.get_available_updates(rc.id, addons.get_modules_with_version())

        except tm.RemoteContractException, e:
            self.abortResponse(1, 'Migration Error', 'warning', str(e))
Ejemplo n.º 4
0
    def exp_get_available_updates(self, contract_id, contract_password):
        import tools.maintenance as tm
        try:
            rc = tm.remote_contract(contract_id, contract_password)
            if not rc.id:
                raise tm.RemoteContractException('This contract does not exist or is not active')

            return rc.get_available_updates(rc.id, addons.get_modules_with_version())

        except tm.RemoteContractException, e:
            self.abortResponse(1, 'Migration Error', 'warning', str(e))
Ejemplo n.º 5
0
    def action_validate(self, cr, uid, ids, context=None):
        if not ids:
            return False

        module_proxy = self.pool.get('ir.module.module')
        module_ids = module_proxy.search(cr, uid, [('state', '=', 'installed')])
        modules = module_proxy.read(cr, uid, module_ids, ['name', 'installed_version'])

        contract = self.read(cr, uid, ids, ['name', 'password'])[0]
        
        try:
            contract_info = tm.remote_contract(contract['name'], contract['password'], modules)
        except tm.RemoteContractException, rce:
            raise osv.except_osv(_('Error'), ustr(rce))
Ejemplo n.º 6
0
    def action_validate(self, cr, uid, ids, context=None):
        if not ids:
            return False

        module_proxy = self.pool.get('ir.module.module')
        module_ids = module_proxy.search(cr, uid,
                                         [('state', '=', 'installed')])
        modules = module_proxy.read(cr, uid, module_ids,
                                    ['name', 'installed_version'])

        contract = self.read(cr, uid, ids, ['name', 'password'])[0]

        try:
            contract_info = tm.remote_contract(contract['name'],
                                               contract['password'], modules)
        except tm.RemoteContractException, rce:
            raise osv.except_osv(_('Error'), ustr(rce))
Ejemplo n.º 7
0
    def exp_get_migration_scripts(self, contract_id, contract_password):
        l = netsvc.Logger()
        import tools.maintenance as tm
        try:
            rc = tm.remote_contract(contract_id, contract_password)
            if not rc.id:
                raise tm.RemoteContractException('This contract does not exist or is not active')
            if rc.status != 'full':
                raise tm.RemoteContractException('Can not get updates for a partial contract')

            l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))

            zips = rc.retrieve_updates(rc.id, addons.get_modules_with_version())

            from shutil import rmtree, copytree, copy

            backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
            if zips and not os.path.isdir(backup_directory):
                l.notifyChannel('migration', netsvc.LOG_INFO, 'create a new backup directory to \
                                store the old modules: %s' % (backup_directory,))
                os.makedirs(backup_directory)

            for module in zips:
                l.notifyChannel('migration', netsvc.LOG_INFO, 'upgrade module %s' % (module,))
                mp = addons.get_module_path(module)
                if mp:
                    if os.path.isdir(mp):
                        copytree(mp, os.path.join(backup_directory, module))
                        if os.path.islink(mp):
                            os.unlink(mp)
                        else:
                            rmtree(mp)
                    else:
                        copy(mp + 'zip', backup_directory)
                        os.unlink(mp + '.zip')

                try:
                    try:
                        base64_decoded = base64.decodestring(zips[module])
                    except Exception:
                        l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to read the module %s' % (module,))
                        raise

                    zip_contents = StringIO(base64_decoded)
                    zip_contents.seek(0)
                    try:
                        try:
                            tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
                        except Exception:
                            l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to extract the module %s' % (module, ))
                            rmtree(module)
                            raise
                    finally:
                        zip_contents.close()
                except Exception:
                    l.notifyChannel('migration', netsvc.LOG_ERROR, 'restore the previous version of the module %s' % (module, ))
                    nmp = os.path.join(backup_directory, module)
                    if os.path.isdir(nmp):
                        copytree(nmp, tools.config['addons_path'])
                    else:
                        copy(nmp+'.zip', tools.config['addons_path'])
                    raise

            return True
        except tm.RemoteContractException, e:
            self.abortResponse(1, 'Migration Error', 'warning', str(e))
Ejemplo n.º 8
0
    def exp_get_migration_scripts(self, contract_id, contract_password):
        l = netsvc.Logger()
        import tools.maintenance as tm
        try:
            rc = tm.remote_contract(contract_id, contract_password)
            if not rc.id:
                raise tm.RemoteContractException('This contract does not exist or is not active')
            if rc.status != 'full':
                raise tm.RemoteContractException('Can not get updates for a partial contract')

            l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))

            zips = rc.retrieve_updates(rc.id, addons.get_modules_with_version())

            from shutil import rmtree, copytree, copy

            backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
            if zips and not os.path.isdir(backup_directory):
                l.notifyChannel('migration', netsvc.LOG_INFO, 'create a new backup directory to \
                                store the old modules: %s' % (backup_directory,))
                os.makedirs(backup_directory)

            for module in zips:
                l.notifyChannel('migration', netsvc.LOG_INFO, 'upgrade module %s' % (module,))
                mp = addons.get_module_path(module)
                if mp:
                    if os.path.isdir(mp):
                        copytree(mp, os.path.join(backup_directory, module))
                        if os.path.islink(mp):
                            os.unlink(mp)
                        else:
                            rmtree(mp)
                    else:
                        copy(mp + 'zip', backup_directory)
                        os.unlink(mp + '.zip')

                try:
                    try:
                        base64_decoded = base64.decodestring(zips[module])
                    except:
                        l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to read the module %s' % (module,))
                        raise

                    zip_contents = StringIO(base64_decoded)
                    zip_contents.seek(0)
                    try:
                        try:
                            tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
                        except:
                            l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to extract the module %s' % (module, ))
                            rmtree(module)
                            raise
                    finally:
                        zip_contents.close()
                except:
                    l.notifyChannel('migration', netsvc.LOG_ERROR, 'restore the previous version of the module %s' % (module, ))
                    nmp = os.path.join(backup_directory, module)
                    if os.path.isdir(nmp):
                        copytree(nmp, tools.config['addons_path'])
                    else:
                        copy(nmp+'.zip', tools.config['addons_path'])
                    raise

            return True
        except tm.RemoteContractException, e:
            self.abortResponse(1, 'Migration Error', 'warning', str(e))