Esky freezes after escalating permissions on windows 7 - python

We're about to start using Esky to deploy updates to our application. On Windows 7, Esky appears to be unable to get the escalated privileges it needs to install an update.
I've narrowed it down to this simple script. It asks for escalated permissions, but will either freeze, or crash with the stacktrace below.
Script
import esky
import esky.sudo
class MyProgram(object):
#esky.sudo.allow_from_sudo()
def do_stuff(self):
pass
app = MyProgram()
sapp = esky.sudo.SudoProxy(app)
sapp.start()
sapp.do_stuff()
sapp.drop_root()
Stack Trace
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 125, in start
raise RuntimeError("sudo helper process terminated unexpectedly")
RuntimeError: sudo helper process terminated unexpectedly
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 140, in start
self.close()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 156, in close
self.pipe.read()
File "c:\Python27\lib\site-packages\esky\sudo\sudo_base.py", line 123, in read
raise EOFError
EOFError
Does anyone know of a solution, or have any suggestions?
Using:
python 2.7.3
esky 0.9.7

3 years and no answer that is very sad :(
This is a bug in esky.
Esky works fine for me besides the fact that escalating privileges fails.
I'm used to programming in python3... so once I'm done updating Esky to be python 2 and 3 compatible I'm going to tackle this issue.
If anyone wants to solve this problem let's rock and roll! To the github issue tracker!

This is super late, but if anyone in the future has this problem, try running sudo python your_program.py.

Related

Mouse, and keyboard python modules conflicting?

I am writing a test program which contains the mouse, and keyboard modules together, but they conflict when I run the program.
If applicable, I run Linux Mint 20.04 (Uma).
Here is my code:
import keyboard
import mouse
import time
time.sleep(2)
print("Finished part 1!")
x, y = mouse.get_position()
time.sleep(2)
print("Finished part 2!")
mouse.move(x, y)
time.sleep(2)
print("Finished part 3!")
keyboard.add_hotkey('ctrl+alt+c', mouse.move(x, y))
If I run this program normally, such as /bin/python3 /home/bhrz/Scripts/Python/Mouse/main.py in my terminal, it outputs:
Finished part 1!
Finished part 2!
Finished part 3!
Traceback (most recent call last):
File "/home/bhrz/Scripts/Python/Mouse/main.py", line 18, in <module>
keyboard.add_hotkey('ctrl+alt+c', mouse.move(x, y))
File "/usr/local/lib/python3.8/dist-packages/keyboard/__init__.py", line 639, in add_hotkey
_listener.start_if_necessary()
File "/usr/local/lib/python3.8/dist-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/usr/local/lib/python3.8/dist-packages/keyboard/__init__.py", line 196, in init
_os_keyboard.init()
File "/usr/local/lib/python3.8/dist-packages/keyboard/_nixkeyboard.py", line 113, in init
build_device()
File "/usr/local/lib/python3.8/dist-packages/keyboard/_nixkeyboard.py", line 109, in build_device
ensure_root()
File "/usr/local/lib/python3.8/dist-packages/keyboard/_nixcommon.py", line 174, in ensure_root
raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.
When I attempt to solve that error by entering this, sudo /bin/python3 /home/bhrz/Scripts/Python/Mouse/main.py, it outputs:
Traceback (most recent call last):
File "/home/bhrz/Scripts/Python/Mouse/main.py", line 2, in <module>
import mouse
ModuleNotFoundError: No module named 'mouse'
I have looked for answers, and some were to do the above, which as you can see, has resulted in failure, and another said to do sudo su then run the script--which also failed, with the same output as above.
Please help me figure out what the problem is.
I do have unintentionally 3 versions of python installed: 2.7, 3.8.10, and 3.9.5. I personally installed Python 3.9.5. I don't use 2.7, but it was installed with the python-dev
On Python 3.9.5, the keyboard module isn't recognized, but on Python 3.8.10, it is.
I have found the answer to my problem. The thread: Python can't find module when started with sudo 's second answer fixed my problem.
Instead of running sudo python3(/3.8) myScriptName.py, run sudo -E python3(/3.8) myScriptName.py.
Thank you, Nima for attempting to help me!
Use sudo /bin/python3.8 /home/bhrz/Scripts/Python/Mouse/main.py as you said:
On Python 3.9.5, the keyboard module isn't recognized, but on Python 3.8.10, it is.
python3 has been replaced when you installed python3.9.5. So it belongs to python 3.9.5. You need to use python3.8 in order to execute your script in python 3.8.10 environment.

Issue running python script

I'm running a python script called ALPS which installs packages. It has worked, but now spits this error:
Traceback (most recent call last):
File "/usr/bin/alps", line 295, in <module>
initPackages()
File "/usr/bin/alps", line 156, in initPackages
packageMap[line.split(':')[0]].append(line.split(':')[1].strip())
KeyError: 'gnome-icon-theme'
The error occured when I made spelling mistake with the package 'gnome-icon-theme?
This is obviously linked to python, but can anyone point the way to solving this? The source code can be found here: https://github.com/FluidIdeas/alps
thanks
Cliff

The command "pipenv run" worked fine yesterday. Why I get an AttributeError today?

I have a python script which I called via
pipenv run python3 script.py
Yesterday it worked fine, but today I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 7, in <module>
from pipenv import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17,in <module>
from .cli import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 89, in <module>
if ((now.tm_mon == 10) and (now.tm_day == 30)) or ((now.tm_mon == 10) and (now.tm_day == 31)):
AttributeError: 'time.struct_time' object has no attribute 'tm_day'
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 7, in <module>
from pipenv import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17, in <module>
I assume that it may have something to do with the new month starting, but I can't find a way to fix this (strange) problem.
Some further information:
The script runs on a raspberry pi. It uses the requests and the Adafruit_DHT library. I don't do any time-regarding operations in the python script by myself.
Could I kindly ask you to help me?
Many thanks in advance
Make on reinstall, direct repository latest version!
pip install git+https://github.com/kennethreitz/pipenv.git
Pretty sure this is a bug in pipenv. I've submitted an issue here

Debugging twisted application using PyCharm

I am fighting a few hours trying to configure PyCharm for debugging my app. I was looking for solution, but twisted seems to not be so popular and there is weak support. Below I put error log that i got.
/usr/local/bin/python3.4m -u /Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py 57276 57277 /usr/bin/twistd -y /Users/artur/projs/private/elanga-web/start_app.tac
Running /usr/bin/twistd
PyDev console: starting.
Traceback (most recent call last):
File "/usr/bin/twistd", line 7, in <module>
import _preamble
ImportError: No module named '_preamble'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 68, in <module>
globals = run_file(file, None, None)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 28, in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/usr/bin/twistd", line 9, in <module>
sys.exc_clear()
AttributeError: 'module' object has no attribute 'exc_clear'
Process finished with exit code 1
Couldn't connect to console process.
I will be grateful for an answer why there is no such module like _preamble
On OS X, /usr/bin/twistd is a version of Twisted installed into the system python. This is not python 3.4. The symptom you're seeing is not the missing _preamble module (which is in fact not supposed to be installed, which is why there is an except block around that import catching the exception) but rather that you have pointed python 3.4 at some random python 2 program.
If you want to run python 3.4, you need to create a python 3 environment with Twisted installed. Keep in mind that not all of Twisted is ported, so only a subset of APIs will be available to you. One of the things that is not ported to python 3 yet is the twistd command line, so there's no way to run twistd with python 3 yet.

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

Categories