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 when it force exit?
Tag: python
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. Any Ideas? Thanks Answer Sudo doesn’t take
Python doesn’t find a directory using the home sign ~ [duplicate]
This question already has answers here: os.makedirs doesn’t understand “~” in my path (3 answers) Closed last month. I have created a small Python script to save directories in a side directory, under the current user. I am running on Mac but production is Ubuntu My problem is the it doesn’t manage to identify the dir with the home sign
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 s3cmd it should work without a problem After
VATIC Annotation Tool installation – “turkic setup –database” – unknown action setup
I’m trying to install VATIC Video Annotation Tool on Linux. I followed the instructions in README file twice, always failing to execute command: which gives these two error messages: Other turkic commands, e.g. turkic status –verify give the same error messages (for a given action name). I also noticed that source file ~/vatic/public/index.html contains links to stylesheets and scripts in
Python 3.4.3 subprocess.Popen get output of command without piping?
I am trying to assign the output of a command to a variable without the command thinking that it is being piped. The reason for this is that the command in question gives unformatted text as output if it is being piped, but it gives color formatted text if it is being run from the terminal. I need to get
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 access to external function’s code) Multiprocessing is also not
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 get a segfault. Below is a
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 have not
manipulate column fields for clean representation
Hi I have data in txt file in following format I want to only extract IP address and bytes field, so final result should be Also at the end i want to group by bytes (3rd column) by first field. to get : Any help ? thanks Answer If you want to consider awk: EDIT: Based on comments below: