Perhaps an easier way to debug this is to use the fact that the global
maple object is defined in the Sage library by the assignment maple=Maple()
(in sage/interfaces/maple.py) and if at the top of your Sage session you do
maple = Maple(logfile="maple.log")
then you can take a look in that file to see all the communication between
Sage via pexpect and maple.

John

On Wed, 6 Mar 2019 at 16:42, E. Madison Bray <[email protected]> wrote:

>
>
> On Wednesday, March 6, 2019 at 5:31:19 PM UTC+1, E. Madison Bray wrote:
>>
>> On Tuesday, March 5, 2019 at 4:47:39 PM UTC+1, benyamin alizade wrote:
>>>
>>> It gives no result, and when I interrupt it, the following error appears:
>>>
>>>
>>> ---------------------------------------------------------------------------
>>> EOF                                       Traceback (most recent call
>>> last)
>>> <ipython-input-2-8f0455f97669> in <module>()
>>> ----> 1 maple('2*3')
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc
>>> in __call__(self, x, name)
>>>     278
>>>     279         if isinstance(x, string_types):
>>> --> 280             return cls(self, x, name=name)
>>>     281         try:
>>>     282             return self._coerce_from_special_method(x)
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
>>> in __init__(self, parent, value, is_name, name)
>>>    1436         else:
>>>    1437             try:
>>> -> 1438                 self._name = parent._create(value, name=name)
>>>    1439             # Convert ValueError and RuntimeError to TypeError
>>> for
>>>    1440             # coercion to work properly.
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc
>>> in _create(self, value, name)
>>>     474     def _create(self, value, name=None):
>>>     475         name = self._next_var_name() if name is None else name
>>> --> 476         self.set(name, value)
>>>     477         return name
>>>     478
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/maple.pyc
>>> in set(self, var, value)
>>>     622         """
>>>     623         cmd = '%s:=%s:' % (var, value)
>>> --> 624         out = self.eval(cmd)
>>>     625         if out.find("error") != -1:
>>>     626             raise TypeError("Error executing code in
>>> Maple\nCODE:\n\t%s\nMaple ERROR:\n\t%s" % (cmd, out))
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
>>> in eval(self, code, strip, synchronize, locals, allow_use_file,
>>> split_lines, **kwds)
>>>    1350                 elif split_lines:
>>>    1351                     return '\n'.join([self._eval_line(L,
>>> allow_use_file=allow_use_file, **kwds)
>>> -> 1352                                         for L in
>>> code.split('\n') if L != ''])
>>>    1353                 else:
>>>    1354                     return self._eval_line(code,
>>> allow_use_file=allow_use_file, **kwds)
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/maple.pyc
>>> in _eval_line(self, line, allow_use_file, wait_for_prompt,
>>> restart_if_needed)
>>>     574         with gc_disabled():
>>>     575             z = Expect._eval_line(self, line,
>>> allow_use_file=allow_use_file,
>>> --> 576
>>>  wait_for_prompt=wait_for_prompt).replace('\\\n','').strip()
>>>     577             if z.lower().find("error") != -1:
>>>     578                 raise RuntimeError("An error occurred running a
>>> Maple command:\nINPUT:\n%s\nOUTPUT:\n%s" % (line, z))
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
>>> in _eval_line(self, line, allow_use_file, wait_for_prompt,
>>> restart_if_needed)
>>>     982                     out = ''
>>>     983         except KeyboardInterrupt:
>>> --> 984             self._keyboard_interrupt()
>>>     985             raise KeyboardInterrupt("Ctrl-c pressed while
>>> running %s"%self)
>>>     986         if self._terminal_echo:
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/sage/interfaces/maple.pyc
>>> in _keyboard_interrupt(self)
>>>     333         print("Interrupting %s..." % self)
>>>     334         self._expect.sendline(chr(3))  # send ctrl-c
>>> --> 335         self._expect.expect(self._prompt)
>>>     336         raise RuntimeError("Ctrl-c pressed while running %s" %
>>> self)
>>>     337
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/pexpect/spawnbase.pyc
>>> in expect(self, pattern, timeout, searchwindowsize, async_, **kw)
>>>     339         compiled_pattern_list =
>>> self.compile_pattern_list(pattern)
>>>     340         return self.expect_list(compiled_pattern_list,
>>> --> 341                 timeout, searchwindowsize, async_)
>>>     342
>>>     343     def expect_list(self, pattern_list, timeout=-1,
>>> searchwindowsize=-1,
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/pexpect/spawnbase.pyc
>>> in expect_list(self, pattern_list, timeout, searchwindowsize, async_, **kw)
>>>     367             return expect_async(exp, timeout)
>>>     368         else:
>>> --> 369             return exp.expect_loop(timeout)
>>>     370
>>>     371     def expect_exact(self, pattern_list, timeout=-1,
>>> searchwindowsize=-1,
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/pexpect/expect.pyc
>>> in expect_loop(self, timeout)
>>>     115                     timeout = end_time - time.time()
>>>     116         except EOF as e:
>>> --> 117             return self.eof(e)
>>>     118         except TIMEOUT as e:
>>>     119             return self.timeout(e)
>>>
>>> /opt/sagemath-8.5/local/lib/python2.7/site-packages/pexpect/expect.pyc
>>> in eof(self, err)
>>>      61             if err is not None:
>>>      62                 msg = str(err) + '\n' + msg
>>> ---> 63             raise EOF(msg)
>>>      64
>>>      65     def timeout(self, err=None):
>>>
>>> EOF: End Of File (EOF). Exception style platform.
>>> Maple with PID 5472 running /cygdrive/c/Program Files (x86)/Maple
>>> 17/bin.win/maple -t -c interface(screenwidth=infinity,errorcursor=false)
>>> command: /cygdrive/c/Program Files (x86)/Maple 17/bin.win/maple
>>> args: ['/cygdrive/c/Program Files (x86)/Maple 17/bin.win/maple', '-t',
>>> '-c', 'interface(screenwidth=infinity,errorcursor=false)']
>>> buffer (last 100 chars): ''
>>> before (last 100 chars): '\r\n'
>>> after: <class 'pexpect.exceptions.EOF'>
>>> match: None
>>> match_index: None
>>> exitstatus: None
>>> flag_eof: True
>>> pid: 5472
>>> child_fd: 10
>>> closed: False
>>> timeout: None
>>> delimiter: <class 'pexpect.exceptions.EOF'>
>>> logfile: None
>>> logfile_read: None
>>> logfile_send: None
>>> maxread: 4194304
>>> ignorecase: False
>>> searchwindowsize: None
>>> delaybeforesend: None
>>> delayafterclose: 0.1
>>> delayafterterminate: 0.1
>>> searcher: searcher_re:
>>>     0: re.compile('#-->')
>>>
>>>>
>>>>
>> It looks to me like pexpect is just waiting forever for a prompt and not
>> receiving one.  The best thing to do I think would be to run it more
>> directly and see what it's outputting.  Perhaps even it's something as
>> simple as, the prompt is something other than "#-->".  So pexpect will just
>> sit there until something resembling the "#-->" appears on its stdin
>> stream.
>>
>
> I almost forgot the most important point!  If you want to interact "more
> directly" what I wrote above, you can use the `ptyprocess` module directly,
> which is what pexpect (and by extension Sage's interface to maple) is
> using.  For example to start process with a PTY from Python/sage:
>
>     sage: import ptyprocess
>     sage: p = ptyprocess.PtyProcess.spawn(['/cygdrive/c/Program Files
> (x86)/Maple 17/bin.win/maple', '-t', '-c',
> 'interface(screenwidth=infinity,errorcursor=false)'])
>
>
> then to see the process's output:
>
>     sage: p.read()
>     <something>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to