Apache Storm nimbus start fails when run using python - linux

I am trying to install and run apache storm(version 1.0.2) on amazon linux instance.There is no problem in starting storm nimbus when I am root user. In other words, if is use the following commands
sudo su -
python /opt/apache-storm-1.0.2/bin/storm.py nimbus
it is working fine.
However if am an ec2-user and tries to execute the command as
sudo python /opt/apache-storm-1.0.2/bin/storm.py nimbus
it is giving the following error
Traceback (most recent call last):
File "./storm.py", line 769, in <module>
main()
File "./storm.py", line 766, in main
(COMMANDS.get(COMMAND, unknown_command))(*ARGS)
File "./storm.py", line 529, in nimbus
jvmopts = parse_args(confvalue("nimbus.childopts", cppaths)) + [
File "./storm.py", line 145, in confvalue
p = sub.Popen(command, stdout=sub.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Is there anyway to run the command without switching as root user

Related

Python cannot access my usb device - insufficient permission

Python script cannot send print to my usb Epson receipt printer
I am new to Ubuntu. I am trying to send some text to a thermal label printer connected to my computer via usb. Upon executing the code in Visual Studio Code by pressing the F5 key, I get the below error
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
However, if I execute the same code with:
sudo python3 -m test5.py
then, it prints out all right. I have done many google searches, and it seems that this is a problem related to my rule settings, so I made the following rule in /etc/udev/rules.d/printerRule.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="1208", ATTRS{idProduct}=="3605", MODE="0666", OWNER="hdadmin"
Still the problem persists.
The reason why I need to solve this problem is, I later need to compile the Python script using pyinstaller. If I compile as it is right now with
pyinstaller --onefile test5.py
The compile process will be fine, but I will still not be allowed to use the usb device when running the compiled file. Below is the full error report
(env) (base) hdadmin#HiddenDimsum:~/Documents/Python/POS$ cd /home/hdadmin/Documents/Python/POS ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /home/hdadmin/Documents/Python/POS/env/bin/python3.6 /home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 42379 /home/hdadmin/Documents/Python/POS/test4.py
Traceback (most recent call last):
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 432, in main
run()
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "/usr/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/hdadmin/Documents/Python/POS/test4.py", line 2, in <module>
printer = Usb(1208, 3605)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 51, in __init__
self.open()
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 62, in open
check_driver = self.device.is_kernel_driver_active(0)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
self._ctx.managed_open()
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
Since I am new to Linux and Ubuntu, I need help and advices so that I can get permission to the usb devices connected to my computer. The expected outcome is, I should be able to run the test5.py by without the need for
sudo python3 -m test5.py
Thanks to gst. You are fully right. My mistake is during my .rule creation
SUBSYSTEM=="usb", ATTRS{idVendor}=="1208", ATTRS{idProduct}=="3605", MODE="0666", OWNER="hdadmin"
Instead it should look as below, where GROUP="users". I misread the "users" and substituted it with the user name. I changed my rule to as below:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="2016", GROUP="users", MODE="0666"
and then in termial write
$ sudo udevadm control --reload
and restarted the computer.

Mac: saving .exe to PATH for selenium web driver

I am not a professional developer... trying to save chromedriver to PATH variable so i can use selenium with python.
following this page for instructions on this page
https://medium.com/#himanshuagarwal1395/setting-up-environment-variables-in-macos-sierra-f5978369b255
I open bash_profile with nano .bash_profile
I made a directory user/mysusername/selenium/
then saved my file chromedriver in this directory with the python script i and using selenium with.
I have tried to save my path to the chromedriver.exe file as such
export PATH="/User/baldoa/selenium/ChromeDriver.exe:$PATH"
I follow the steps to save appropriately according to this page. I am not sure
i still get the following error :
a8206602016e:selenium baldoa$ python destruction.py
Traceback (most recent call last):
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py", line
709, in __init__
restore_signals, start_new_session)
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py", line
1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:/users/baldoa
/selenium/chromedriver.exe': 'C:/users/baldoa/selenium/chromedriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "destruction.py", line 7, in <module>
browser = webdriver.Chrome("""C:/users/baldoa/selenium/chromedriver.exe""")
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe'
executable needs to be in PATH. Please see https://sites.google.com
/a/chromium.org/chromedriver/home

jupyter nbconvert --to slides fails due to access permissions

I'm trying to generate a slideshow for my notebook using nbconvert. Using windows, jupyter and python 3.
https://nbconvert.readthedocs.io/en/latest/usage.html#convert-revealjs
I'm running the command in a command shell in admin mode:
jupyter nbconvert C:\files\notebook.ipynb --to slides --post serve
The files\ directory contains a directory called reveal.js.
The following error is raised,
[NbConvertApp] Converting notebook C:\files\notebook.ipynb to slides
[NbConvertApp] Writing 379320 bytes to C:\files\notebook.slides.html
[NbConvertApp] Serving local reveal.js
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\Scripts\jupyter-nbconvert-script.py", line 5, in <module>
main()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 293, in start
self.convert_notebooks()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 457, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 430, in convert_single_notebook
self.postprocess_single_notebook(write_results)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 402, in postprocess_single_notebook
self.postprocessor(write_results)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\postprocessors\base.py", line 28, in __call__
self.postprocess(input)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\nbconvert\postprocessors\serve.py", line 87, in postprocess
http_server.listen(self.port, address=self.ip)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\tornado\tcpserver.py", line 126, in listen
sockets = bind_sockets(port, address=address)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\tornado\netutil.py", line 194, in bind_sockets
sock.bind(sockaddr)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Which indicates that the port is already in use locally- I believe it defaults to 8000. Is there a way to specify the port when running the nbcovert command? E.g. not 8000.
NB The file notebook.slides.html is being created, and I can manually serve it up with http.server on a different port.
You can indeed change the port. Modify the command as follows:
jupyter nbconvert C:\files\notebook.ipynb --to slides --ServePostProcessor.port=8910 --post serve

Process as Daemon on Init.d

I am trying to configure airflow webserver and scheduler to run. It is a python application.
I used "python setup.py install" and then using the shell comand:
(start-stop-daemon --start --quiet --exec airflow webserver) started the processes.
Everything works ok.
But when I create a daemon script, on init.d i am getting:
2015-12-09 13:41:29,808 - root - INFO - Filling up the DagBag from /home/pedro/airflow/dags
2015-12-09 13:41:29,810 - root - INFO - Importing /home/pedro/airflow/dags/simple_ecs_dag.py
2015-12-09 13:41:29,830 - root - INFO - Loaded DAG
Running the Gunicorn server with 4 syncworkers on host 0.0.0.0 and port 8080...
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 4, in
import('pkg_resources').run_script('airflow==1.6.1', 'airflow')
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 742, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 1667, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/airflow-1.6.1-py2.7.egg/EGG-INFO/scripts/airflow", line 17, in
args.func(args)
File "/usr/local/lib/python2.7/dist-packages/airflow-1.6.1-py2.7.egg/airflow/bin/cli.py", line 338, in webserver
'airflow.www.app:cached_app()'])
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I imagine that the start-stop-daemon running or the python process are running under diferent users.
Does anyone can help me?

