本文整理汇总了Python中expect.Expect类的典型用法代码示例。如果您正苦于以下问题:Python Expect类的具体用法?Python Expect怎么用?Python Expect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:34,代码来源:maple.py
示例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
开发者ID:bgxcpku,项目名称:sagelib,代码行数:29,代码来源:gap.py
示例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);')
开发者ID:bgxcpku,项目名称:sagelib,代码行数:7,代码来源:kash.py
示例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
开发者ID:williamstein,项目名称:sagelib,代码行数:29,代码来源:axiom.py
示例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
开发者ID:pombredanne,项目名称:spd_notebook,代码行数:27,代码来源:gp.py
示例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)
开发者ID:sensen1,项目名称:sage,代码行数:32,代码来源:maxima.py
示例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
开发者ID:Findstat,项目名称:sage,代码行数:25,代码来源:scilab.py
示例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)
开发者ID:robertzk,项目名称:lmfdb,代码行数:9,代码来源:gp.py
示例9: _start
def _start(self):
"""
Starts Scilab and sets some options.
EXAMPLES:
sage: scilab._start() # optional - scilab
"""
Expect._start(self)
self.eval("mode(0)")
开发者ID:sageb0t,项目名称:testsage,代码行数:9,代码来源:scilab.py
示例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)
开发者ID:Etn40ff,项目名称:sage,代码行数:11,代码来源:genus2reduction.py
示例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)
开发者ID:CETHop,项目名称:sage,代码行数:12,代码来源:mathematica.py
示例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
开发者ID:pombredanne,项目名称:spd_notebook,代码行数:12,代码来源:lisp.py
示例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)
开发者ID:Babyll,项目名称:sage,代码行数:13,代码来源:matlab.py
示例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);')
开发者ID:BlairArchibald,项目名称:sage,代码行数:14,代码来源:gp.py
示例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
开发者ID:m000,项目名称:panda,代码行数:49,代码来源:run_guest.py
示例16: __init__
def __init__(self, options="", server=None,server_tmpdir=None):
"""
INPUT:
- ``options`` - string; passed when starting mwrank.
The format is::
-h help prints this info and quits
-q quiet turns OFF banner display and prompt
-v n verbosity sets verbosity to n (default=1)
-o PARI/GP output turns ON extra PARI/GP short output (default is OFF)
-p n precision sets precision to n decimals (default=15)
-b n quartic bound bound on quartic point search (default=10)
-x n n aux number of aux primes used for sieving (default=6)
-l list turns ON listing of points (default ON unless v=0)
-s selmer_only if set, computes Selmer rank only (default: not set)
-d skip_2nd_descent if set, skips the second descent for curves with 2-torsion (default: not set)
-S n sat_bd upper bound on saturation primes (default=100, -1 for automatic)
.. warning:
Do not use the option "-q" which turns off the prompt.
.. note::
Normally instances of this class would be created by
calling the global function :meth:`Mwrank`.
EXAMPLES::
sage: from sage.interfaces.mwrank import Mwrank_class
sage: M = Mwrank_class('-v 0 -l')
sage: M('0 -1 1 0 0')
'Curve [0,-1,1,0,0] :...Rank = 0...Regulator = 1...'
sage: from sage.interfaces.mwrank import Mwrank_class
sage: TestSuite(Mwrank_class).run()
"""
Expect.__init__(self,
name = 'mwrank',
prompt = 'Enter curve: ',
command = "mwrank %s"%options,
server = server,
server_tmpdir = server_tmpdir,
maxread = 10000,
restart_on_ctrlc = True,
verbose_start = False)
开发者ID:Findstat,项目名称:sage,代码行数:49,代码来源:mwrank.py
示例17: quit
def quit(self, verbose=False, timeout=0.25):
"""
EXAMPLES::
sage: a = gp('10'); a
10
sage: gp.quit()
sage: a
(invalid object -- defined in terms of closed session)
sage: gp(pi)
3.1415926535897932384626433832795028842 # 64-bit
3.141592653589793238462643383 # 32-bit
"""
self.__var_store_len = 0
Expect.quit(self, verbose=verbose, timeout=timeout)
开发者ID:pombredanne,项目名称:spd_notebook,代码行数:15,代码来源:gp.py
示例18: __init__
def __init__(self):
self.connect = Expect()
if self.connect.mode == 'ssh':
self.connect.ssh_login()
elif self.connect.mode == 'telnet':
self.connect.telnet_login()
self._data()
开发者ID:4v4t4r,项目名称:VMware,代码行数:7,代码来源:__init__.py
示例19: help
def help(self, s, pager=True):
"""
Print help on a given topic.
EXAMPLES::
sage: print gap.help('SymmetricGroup', pager=False)
Basic Groups _____________________________________________ Group Libraries
...
"""
tmp_to_use = self._local_tmpfile()
if self.is_remote():
tmp_to_use = self._remote_tmpfile()
else:
tmp_to_use = self._local_tmpfile()
self.eval('$SAGE.tempfile := "%s";'%tmp_to_use)
line = Expect.eval(self, "? %s"%s)
match = re.search("Page from (\d+)", line)
if match == None:
print line
else:
(sline,) = match.groups()
if self.is_remote():
self._get_tmpfile()
F = open(self._local_tmpfile(),"r")
if pager:
page(F.read(), start = int(sline)-1)
else:
return F.read()
开发者ID:bgxcpku,项目名称:sagelib,代码行数:29,代码来源:gap.py
示例20: _eval_line
def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if_needed=False):
"""
EXAMPLES::
sage: gp._eval_line('2+2')
'4'
TESTS:
We verify that trac 11617 is fixed::
sage: gp._eval_line('a='+str(range(2*10^5)))[:70]
'[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,'
"""
line = line.strip()
if len(line) == 0:
return ''
a = Expect._eval_line(self, line,
allow_use_file=allow_use_file,
wait_for_prompt=wait_for_prompt)
if a.find("the PARI stack overflows") != -1:
verbose("automatically doubling the PARI stack and re-executing current input line")
b = self.eval("allocatemem()")
if b.find("Warning: not enough memory") != -1:
raise RuntimeError(a)
return self._eval_line(line, allow_use_file=allow_use_file,
wait_for_prompt=wait_for_prompt)
else:
return a
开发者ID:anuragwaliya,项目名称:sage,代码行数:29,代码来源:gp.py
注:本文中的expect.Expect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论