本文整理汇总了Python中expect.Expect类的典型用法代码示例。如果您正苦于以下问题:Python Expect类的具体用法?Python Expect怎么用?Python Expect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, maxread=None, script_subdirectory=None, server=None,
server_tmpdir=None, logfile=None, ulimit=None):
"""
Create an instance of the Maple interpreter.
EXAMPLES::
sage: maple == loads(dumps(maple))
True
"""
__maple_iface_opts = [
'screenwidth=infinity',
'errorcursor=false',]
__maple_command = 'maple -t -c "interface({})"'.format(
','.join(__maple_iface_opts))
#errorcursor=false avoids maple command line interface to dump
#into the editor when an error occurs. Thus pexpect interface
#is not messed up if a maple error occurs.
#screenwidth=infinity prevents maple command interface from cutting
#your input lines. By doing this, file interface also works in the
#event that sage_user_home + sage_tmp_file_stuff exceeds the
#length of 79 characters.
Expect.__init__(self,
name = 'maple',
prompt = '#-->',
command = __maple_command,
server = server,
server_tmpdir = server_tmpdir,
ulimit = ulimit,
script_subdirectory = script_subdirectory,
restart_on_ctrlc = False,
verbose_start = False,
logfile = logfile,
eval_using_file_cutoff=2048) # 2048 is
示例2: _start
def _start(self):
"""
EXAMPLES::
sage: g = Gap()
sage: g.is_running()
False
sage: g._start()
sage: g.is_running()
True
sage: g.quit()
"""
if self.__use_workspace_cache and not os.path.exists(WORKSPACE):
gap_reset_workspace()
global first_try
n = self._session_number
try:
Expect._start(self, "Failed to start GAP.")
except Exception, msg:
if self.__use_workspace_cache and first_try:
print "A workspace appears to have been corrupted... automatically rebuilding (this is harmless)."
first_try = False
self._expect = None
expect.failed_to_start.remove(self.name())
gap_reset_workspace(verbose=False)
Expect._start(self, "Failed to start GAP.")
self._session_number = n
return
raise RuntimeError, msg
示例3: _start
def _start(self):
try:
Expect._start(self)
except RuntimeError:
raise RuntimeError, "You must install the optional Kash package to use Kash from Sage."
# Turn off the annoying timer.
self.eval('Time(false);')
示例4: __init__
def __init__(self, name='axiom', command='axiom -nox -noclef',
script_subdirectory=None, logfile=None,
server=None, server_tmpdir=None,
init_code=[')lisp (si::readline-off)']):
"""
Create an instance of the Axiom interpreter.
TESTS::
sage: axiom == loads(dumps(axiom))
True
"""
eval_using_file_cutoff = 200
self.__eval_using_file_cutoff = eval_using_file_cutoff
self._COMMANDS_CACHE = '%s/%s_commandlist_cache.sobj'%(DOT_SAGE, name)
Expect.__init__(self,
name = name,
prompt = '\([0-9]+\) -> ',
command = command,
maxread = 10,
script_subdirectory = script_subdirectory,
server=server,
server_tmpdir=server_tmpdir,
restart_on_ctrlc = False,
verbose_start = False,
init_code = init_code,
logfile = logfile,
eval_using_file_cutoff=eval_using_file_cutoff)
self._prompt_wait = self._prompt
示例5: __init__
def __init__(self, stacksize=10000000, # 10MB
maxread=100000, script_subdirectory=None,
logfile=None,
server=None,
server_tmpdir=None,
init_list_length=1024):
"""
EXAMPLES::
sage: gp == loads(dumps(gp))
True
"""
Expect.__init__(self,
name = 'pari',
prompt = '\\? ',
command = "gp --emacs --fast --quiet --stacksize %s"%stacksize,
maxread = maxread,
server=server,
server_tmpdir=server_tmpdir,
script_subdirectory = script_subdirectory,
restart_on_ctrlc = False,
verbose_start = False,
logfile=logfile,
eval_using_file_cutoff=50)
self.__seq = 0
self.__var_store_len = 0
self.__init_list_length = init_list_length
示例6: _start
def _start(self):
"""
Starts the Maxima interpreter.
EXAMPLES::
sage: m = Maxima()
sage: m.is_running()
False
sage: m._start()
sage: m.is_running()
True
Test that we can use more than 256MB RAM (see :trac:`6772`)::
sage: a = maxima(10)^(10^5)
sage: b = a^600 # long time -- about 10-15 seconds
"""
Expect._start(self)
self._sendline(r":lisp (defun tex-derivative (x l r) (tex (if $derivabbrev (tex-dabbrev x) (tex-d x '\\partial)) l r lop rop ))")
# Don't use ! for factorials (#11539)
self._sendline(":lisp (remprop 'mfactorial 'grind)")
# Remove limit on the max heapsize (since otherwise it defaults
# to 256MB with ECL).
self._sendline(":lisp (ext:set-limit 'ext:heap-size 0)")
self._eval_line('0;')
# set random seed
self.set_seed(self._seed)
示例7: __init__
def __init__(self, maxread=100, script_subdirectory=None,
logfile=None, server=None,server_tmpdir=None,
seed=None):
"""
Initializes the Scilab class.
EXAMPLES::
sage: from sage.interfaces.scilab import Scilab
sage: sci_obj = Scilab()
sage: del sci_obj
"""
Expect.__init__(self,
name = 'scilab',
prompt = '-->',
command = "scilab -nw",
maxread = maxread,
server = server,
server_tmpdir = server_tmpdir,
script_subdirectory = script_subdirectory,
restart_on_ctrlc = False,
verbose_start = False,
logfile = logfile,
eval_using_file_cutoff=100)
self._seed = seed
示例8: _start
def _start(self, alt_message=None, block_during_init=True):
r"""
Restart the underlying process.
.. note:: This is handled by the Expect class, except that we
need to reset the breakloop configuration parameter.
"""
Expect._start(self, alt_message=alt_message, block_during_init=block_during_init)
self.set_default('breakloop',0)
示例9: _start
def _start(self):
"""
Starts Scilab and sets some options.
EXAMPLES:
sage: scilab._start() # optional - scilab
"""
Expect._start(self)
self.eval("mode(0)")
示例10: __init__
def __init__(self, server=None, server_tmpdir=None, logfile=None):
Expect.__init__(self,
name = 'genus2reduction',
prompt = 'enter',
command = 'genus2reduction',
server = server,
server_tmpdir = server_tmpdir,
maxread = 10000,
restart_on_ctrlc = True,
logfile = logfile,
verbose_start = False)
示例11: __init__
def __init__(self, maxread=100, script_subdirectory="", logfile=None, server=None, server_tmpdir=None):
Expect.__init__(self,
name = 'mathematica',
prompt = 'In[[0-9]+]:=',
command = "math",
maxread = maxread,
server = server,
server_tmpdir = server_tmpdir,
script_subdirectory = script_subdirectory,
verbose_start = False,
logfile=logfile,
eval_using_file_cutoff=50)
示例12: _start
def _start(self, *args, **kwds):
"""
EXAMPLES:
sage: l = Lisp()
sage: l.is_running()
False
sage: l._start()
sage: l.is_running()
True
"""
Expect._start(self, *args, **kwds)
self.__in_seq = 1
示例13: __init__
def __init__(self, maxread=None, script_subdirectory=None,
logfile=None, server=None,server_tmpdir=None):
Expect.__init__(self,
name = 'matlab',
prompt = '>> ',
command = "sage-native-execute matlab -nodisplay",
server = server,
server_tmpdir = server_tmpdir,
script_subdirectory = script_subdirectory,
restart_on_ctrlc = False,
verbose_start = False,
logfile = logfile,
eval_using_file_cutoff=100)
示例14: _start
def _start(self, alt_message=None, block_during_init=True):
Expect._start(self, alt_message, block_during_init)
# disable timer
self._eval_line('default(timer,0);')
# disable the break loop, otherwise gp will seem to hang on errors
self._eval_line('default(breakloop,0);')
# list of directories where gp will look for scripts (only current working directory)
self._eval_line('default(path,".");')
# location of elldata, seadata, galdata
self._eval_line('default(datadir, "$SAGE_LOCAL/share/pari");')
# executable for gp ?? help
self._eval_line('default(help, "$SAGE_LOCAL/bin/gphelp -detex");')
# logfile disabled since Expect already logs
self._eval_line('default(log,0);')
示例15: __enter__
def __enter__(self):
monitor_path = join(self.tempdir, 'monitor')
if not self.boot:
serial_path = join(self.tempdir, 'serial')
qemu_args = [self.qemu_path, self.qcow]
# if not self.boot:
#
qemu_args.extend(['-monitor', 'unix:{},server,nowait'.format(monitor_path)])
if self.boot:
qemu_args.append('-S')
else:
qemu_args.extend(['-serial', 'unix:{},server,nowait'.format(serial_path),
'-loadvm', self.snapshot])
qemu_args.extend(['-display', 'none'])
qemu_args.extend(self.extra_args)
if self.rr: qemu_args = ['rr', 'record'] + qemu_args
if self.perf: qemu_args = ['perf', 'record'] + qemu_args
progress("Running qemu with args:")
print subprocess32.list2cmdline(qemu_args)
self.qemu = subprocess32.Popen(qemu_args) # , stdout=DEVNULL, stderr=DEVNULL)
while not os.path.exists(monitor_path):
time.sleep(0.1)
if not self.boot:
while not os.path.exists(serial_path):
time.sleep(0.1)
# while not all([os.path.exists(p) for p in [monitor_path, serial_path]]):
# time.sleep(0.1)
self.monitor_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.monitor_socket.connect(monitor_path)
self.monitor = Expect(self.monitor_socket)
if not self.boot:
self.serial_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.serial_socket.connect(serial_path)
self.console = Expect(self.serial_socket)
# Make sure monitor/console are in right state.
self.monitor.expect("(qemu)")
print
if not self.boot:
self.console.sendline()
self.console.expect(self.expect_prompt)
print
print
return self