332 msg = 'ignoring %s, not a valid script extension (%s)' |
332 msg = 'ignoring %s, not a valid script extension (%s)' |
333 raise ExecutionError(msg % (migrscript, ftypes)) |
333 raise ExecutionError(msg % (migrscript, ftypes)) |
334 if not self.execscript_confirm(migrscript): |
334 if not self.execscript_confirm(migrscript): |
335 return |
335 return |
336 scriptlocals = self._create_context().copy() |
336 scriptlocals = self._create_context().copy() |
|
337 scriptlocals.update({'__file__': migrscript, |
|
338 '__args__': kwargs.pop("scriptargs", [])}) |
337 self._context_stack.append(scriptlocals) |
339 self._context_stack.append(scriptlocals) |
338 if script_mode == 'python': |
340 if script_mode == 'python': |
339 if funcname is None: |
341 if funcname is None: |
340 pyname = '__main__' |
342 pyname = '__main__' |
341 else: |
343 else: |
342 pyname = splitext(basename(migrscript))[0] |
344 pyname = splitext(basename(migrscript))[0] |
343 scriptlocals.update({'__file__': migrscript, '__name__': pyname, |
345 scriptlocals['__name__'] = pyname |
344 '__args__': kwargs.pop("scriptargs", [])}) |
|
345 execfile(migrscript, scriptlocals) |
346 execfile(migrscript, scriptlocals) |
346 if funcname is not None: |
347 if funcname is not None: |
347 try: |
348 try: |
348 func = scriptlocals[funcname] |
349 func = scriptlocals[funcname] |
349 self.info('found %s in locals', funcname) |
350 self.info('found %s in locals', funcname) |