Skip to content

Tag: python

How to prevent Python script from Force exit?

I am running a python script and trying to prevent from force exiting or print an error message or log that into the log file. I am already using logging.info(“”) for logging.. or just print for printing something.. but what or how do I create a method or function that can either do print or log w…

change date/time using python in linux

I tried using date command to change the system time in debian linux: os.system(“echo passwd | “sudo date -s “Thu Aug 9 21:31:26 UTC 2012”) and I set the python file permission to 777 and also chown as root. But it does not work and says date: cannot set date: Operation not permitted. …

s3cmd ImportError: No module named S3.Exceptions

Received an error after installing and trying to run s3cmd 1.0.0 This error came about after upgrading to the latest Amazon Linux distro 2015.03.0 Answer Looks like the error happened because python2.7 is now the default python version in the Amazon Linux 2015.03.0+ If you change python back to 2.6 and run s3…

Kill python thread using os

I’ve already asked similar question many times, but still can’t find appropriate solution. I have and external function, that could run in some cases very long. I want to interrupt it after, say, 30 seconds. How do I do that? Threads are good, but I can’t stope them (i don’t have acces…

segfault when using shout-python inside a thread

Recently a machine was upgraded/reinstalled from an older Ubuntu version to the most recent Debian version. Since then, I get a segfault in an application I wrote which sends data to an icecast daemon. After some searching, I focused it down to threading. As soon as I call shout.send from inside a thread, I g…

python: numpy runs script twice

when I import numpy to my python script, the script is executed twice. Can someone tell me how I can stop this, since everything in my script takes twice as long? Here’s an example: And the output is: So, is my script first executed with normal python and then with numpy again? Maybe I should say that I…