webrtc build fail in ubuntu

I built webrtc for my linux (ubuntu 14.04 32 bit) machine. The way I follow to build webrtc is following.
1, download and setup depot_tools and java.
2, fetch webrtc.
3, build/install-build-deps.sh.
4, export GYP_GENERATORS=make.
5, gclient runhooks --force (also try python src/webrtc/build/gyp_webrtc).
6, make.
when make command execute after compile some code following error occur.
LINK(host) out/Debug/protoc
TOUCH webrtc_modules_modules_gyp_audioproc_debug_proto_target_genproto_0.intermediate
RULE webrtc_modules_modules_gyp_audioproc_debug_proto_target_genproto_0
webrtc_modules_modules_gyp_audioproc_debug_proto_target_genproto_0.intermediate
Traceback (most recent call last):
File "../../tools/protoc_wrapper/protoc_wrapper.py", line 134, in <module>
sys.exit(main(sys.argv))
File "../../tools/protoc_wrapper/protoc_wrapper.py", line 119, in main
ret = subprocess.call(protoc_args)
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
make: *** [webrtc_modules_modules_gyp_audioproc_debug_proto_target_genproto_0.intermediate]
Error 1
rm webrtc_modules_modules_gyp_audioproc_debug_proto_target_genproto_0.intermediate.
Do you guys have any idea of why? And how to fix this?

Resources