USB missile launcher on Linux - python

I came across a page on Hacking the Kinect. It was discussing how to interface with the system. The code I used is as follows.
The script comes from Lady ada in her post on hacking the connect.
I would love get this working. I am using python
This is a link to that code
http://learn.adafruit.com/hacking-the-kinect/fuzzing
The errors I get are as follow
sudo python UsbFuzzer.py
Traceback (most recent call last):
File "UsbFuzzer.py", line 14, in <module>
dev.set_configuration()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 554, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 92, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 503, in set_configuration
_check(_lib.libusb_set_configuration(dev_handle, config_value))
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 403, in _check
raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy

The main problem here is that libusb is returning an error code, "Resource busy". This could be a permissions problem. Try running your program with sudo and see if that fixes it. This link looks promising, because it talks about how to set up a udev rule so you don't have to run as root:
pyusb: cannot set configuration
If that does not help, you could Google around for "libusb resource busy".

Related

issue with hubble-pi camera capture

I have recently tried to install and get working a program developed to use with a telescope. It is called hubble-pi and can be found here. https://github.com/RemovedMoney326/Hubble-Pi
The program runs but when i click the capture button I get this issue. I have reached out to the dev but he has not replied and that was over a month ago. If anyone could assist in figuring out a solution that be awesome.
Im a beginner when it comes to python so be easy. This is also happening on boot up as this is the first thing im doing when turning on my RPI. I am running this on a RPI 4 2gb.
Python 3.7.3 (/usr/bin/python3)
>>> %Run AstroCam.py
Start
Capture
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/AstroCameraApp/PythonScripts/AstroCam.py", line 60, in camHandler
camera.resolution = DynamicCaptureResolution #set photo size
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 2282, in _set_resolution
self._enable_camera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1976, in _enable_camera
self._camera.enable()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 724, in enable
prefix="Failed to enable component")
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable component: Out of resources
I just hit this same error with another Picamera IMX477 app, and found a fix.
Set gpu-mem=192 in /boot/config.txt, reboot, and 4032x3040 starts working.
This is for Pi-4, 2GB running Buster. Bullseye is a different animal.

Unable to run Django Test Server in Ubuntu Server 16.04

I have 2 servers. I am attempting to setup one for continuous integration for my main website server
Web server 1(cloud-hosting):
Python3.6
Django3.1
Ubuntu16.04
Webserver 2(VPS):
Python3.7
Django3.1
Ubuntu16.04
Jenkins
--ShiningPanda(plugin)
Im new to web development, so if it seems odd as far as my web server types, that is why. I have been following along in the book Test Driven Development with Python. My issue is that when running python manage.py test [app] My [app] inherits from the class StaticLiveSever to generate a testing environment. On webserver 1, this works fine. On webserver 2, i get an error that the request address cannot be assigned. I use jenkins to build the environment, but the error i get is OSerror[99]:cannot assign requested address. I dont understand why this is happening when i run the same commands in Web Sever 1. It runs fine. Although again, the commands are run by jenkins and jenkins is configured to run python3.7
Full Traceback(Main Issue)
Traceback (most recent call last):
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1449, in setUpClass
raise cls.server_thread.error
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1374, in run
self.httpd = self._create_server()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1389, in _create_server
return ThreadedWSGIServer((self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False)
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 67, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib/python3.7/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/lib/python3.7/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address
After hardcoded host
Traceback (most recent call last):
File "/var/lib/jenkins/workspace/Superlists/functional_tests/base.py", line 47, in setUp
self.browser = webdriver.Firefox()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 100, in start
self.assert_process_still_running()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 113, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 69
geckodriver.log w/ hardcoded host ip in LiveTestServer
eckodriver: error: Address not available (os error 99)
geckodriver 0.27.0 (7b8c4f32cdde 2020-07-28 18:16 +0000)
WebDriver implementation for Firefox
USAGE:
geckodriver [FLAGS] [OPTIONS]
[...]
Hopefully the tracebacks above are not too confusing. Ultmiately what i did notice was the when im in webserver 2, i access the Django testcases.py module that has LiverServerThread and hardcode host=0.0.0.0 instead of host=localhost (1st traceback). The connection is then made although then the problem lies with geckodriver and the same thing (2nd traceback). I need to hard code ip 0.0.0.0 to be able to establish a connection, but then geckodriver is just listening, which i am assuming, at a completely different location (no error.log shown here).
So 1st id like to at least be able to make a connection to run the LiveServerThread class properly. Then try and resolve the issue with geckodriver. I also was not sure if the type of servers im running on poses as the problem.

Why does Serverless produce an Invalid Cross-device link Error when trying to package or deploy?

When running either command:
sudo serverless package or sudo serverless deploy
I get the following traceback:
Error: ERROR: Exception: Traceback (most recent call last): File
“/var/lang/lib/python3.6/shutil.py”, line 550, in move os.rename(src,
real_dst) OSError: [Errno 18] Invalid cross-device link:
‘/tmp/pip-target-wqc5grcw/lib/python/setuptools’ ->
‘/var/task/setuptools’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
“/var/lang/lib/python3.6/site-packages/pip/_internal/cli/base_command.py”,
line 228, in _main status = self.run(options, args) File
“/var/lang/lib/python3.6/site-packages/pip/_internal/cli/req_command.py”,
line 182, in wrapper return func(self, options, args) File
“/var/lang/lib/python3.6/site-packages/pip/_internal/commands/install.py”,
line 456, in run options.target_dir, target_temp_dir, options.upgrade
File
“/var/lang/lib/python3.6/site-packages/pip/_internal/commands/install.py”,
line 514, in _handle_target_dir target_item_dir File
“/var/lang/lib/python3.6/shutil.py”, line 561, in move symlinks=True)
File “/var/lang/lib/python3.6/shutil.py”, line 321, in copytree
os.makedirs(dst) File “/var/lang/lib/python3.6/os.py”, line 220, in
makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission
denied: ‘/var/task/setuptools’
I’ve created several different projects and they work locally but they never progress beyond this invalid cross-link device Error when trying to deploy or package.
What are my options?
Edit: I tried nuking my virtualenv, uninstalling/re-installing serverless-python-requirements, deleting/re-pulling the lambci/lambda Docker image, no dice.
Then, I stumbled on this GH issue. As hinted in it, the experimental Docker feature Use gRPC FUSE for file sharing seems to be the cause. I've switched it off in the Docker Preferences for now and deploys are successful.
I just had a similar problem. See this issue for a possible solution.
In summary,
Remove all cached packages in /Library/Caches/serverless-python-requirements/
Remove existing docker image lambci/lambda build-python3.8

