Ask Your Question
2

Running a script as sudo from Wing IDE

asked 2019-01-05 12:08:00 -0500

GeertVc's avatar

updated 2022-05-05 09:32:00 -0500

Hi, I have Python code that uses the bluetooth module.  One of the bluetooth calls I'm doing needs sudo permission (advertise_service()).

When running the script on the command line on a RPi, I simply do this: sudo python3 <name_of_script>.  That works perfect.

However, if I want to debug that script from within Wing IDE (remotely), how can I start the debug session of that script as sudo?

Best,

--Geert

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2019-01-05 17:08:00 -0500

updated 2019-03-06 22:25:07 -0500

Wingware Admin's avatar

One way would be to use wingdbstub to initiate debug as described in http://wingware.com/doc/debug/debuggi...

Another way would be to initiate debug with wingdb as described in http://wingware.com/doc/debug/wingdb (this method doesn't require adding an import to your code).  You would add sudo before wingdb.Neither of these starts the debug process from within Wing, but you could set up an OS Command to start the process in combination with one of the above methods.

It would also be possible to set up a script that invokes sudo python and passes in all args and set that as Python Executable in Wing, but this would only work if sudo doesn't require typing in a password.

edit flag offensive delete link more
0

answered 2022-04-09 08:24:24 -0500

piscvau's avatar

updated 2022-04-09 11:21:11 -0500

I am using the second method to debug a python script to be ran as sudo . This does not seem to allow parparse to parse arguments. I get the following message

(myvenv) odile@odile-GE72-2QC:~/Documents/dev_logiciels$ /usr/lib/wingpro8/wingdb django_clone.py gitbidon https://gitlab.com/skirando/family-recipes  dev
Creating meta importer for domain dbg
winghome=/usr/lib/wingpro8
Created meta importer
Adding code directory to merge importer: /usr/lib/wingpro8/bin/dbg/src
Adding code directory to merge importer: /usr/lib/wingpro8/src
Trying to import netserver from ['/usr/lib/wingpro8/bootstrap', '/usr/lib/wingpro8/bootstrap/__pycache__', '/usr/lib/wingpro8/bin/dbg/src', '/usr/lib/wingpro8/bin/dbg/src/debug', '/usr/lib/wingpro8/bin/dbg/src/debug/tserver', '/usr/lib/wingpro8/bin/dbg/src/debug/tserver/__os__', '/usr/lib/wingpro8/bin/dbg/src/debug/tserver/__os__/osx', '/usr/lib/wingpro8/bin/dbg/src/debug/tserver/__os__/win32', '/usr/lib/wingpro8/bin/dbg/src/__pycache__', '/usr/lib/wingpro8/bin/dbg/src/wingbase', '/usr/lib/wingpro8/bin/dbg/src/wingbase/pexpect', '/usr/lib/wingpro8/bin/dbg/src/wingbase/pexpect/ptyprocess', '/usr/lib/wingpro8/bin/dbg/src/wingbase/__pycache__', '/usr/lib/wingpro8/bin/dbg/src/wingbase/__os__', '/usr/lib/wingpro8/bin/dbg/src/wingbase/__os__/osx', '/usr/lib/wingpro8/bin/dbg/src/wingbase/__os__/win32', '/usr/lib/wingpro8/bin/dbg/src/debug/tserver/__os__/linux-x64', '/usr/lib/wingpro8/bin/dbg/src/wingbase/__os__/linux-x64', '/usr/lib/wingpro8/src', '/usr/lib/wingpro8/src/debug', '/usr/lib/wingpro8/src/debug/__pycache__', '/usr/lib/wingpro8/src/debug/tserver', '/usr/lib/wingpro8/src/debug/tserver/__pycache__', '/usr/lib/wingpro8/src/debug/client', '/usr/lib/wingpro8/src/wingutils', '/usr/lib/wingpro8/src/testing', '/usr/lib/wingpro8/src/testing/runners', '/usr/lib/wingpro8/src/external', '/usr/lib/wingpro8/src/external/pygments', '/usr/lib/wingpro8/src/external/pygments/pygments', '/usr/lib/wingpro8/src/external/pygments/pygments/lexers', '/usr/lib/wingpro8/src/external/pygments/pygments/styles', '/usr/lib/wingpro8/src/external/pygments/pygments/formatters', '/usr/lib/wingpro8/src/external/pygments/pygments/filters']
Traceback (most recent call last):
  File "/usr/lib/wingpro8/bin/dbg/src/debug/tserver/startdebug.py", line 33, in _ParseSingleArg
  File "/usr/lib/wingpro8/bin/dbg/src/debug/tserver/startdebug.py", line 62, in _HostportTransform
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/wingpro8/bin/dbg/src/debug/tserver/startdebug.py", line 637, in StartDebug
  File "/usr/lib/wingpro8/bin/dbg/src/debug/tserver/startdebug.py", line 318, in _ParseArgv
  File "/usr/lib/wingpro8/bin/dbg/src/debug/tserver/startdebug.py", line 45, in _ParseSingleArg
SystemExit: 2
(myvenv) odile@odile-GE72-2QC:~/Documents/dev_logiciels$

whereas the same code ran within wing without sudo parses the argument correctly.

edit flag offensive delete link more

Comments

Do you have WINGDB_PYTHON set as described in http://wingware.com/doc/debug/wingdb? I'm suspecting some things were changed in wingdb that intentionally ended up requiring more args. We'll look into that. Try using wingdbstub.py instead and that'll probably work.

Wingware Support's avatar Wingware Support  ( 2022-04-11 09:16:14 -0500 )edit

Actually it looks like the above was caused by setting WINGDB_HOSTPORT to a value that didn't include a port number. We've fixed that for 8.3.0.2+ to default the port to 50005 in that case. The work-around is to set that env correctly to the form hostname:port.

Wingware Support's avatar Wingware Support  ( 2022-04-13 09:35:50 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2019-01-05 12:08:00 -0500

Seen: 894 times

Last updated: Apr 09