odriverobotics / ODrive

High performance motor control
https://odriverobotics.com
MIT License
2.9k stars 1.51k forks source link

autocompletion breaks odrivetool #548

Closed mngr0 closed 3 years ago

mngr0 commented 3 years ago

I have Odrivetool just installed on a Linux debian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux

if I try to use autocompletion it prints a few \n and nothing more. after that if I press enter I get an error that ends in NameError: name 'sys' is not defined this does not happen if I do not press tab twice.

Thinking that it was an issue on my installation I clone the repo, and installed, same result.

mngr0 commented 3 years ago

here is the full stacktrace

marco@debian:~/ODrive/tools$ odrivetool ODrive control utility v0.5.1.post0 Website: https://odriverobotics.com/ Docs: https://docs.odriverobotics.com/ Forums: https://discourse.odriverobotics.com/ Discord: https://discord.gg/k3ZZ3mS Github: https://github.com/madcowswe/ODrive/

Please connect your ODrive. You can also type help() or quit().

Connected to ODrive 335B314E3536 as odrv0 In [1]: odvr0fdsf

TypeError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/IPython/terminal/ptutils.py in get_completions(self, document, complete_event) 112 try: --> 113 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer) 114 except Exception as e:

/usr/local/lib/python3.7/dist-packages/IPython/terminal/ptutils.py in _get_completions(body, offset, cursor_position, ipyc) 128 body, ipyc.completions(body, offset)) --> 129 for c in completions: 130 if not c.text:

