I'm tring to port Driveboardapp from kernel 3.8 to kernel 4.14.
Driveboardapp is an app written in python and designed to run a lasersaur laser cutting machine.It make use of UART1, WiFi, and GPIOs.
Developers recomend running the app into a beaglebone black board using an image based in Ubuntu 14.04 LTS with kernel 3.8
With this image I experience network stability problems and I found the more recent official beaglebone image based in debian 9.5 with kernel 4.14 much more reliable.
Unfortunately I can't get the gpio functionality to work as expected with this new OS.
This is the python code to set gpio pins:
try:
fw = file("/sys/class/gpio/export", "w")
fw.write("%d" % (71))
fw.close()
except IOError:
# probably already exported
pass
# set the gpio pin to output
# echo out > /sys/class/gpio/gpio71/direction
fw = file("/sys/class/gpio/gpio71/direction", "w")
fw.write("out")
fw.close()
# set the gpio pin high
# echo 1 > /sys/class/gpio/gpio71/value
fw = file("/sys/class/gpio/gpio71/value", "w")
fw.write("1")
fw.flush()
fw.close()
When I run the app in debian9.5 sometimes it breaks with this message:
root#beaglebone:~/driveboardapp# python backend/app.py
Traceback (most recent call last):
File "backend/app.py", line 7, in <module>
import config
File "/root/driveboardapp/backend/config.py", line 194, in <module>
fw = file("/sys/class/gpio/gpio71/direction", "w")
IOError: [Errno 2] No such file or directory: '/sys/class/gpio/gpio71/direction'
If i rerun the app it may break at the same point or it may succeed and eventually break at the next point in the code that make use of the gpio.
So far I tried to add a small sleep before the file write attempt but it still fail.
Driveboard app repo https://github.com/nortd/driveboardapp
My edits at the code so far https://github.com/luky83/driveboardapp/blob/debian9.5/backend/config.py
Thanks for any advice.
Switching to Adafruit's BeagleBone IO Python Library seems to be the way to do it:
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("P8_46", GPIO.OUT)
GPIO.output("P8_46", GPIO.HIGH)
Related
Ok I have 2 KVM servers: server_1 and server_2.
server_1 is in production and can not talk to server_2, server_2 is in my test environment getting ready for production.
From server_1 I have copies 2 cloned VM's (I can't put the running ones off now) and moved them to server_2.
On server_2 using the gui interface I select Import existing disk image > Storage path: /home/vmpools/example.img, OS type: Linux, Version: CentOS 7.0 > RAM: 1024, CPU's 1 > Name: example and leave the rest default
Upon finish I get the following error:
Unable to complete install: 'internal error: process exited while connecting to monitor: 2016-08-18T09:29:23.423006Z qemu-kvm: -drive file=/home/vmpools/SureCollectGateway.img,if=none,id=drive-virtio-disk0,format=qed: could not open disk image /home/vmpools/SureCollectGateway.img: Driver 'qed' is not whitelisted
'
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 90, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/create.py", line 2277, in _do_async_install
guest.start_install(meter=meter)
File "/usr/share/virt-manager/virtinst/guest.py", line 501, in start_install
noboot)
File "/usr/share/virt-manager/virtinst/guest.py", line 416, in _create_guest
dom = self.conn.createLinux(start_xml or final_xml, 0)
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3606, in createLinux
if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self)
libvirtError: internal error: process exited while connecting to monitor: 2016-08-18T09:29:23.423006Z qemu-kvm: -drive file=/home/vmpools/SureCollectGateway.img,if=none,id=drive-virtio-disk0,format=qed: could not open disk image /home/vmpools/SureCollectGateway.img: Driver 'qed' is not whitelisted
However I can create new VM's from ISO's.
How would I go about white listing qed or what am I missing to make this work?
CentOS dose not supprt the qed disk format, use qcow2 instead.
https://bugs.centos.org/view.php?id=8986
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/7.0_Release_Notes/Known-Issues-Virtualization.html
qemu-kvm component, BZ#731570
The QEMU Enhanced Disk format (QED) for KVM guest virtual machines is not supported in Red Hat Enterprise Linux 7. Use the qcow2 image
format instead.
My computer's OS is 64-bit win 10. Python 2.7, 32-bit.
My code is plot.py, simple as below:
import matplotlib.pyplot as plt
import FileDialog
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
When I execute pyinstaller -F plot.py, the generated
plot.exe works as expected on my current computer. However, I get an error if I try to run it on a different 32-bit Windows 7 computer:
Traceback (most recent call last):
File "site-packages\GUI_tempCtrl\plot.py", line 3, in <module>
File "lib\site-packages\matplotlib\pyplot.py", line 3147, in plot
File "lib\site-packages\matplotlib\pyplot.py", line 928, in gca
File "lib\site-packages\matplotlib\pyplot.py", line 578, in gcf
File "lib\site-packages\matplotlib\pyplot.py", line 527, in figure
File "lib\site-packages\matplotlib\backends\backend_tkagg.py", line 84, in new
_figure_manager
File "lib\site-packages\matplotlib\backends\backend_tkagg.py", line 92, in new
_figure_manager_given_figure
File "lib\lib-tk\Tkinter.py", line 1814, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/ADMINI~1/AppData/Local/Temp/lib/tcl8.5 C:/Users/Administrator/lib/t
cl8.5 C:/Users/lib/tcl8.5 C:/Users/Administrator/library C:/Users/library C:/Use
rs/tcl8.5.15/library C:/tcl8.5.15/library
This probably means that Tcl wasn't installed properly.
Failed to execute script plot
You can try downgrading pyinstaller to v3.1 and rebuilding your exe file on your first computer to solve this issue.
Alternatively, you can fix it on your second computer by setting the TCL_LIBRARY environment variable to C:\Python27\tcl\tcl8.5\ (or wherever tcl8.5 is located)
PyInstaller has a known issue with Tkinter applications on Windows 7 and Windows XP.
Since this issue has gone unfixed for two years, I've gone ahead and started a bounty. Until the issue is fixed, there are a few workarounds you can try:
Workaround 1 - Manually copy missing files
As mentioned in a related issue, you can manually copy the missing files from your local Python installation.
Find your local Python installation. (%LocalAppData%\Programs\Python)
Make a copy of the missing folder (...\Python36-32\tcl\<missing_folder>)
Move the copy to your application's tcl folder (...\dist\<app_name>\tcl\<missing_folder>)
Workaround 2 - Run with --onefile
Running PyInstaller in --onefile mode seems to avoid this issue.
However, note that running in single file mode will increase startup time.
Workaround 3 - Downgrade to PyInstaller 3.1.0
pip install pyinstaller==3.1.0
According to ugoertz, downgrading to PyInstaller 3.1.0 resolved the issue.
Downgrading to 3.1.0 (and also downgrading setuptools to 19.2 because of the problem described in #1941) fixed the issue for me.
I have installed Scapy on my OS 10.11.5 machine and have been playing around with it in the interactive mode while reading through some of the tutorials on their site (http://www.secdev.org/projects/scapy/doc/index.html) and it's working just fine.
I can run sudo scapy and then run the sniff(count=5) command and all works fine; it does a nice and pretty job printing the contents with _.show(). All works, except a weird message:
WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.
But that's neither here nor there as all things work to properly play with the packets (I haven't tested sending anything while watching in Wireshark, but I guess that's a topic for another time).
Now... When I try to do the following code in a .py file, I get all kinds of issues:
#!/usr/bin/python
from scapy.all import *
def packet_calback(packet):
print packet.show()
sniff(store=0, prn=packet_callback)
with a sudo scapy.py, I get the follow traceback:
#:./scapy.py
Traceback (most recent call last):
File "./scapy.py", line 3, in <module>
from scapy.all import *
File "/Users/myuser/Desktop/scapy.py", line 3, in <module>
from scapy.all import *
ImportError: No module named all
From what I see in the docs, this is the preferred method to getting it to work, but it doesn't here...
I have tried import scapy and then scapy.sniff(...) and scapy.all.sniff(...) but those don't work either.
Just for officialness:
$which python
/usr/local/bin/python
$python --version
Python 2.7.11
$/usr/bin/python --version
Python 2.7.10
I guess I also have 2 versions of Python installed.... But the same issues happen with both installs.
Help! Please?
Wow... I'm an idiot...
Lesson to all! Don't name your file after a module you're importing! I know better than this and yet look at what I've done!!
Bah!!
I have a pair of applications that communicate by sending text (in one direction only) over a serial port. They have been working great for a while. Last week the reading side stopped working on my machine, and raises a SerialException whenever I call the readline() method of my serial.Serial object. The same code works fine on another machine! The only thing I can think of that could have caused a problem is that I installed a bunch of system updates the night before this happened (Any idea how to see the history on that?). I'm using Ubuntu and Python 2.7.6 (see below), and as far as I can tell I have the same python packages installed on both machines.
I've written two small sample apps to try to troubleshoot, and am getting the following error on the reading side:
File "./reader.py", line 16, in <module>
s = port.readline()
File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 475, in read
raise SerialException('device reports readiness to read but returned no data (device disconnected or multiple access on port?)')
It doesn't seem to matter whether I use a "real" port or a "virtual" port, so this can be reproduced by creating two virtual ports with the following command:
socat -d -d pty,raw,echo=0 pty,raw,echo=0
Here is the sample "writer.py" that I created for troubleshooting:
#!/usr/bin/env python
from __future__ import print_function
import serial
print( 'Opening port' )
port = serial.Serial( port='/dev/pts/5', # Substitute the correct port here!
baudrate=115200,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
timeout=0.25 )
while True:
s = raw_input()
if s:
port.write( s + '\n' )
This works great - I can read the text coming through the port using an app like "Serial port terminal" or such.
Here is the sample "reader.py" that works find on another machine but fails immediately on mine:
#!/usr/bin/env python
from __future__ import print_function
import serial
print( 'Opening port' )
port = serial.Serial( port='/dev/pts/10',
baudrate=115200,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
timeout=0.25 )
while True:
s = port.readline()
if s:
print( s )
Once I create the virtual port with the socat command and run "reader.py", I always get the exception immediately. Any ideas what might have changed on my machine that would cause this failure?
System info:
~/temp$ uname -a
Linux alonghi-ubu 3.13.0-65-generic #105-Ubuntu SMP Mon Sep 21 18:50:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
~/temp$ python --version
Python 2.7.6
Ubuntu 14.04 3.13.0.65 kernel breaks python serial communication. Try downgrading kernel to 3.13.0-63 and serial communication should work as before
Trying to install uwsgi according to documentation. I'm getting the below error on Windows 7.
What should I do?
(uwsgi-tutorial) C:\Users\Home\Videos\uwsgi-tutorial\mysite>pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.11.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi\setup.py", line 3, in <module>
import uwsgiconfig as uc
File "uwsgiconfig.py", line 8, in <module>
uwsgi_os = os.uname()[0]
AttributeError: 'module' object has no attribute 'uname'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\home\appdata\local\temp\pip-build-04g1m6\uwsgi
uWSGI can be compiled on Windows only using cygwin. There is no such thing as uname in normal Windows console, but it exists inside cygwin. If you're already in cygwin console, try to run uname command, if that exists, check if os.uname() in python inside cygwin is also working.
Latest news from the front, uWSGI perfectly works on Windows 10 in bash on Ubuntu on Windows
As Linux subsystem still in beta, i'd not recommend for production usage, however this will cover all dev needs.
P.S. i know that op ask about Windows 7, however as Windows 10 and Linux subsystem come to Windows world later, i think i can leave this here.
uWSGI can be compiled on Windows using Cygwin. But unfortunately, I was getting the same message with the Cygwin.
Here I am sharing the other way to install uWSGI on windows.
Step 1: Download the stable release and extract the tar file
Step 2: Open uwsgiconfig.py and import platform then replace os.uname()[index] with platform.uname()[index]
Change
uwsgi_os = os.uname()[0]
uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]
To
import platform
uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]', platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]
Step 3: Run python setup.py install
Note: You may need to install GCC and configure it.