I am trying to come out with a small python script to monitor the battery state of my ubuntu laptop and sound alerts if it’s not charging as well as do other stuff (such as suspend etc). I really don’t know where to start, and would like to know if there is any library for python i can use. Any
Tag: linux
Disable webcam’s Autofocus in Linux
I’m working in embebed system in the beagleboard. The source code is in Python, but I import libraries from OpenCV to do image processing. Actually, I’m using the webcam Logitech c910, it’s a excellent camera but it has autofocus. I would like to know if I can disable the autofocus from Pyth…
Using cat command in Python for printing
In the Linux kernel, I can send a file to the printer using the following command From what I understand, this redirects the contents in file.txt into the printing location. I tried using the following command I thought this command would achieve the same thing, but it gave me a “Permission Denied”…
Why do up and down arrow commands not work in the Python command line interpreter?
I am using a VT100 terminal emulator on Linux. In bash, up and down arrows scroll through the last commands executed; they work as expected. Previous (up arrow) and next (down arrow) commands are not interpreted in the Python command line interpreter. What kind of key mappings do I need to make this work? Tha…
How to access the keys or values of Python GDB Value
I have a struct in GDB and want to run a script which examines this struct. In Python GDB you can easily access the struct via Now I got this variable called mystruct which is a GDB.Value object. And I can access all the members of the struct by simply using this object as a dictionary (likemystruct[‘me…
detecting bind mounts on linux
I am looking for a way to determine if a given path is a bind mount point (on linux). The standard techniques for detecting regular mount points don’t seem to work. Even the mountpoint command fails to detect bind mounts. Answer I’m not sure there is supposed to be a way to do that (except perhaps…
Pipe raw OpenCV images to FFmpeg
Here’s a fairly straightforward example of reading off a web cam using OpenCV’s python bindings: Now I want to pipe the output to ffmpeg as in: $ python capture.py | ffmpeg -f image2pipe -pix_fmt bgr8 -i – -s 640×480 foo.avi Sadly, I can’t get the ffmpeg magic incantation quite ri…
What is the correct way to make my PyQt application quit when killed from the console (Ctrl-C)?
What is the correct way to make my PyQt application quit when killed from the console (Ctrl-C)? Currently (I have done nothing special to handle unix signals), my PyQt application ignores SIGINT (Ctrl+C). I want it to behave nicely and quit when it is killed. How should I do that? Answer 17.4. signal — Set ha…
Python virtualenv questions
I’m using VirtualEnv on Windows XP. I’m wondering if I have my brain wrapped around it correctly: I ran virtualenv ENV and it created C:WINDOWSsystem32ENV. I then changed my PATH variable to include C:WINDOWSsystem32ENVScripts instead of C:Python27Scripts. Then, I checked out Django into C:WINDOWS…
How to call Wine dll from python on Linux?
I’m writing a python script in Linux, and need to call some Windows functions available in Wine. Specifically, AllocateAndInitializeSid and LookupAccountSidW, to determine who is logged in to a remote Windows computer. These functions are part of advapi32.dll in Wine (edit: using the answers, I was able…