← Back to team overview

savoirfairelinux-openerp team mailing list archive

[Merge] lp:~savoirfairelinux/openupgrade-server/better_migration_ipdb into lp:openupgrade-server

 

Sandy Carter (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux/openupgrade-server/better_migration_ipdb into lp:openupgrade-server.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~savoirfairelinux/openupgrade-server/better_migration_ipdb/+merge/231585

Back port of https://github.com/OpenUpgrade/OpenUpgrade/pull/50

Very useful if you use pdb or any sort of debugger
-- 
https://code.launchpad.net/~savoirfairelinux/openupgrade-server/better_migration_ipdb/+merge/231585
Your team Savoir Faire Linux is subscribed to branch lp:~savoirfairelinux/openupgrade-server/better_migration_ipdb.
=== modified file 'openerp/modules/migration.py'
--- openerp/modules/migration.py	2012-11-24 22:22:00 +0000
+++ openerp/modules/migration.py	2014-08-20 16:15:27 +0000
@@ -171,17 +171,16 @@
                     name, ext = os.path.splitext(os.path.basename(pyfile))
                     if ext.lower() != '.py':
                         continue
-                    mod = fp = fp2 = None
+                    # OpenUpgrade edit start:
+                    # Removed a copy of migration script to temp directory
+                    # Replaced call to load_source with load_module so frame isn't lost and breakpoints can be set
+                    mod = fp = None
                     try:
-                        fp = tools.file_open(pyfile)
-
-                        # imp.load_source need a real file object, so we create
-                        # one from the file-like object we get from file_open
-                        fp2 = os.tmpfile()
-                        fp2.write(fp.read())
-                        fp2.seek(0)
+                        fp, pathname = tools.file_open(pyfile, pathinfo=True)
                         try:
-                            mod = imp.load_source(name, pyfile, fp2)
+                            mod = imp.load_module(name, fp, pathname, ('.py', 'r', imp.PY_SOURCE))
+                            _logger.info('module %(addon)s: Running migration %(version)s %(name)s',
+                                         mergedict({'name': mod.__name__}, strfmt))
                         except ImportError:
                             _logger.error('module %(addon)s: Unable to load %(stage)s-migration file %(file)s' % mergedict({'file': pyfile}, strfmt))
                             raise
@@ -195,10 +194,9 @@
                     finally:
                         if fp:
                             fp.close()
-                        if fp2:
-                            fp2.close()
                         if mod:
                             del mod
+                    # OpenUpgrade edit end
 
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


Follow ups