unix

Using absolute unix paths in windows with python

Using absolute unix paths in windows with python Question: I’m creating an application that stores blob files into the hard drive, but this script must run in both linux and windows, the issue is that i want to give it an absolute path from the filesystem root and not one relative to the project files, …

Total answers: 4

How can I set the last modified time of a file from python?

How can I set the last modified time of a file from python? Question: I have a python script that downloads a file over FTP using ftplib. My current download code looks just like the example in the ftp lib docs: ftp.retrbinary(‘RETR README’, open(‘README’, ‘wb’).write) Now I have a requirement that the file downloaded over …

Total answers: 3

Pipe output from shell command to a python script

Pipe output from shell command to a python script Question: I want to run a mysql command and set the output of that to be a variable in my python script. Here is the shell command I’m trying to run: $ mysql my_database –html -e “select * from limbs” | ./script.py Here is the python …

Total answers: 7

Run python script with reduced permissions

Run python script with reduced permissions Question: I have to run some student-made code that they made as homework, I’m running this on my own computer (Mac OS), and I’m not entirely certain they won’t accidentally “rm -rf /” my machine. Is there an easy way to run their python scripts with reduced permissions, so …

Total answers: 3

How do I change directories using Paramiko?

How do I change directories using Paramiko? Question: Drush commands not executing using Paramiko I posted the above question regarding a persistent error message that I receive using Paramiko. I do not think it is related to my next question, but it might be. I can successfully connect to my server via SSH using Paramiko. …

Total answers: 4

Calling the "source" command from subprocess.Popen

Calling the "source" command from subprocess.Popen Question: I have a .sh script that I call with source the_script.sh. Calling this regularly is fine. However, I am trying to call it from my python script, through subprocess.Popen. Calling it from Popen, I am getting the following errors in the following two scenario calls: foo = subprocess.Popen(“source …

Total answers: 9

How do I run Selenium in Xvfb?

How do I run Selenium in Xvfb? Question: I’m on EC2 instance. So there is no GUI. $pip install selenium $sudo apt-get install firefox xvfb Then I do this: $Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & $DISPLAY=:1 java -jar selenium-server-standalone-2.0b3.jar 05:08:31.227 INFO – Java: Sun Microsystems Inc. 19.0-b09 05:08:31.229 INFO – OS: Linux 2.6.32-305-ec2 …

Total answers: 5

How do you set your pythonpath in an already-created virtualenv?

How do you set your pythonpath in an already-created virtualenv? Question: What file do I edit, and how? I created a virtual environment. Asked By: TIMEX || Source Answers: It’s already answered here -> Is my virtual environment (python) causing my PYTHONPATH to break? UNIX/LINUX Add “export PYTHONPATH=/usr/local/lib/python2.0” this to ~/.bashrc file and source it …

Total answers: 7