def ipexec(fname, options=None, commands=()):
 if (options is None):
  options = []
 cmdargs = (default_argv() + options)
 test_dir = os.path.dirname(__file__)
 ipython_cmd = get_ipython_cmd()
 full_fname = os.path.join(test_dir, fname)
 full_cmd = ((ipython_cmd + cmdargs) + [full_fname])
 env = os.environ.copy()
 env['PYTHONWARNINGS'] = 'ignore'
 for (k, v) in env.items():
  if (not isinstance(v, str)):
   print (k, v)
 p = Popen(full_cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE, env=env)
 (out, err) = p.communicate(input=(py3compat.str_to_bytes('\n'.join(commands)) or None))
 (out, err) = (py3compat.bytes_to_str(out), py3compat.bytes_to_str(err))
 if out:
  out = re.sub('\\x1b\\[[^h]+h', '', out)
 return (out, err)

def ipexec ( fname , options = None , commands = ( ) ) : if ( options is None ) : options = [ ] cmdargs = ( default_argv ( ) + options ) test_dir = os . path . dirname ( __file__ ) ipython_cmd = get_ipython_cmd ( ) full_fname = os . path . join ( test_dir , fname ) full_cmd = ( ( ipython_cmd + cmdargs ) + [ full_fname ] ) env = os . environ . copy ( ) env [ 'PYTHONWARNINGS' ] = 'ignore' for ( k , v ) in env . items ( ) : if ( not isinstance ( v , str ) ) : print ( k , v ) p = Popen ( full_cmd , stdout = PIPE , stderr = PIPE , stdin = PIPE , env = env ) ( out , err ) = p . communicate ( input = ( py3compat . str_to_bytes ( '\n' . join ( commands ) ) or None ) ) ( out , err ) = ( py3compat . bytes_to_str ( out ) , py3compat . bytes_to_str ( err ) ) if out : out = re . sub ( '\\x1b\\[[^h]+h' , '' , out ) return ( out , err )
utility to call ipython filename .