/usr/local/lib/python3.7/dist-packages/IPython/core/completer.py in _deduplicate_completions(text, completions) 437 """ --> 438 completions = list(completions) 439 if not completions:

/usr/local/lib/python3.7/dist-packages/IPython/core/completer.py in completions(self, text, offset) 1817 try: -> 1818 for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000): 1819 if c and (c in seen):

/usr/local/lib/python3.7/dist-packages/IPython/core/completer.py in _completions(self, full_text, offset, _timeout) 1861 matched_text, matches, matches_origin, jedi_matches = self._complete( -> 1862 full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column) 1863

/usr/local/lib/python3.7/dist-packages/IPython/core/completer.py in _complete(self, cursor_line, cursor_pos, line_buffer, text, full_text) 2029 completions = self._jedi_matches( -> 2030 cursor_pos, cursor_line, full_text) 2031

/usr/local/lib/python3.7/dist-packages/IPython/core/completer.py in _jedi_matches(self, cursor_column, cursor_line, text) 1373 interpreter = jedi.Interpreter( -> 1374 text[:offset], namespaces, column=cursor_column, line=cursor_line + 1) 1375 try_jedi = True

/usr/local/lib/python3.7/dist-packages/jedi/api/init.py in init(self, code, namespaces, kwds) 725 super().init(code, environment=environment, --> 726 project=Project(Path.cwd()), kwds) 727 self.namespaces = namespaces

TypeError: init() got an unexpected keyword argument 'column'

During handling of the above exception, another exception occurred:

NameError Traceback (most recent call last) /usr/local/bin/odrivetool in 136 print("") 137 import odrive.shell --> 138 odrive.shell.launch_shell(args, logger, app_shutdown_token) 139 140 elif args.command == 'dfu':

~/.local/lib/python3.7/site-packages/odrive/shell.py in launch_shell(args, logger, app_shutdown_token) 99 print_banner, print_help, 100 logger, app_shutdown_token, --> 101 branding_short="odrv", branding_long="ODrive")

~/.local/lib/python3.7/site-packages/fibre/shell.py in launch_shell(args, interactive_variables, print_banner, print_help, logger, app_shutdown_token, branding_short, branding_long) 125 print_banner() 126 logger._skip_bottom_line = True --> 127 interact() 128 app_shutdown_token.set()

/usr/local/lib/python3.7/dist-packages/IPython/terminal/embed.py in call(self, header, local_ns, module, dummy, stack_depth, global_ns, compile_flags, **kw) 227 # our call and get the original caller's namespaces. 228 self.mainloop(local_ns, module, stack_depth=stack_depth, --> 229 global_ns=global_ns, compile_flags=compile_flags) 230 231 self.banner2 = self.old_banner2

/usr/local/lib/python3.7/dist-packages/IPython/terminal/embed.py in mainloop(self, local_ns, module, stack_depth, display_banner, global_ns, compile_flags) 322 323 with self.builtin_trap, self.display_trap: --> 324 self.interact() 325 326 # now, purge out the local namespace of IPython's hidden variables.

/usr/local/lib/python3.7/dist-packages/IPython/terminal/interactiveshell.py in interact(self, display_banner) 545 546 try: --> 547 code = self.prompt_for_code() 548 except EOFError: 549 if (not self.confirm_exit) \

/usr/local/lib/python3.7/dist-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self) 473 text = self.pt_app.prompt( 474 default=default, --> 475 **self._extra_prompt_options()) 476 finally: 477 # Restore the original event loop.

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/shortcuts/prompt.py in prompt(self, message, editing_mode, refresh_interval, vi_mode, lexer, completer, complete_in_thread, is_password, key_bindings, bottom_toolbar, style, color_depth, include_default_pygments_style, style_transformation, swap_light_and_dark_colors, rprompt, multiline, prompt_continuation, wrap_lines, enable_history_search, search_ignore_case, complete_while_typing, validate_while_typing, complete_style, auto_suggest, validator, clipboard, mouse_support, input_processors, placeholder, reserve_space_for_menu, enable_system_prompt, enable_suspend, enable_open_in_editor, tempfile_suffix, tempfile, default, accept_default, pre_run, set_exception_handler) 1011 return get_event_loop().run_until_complete(self._dumb_prompt(self.message)) 1012 -> 1013 return self.app.run(set_exception_handler=set_exception_handler) 1014 1015 async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/application/application.py in run(self, pre_run, set_exception_handler) 815 816 return loop.run_until_complete( --> 817 self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler) 818 ) 819

/usr/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future) 582 raise RuntimeError('Event loop stopped before Future completed.') 583 --> 584 return future.result() 585 586 def stop(self):

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/application/application.py in run_async(self, pre_run, set_exception_handler) 781 loop.set_exception_handler(previous_exc_handler) 782 --> 783 return await _run_async2() 784 785 def run(

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/application/application.py in _run_async2() 769 # KeyboardInterrupt, we still want to wait for the 770 # background tasks. --> 771 await self.cancel_and_wait_for_background_tasks() 772 773 # Set the _is_running flag to False. Normally this

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/application/application.py in cancel_and_wait_for_background_tasks(self) 870 for task in self.background_tasks: 871 try: --> 872 await task 873 except CancelledError: 874 pass

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/buffer.py in new_coroutine(*a, *kw) 1852 while True: 1853 try: -> 1854 await coroutine(a, **kw) 1855 except _Retry: 1856 continue

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/buffer.py in async_completer(select_first, select_last, insert_common_part, complete_event) 1682 1683 async for completion in self.completer.get_completions_async( -> 1684 document, complete_event 1685 ): 1686 complete_state.completions.append(completion)

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/completion/base.py in get_completions_async(self, document, complete_event) 268 269 async for completion in completer.get_completions_async( --> 270 document, complete_event 271 ): 272 yield completion

/usr/local/lib/python3.7/dist-packages/prompt_toolkit/completion/base.py in get_completions_async(self, document, complete_event) 194 Asynchronous generator of :class:.Completion objects. 195 """ --> 196 for item in self.get_completions(document, complete_event): 197 yield item

/usr/local/lib/python3.7/dist-packages/IPython/terminal/ptutils.py in get_completions(self, document, complete_event) 114 except Exception as e: 115 try: --> 116 exc_type, exc_value, exc_tb = sys.exc_info() 117 traceback.print_exception(exc_type, exc_value, exc_tb) 118 except AttributeError:

NameError: name 'sys' is not defined

samuelsadok commented 3 years ago

The stack trace looks as far as I can tell identical to https://github.com/ipython/ipython/issues/12745. It seems that the proposed workaround is this: https://github.com/ipython/ipython/issues/12745#issuecomment-751892538

mngr0 commented 3 years ago

Thank you very much, I hope that this issue will be helpful for someone else in the future