IOError: [Errno 0] Error while writing to output of Powershell in VSCode

This is the error I get in VSCode when running docker-compose.
PS D:\Work\Imho\Api> docker-compose -f docker-compose.yml up
Creating network "api_default" with the default driver
Pulling ignite (apacheignite/ignite:latest)...
latest: Pulling from apacheignite/ignite
5040bd298390: Pulling fs layer
fce5728aad85: Pulling fs layer
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\main.py", line 68, in main
File "compose\cli\main.py", line 118, in perform_command
File "compose\cli\main.py", line 926, in up
File "compose\project.py", line 401, in up
File "compose\service.py", line 305, in ensure_image_exists
File "compose\service.py", line 1001, in pull
File "compose\progress_stream.py", line 37, in stream_output
File "codecs.py", line 370, in write
File "site-packages\colorama\ansitowin32.py", line 40, in write
File "site-packages\colorama\ansitowin32.py", line 141, in write
File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
IOError: [Errno 0] Error
Failed to execute script docker-compose
docker-compose.yml:
version: '3'
services:
ignite:
image: apacheignite/ignite
This error only happens on one of my 3 machines, so I have no idea what causes it. Resetting to factory defaults or reinstalling docker and vscode doesn't help. Without docker compose the image is pulling and then working fine. All the machines are on windows 10 and latest stable docker installed.
Here is the issue I opened on github. It appeared that this behavior only occurs in VSCode powershell console, but not in regular powershell console. The solution with changing encoding suggested there didn't help.
Solution: Update to 1803 on Windows 10. If you can't update, use external command prompt.
The same thing happens to me with Python scripts. Apparently, this is a Windows Update issue:
https://github.com/Microsoft/vscode/issues/36630#issuecomment-359969098
Edit: My workaround due to my company restricting updates is to use external terminal in VS Code

Python - Pygame For android errors

I was following the documentation of pgs4a, where in the build part I got a WindowsError [Error 2].
The Command and Traceback:
C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4>android.py build "C:\Users\karuna\Desktop\Jython\P
ython\pgs4a-0.9.4\mygame" release install
Updating build files.
Traceback (most recent call last):
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 66, in <module>
main()
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 54, in main
build.build(iface, args.argument[0], args.argument[1:])
File "buildlib\build.py", line 301, in build
build_core(iface, directory, commands)
File "buildlib\build.py", line 221, in build_core
subprocess.call([plat.android, "update", "project", "-p", '.', '-t', 'android-8', '-n', versione
d_name])
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 893, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
As obvious,
I am using Windows 7, and have:
Python 2.7.3
JDK
Android Emulator
Device drivers for my Sony Tipo.
Please help!
By the way,
I would prefer to get this running on my phone first. I am thinking of moving to the emulator later(after the tutorial is completed).
Is this question more suitable for https://android.stackexchange.com/?
I am not sure if this is still an issue for you, but I ran into the similar issue recently and managed to solve it so I will just leave a note here.
If anyone gets this kind of error, go to pgs4a folder and android-sdk folder. There, run SDK Manager.exe file. You will see a list of Tools and different android versions. Try to find the version that you are working on and install everything that is 'uninstalled'.
I managed to solve the above issue by installing everything under my current AND previous Android versions. Hope this will help anyone who ran into the same issue!
rename the folder android-sdk-windows to android-sdk

Categories