Available Count
int64
1
31
AnswerCount
int64
1
35
GUI and Desktop Applications
int64
0
1
Users Score
int64
-17
588
Q_Score
int64
0
6.79k
Python Basics and Environment
int64
0
1
Score
float64
-1
1.2
Networking and APIs
int64
0
1
Question
stringlengths
15
7.24k
Database and SQL
int64
0
1
Tags
stringlengths
6
76
CreationDate
stringlengths
23
23
System Administration and DevOps
int64
0
1
Q_Id
int64
469
38.2M
Answer
stringlengths
15
7k
Data Science and Machine Learning
int64
0
1
ViewCount
int64
13
1.88M
is_accepted
bool
2 classes
Web Development
int64
0
1
Other
int64
1
1
Title
stringlengths
15
142
A_Id
int64
518
72.2M
1
1
0
1
0
1
1.2
0
I have a Simulink block, accepting TCP/IP connections and reading the incoming data. The data has to be integers of type int32. Imagine we have a variable of any integer number in Python. We can convert the number to a string and send it via a tcp socket. So far no Problem. But how to convert the number to that kind of string, that my Simulink blocks receives the number in int32 format?
0
python,simulink
2013-10-16T16:44:00.000
0
19,409,095
In Matlab simulink, there is block named TCP/IP receive. after choosing this block, double click on it. You will see number of option regarding type of data that matlab receiving.
0
544
true
0
1
TCP/IP Message from Python to Simulink
22,297,932
1
2
0
0
0
0
1.2
0
I want to run Python script from PHP. The script's syntax is good, when I run it from command line it generates an image file next to it. When I run the PHP file (contains Python exec) from command line it generates an image file. It's good. The problem is: when I use browser and run PHP it isn't generate any image file. I use Xubuntu OS.
0
php,python
2013-10-16T19:04:00.000
0
19,411,652
The problem was the matplotlib backend setting. I changed to 'Agg' and the plot function worked fine.
0
408
true
0
1
Run Python script from PHP
19,448,302
1
2
0
1
0
1
0.099668
0
I've used Boost.Python to expose my class into Python. I want to change this class or override some parts of it in Python as well as what we can do on classes in Python by default.
0
c++,python,boost-python
2013-10-17T12:30:00.000
0
19,426,810
It sounds like you want to subclass, which would be the other answer provided; however if you are looking to change an objects class on-the-fly, you could use object.__class__ = NewClass -- though this may be considered EVIL in some (probably most) circles.
0
56
false
0
1
Expose a class to Python and change it in Python as well
19,427,479
1
2
0
1
0
0
1.2
0
We want to write our Webapps in Python for High-Traffic use (800 req/sec), but we don't know which Webserver and module are the best one. We actually think Apache2 + mod_wsgi is a good option, but maybe Apache2 + FastCGI or Nginx + mod_wsgi oder FastCGI could be better. Any Ideas?
0
python,web,nginx,apache2,webserver
2013-10-17T15:18:00.000
0
19,430,713
I would probably go with - Apache2(mod_wsgi) + Nginx(Proxy) . Where Nginx will be serving the static content and directing the dynamic content request to Apache2 server . This will improve the performance of your application .
0
227
true
1
1
Which Webserver shall i take for High-Traffic Python Web-Pages?
19,431,028
1
1
0
2
2
0
0.379949
0
I have a Python script that runs in several modes. One of those modes monitors certain files, and if those files have been modified, the script restores them. The way I do this is to run the script every minute via cron. Another cron job exists (actually the same script called with a different argument) to remove the script from the crontab when the scheduled time has elapsed. Initially, I was attempting to work with a crontab in /etc/cron.d. The script behaves as expected if executed on the command line, but does not edit the crontab when it is run from cron. I then switched to writing a temporary file and executing crontab tempfile (via subprocess.Popen) from the script. This doesn't work either, as the crontab is simply not created. Executing crontab tempfile from the commandline and using the temporary file created by the script works as expected. I can't use the python-crontab library as this is a commercial project and that library is GPLed. Are there any inherent limitations in cron that prevent either approach from working?
0
python,linux,ubuntu,cron
2013-10-17T22:07:00.000
1
19,438,160
The GPL is not anti-commercial. python-crontab can be used in commercial products and services. You must only follow the copy-left rules witch state that the actual code itself can't be made proprietary. You can sell it as much as you like, and as the author I encourage you to make money from my work. Besides that error, it doesn't look like your problem requires python-crontab anyway. You could just open the files yourself and if that doesn't work, it was never going to work with python-crontab anyway.
0
1,397
false
0
1
Modifying a crontab from a cron job
19,448,431
1
1
0
0
0
0
0
1
I wrote a program to login to a website and do some automatic stuff (by making HTTP requests). Most of these automatic stuff requires the program/session is in logged-in state (if the cookie expires, the program/session can not be considered in logged-in state), so I am implementing a isLoggedIn function to test it. My current approach to get a page only available after login, but this requires a HTTP request and the transfer of a web page, so it is not very fast, what are other possible solutions? Any lead will be appreciated! Thank you very much!
0
python,http,session,login,urllib2
2013-10-19T23:16:00.000
0
19,472,177
As you mentioned yourself, the logged-in state is most of the time determined by validity of specific cookie. You can check if the cookie is still valid by comparing it's expiry time with the current time. Alternatively you can make HEAD request which allows you to get cookies (and other headers) without the need to download page body. However you have to check if the site handles HEAD requests for this to work.
0
47
false
0
1
What is the fastest way to test whether logged in or not when use python to login to a website?
19,481,620
1
1
0
0
0
0
0
0
I want to use python-mode and jedi for autocompletion in Vim for python. However under my environment (vim 7.3 in terminal.app on OSX 10.8), I just cannot have the key-combination work. I read many related articles and knows that it is because terminal.app interpret as and I tried to use inoremap to change it but it does not work. Anyone has similar problem and figured out ideal solutions? Thx! (In macvim with Gui there is no such problem, but I'd prefer run vim in terminal. I tried iterm2 but it also suffers.)
0
macos,terminal-emulator,python-mode,jedi-vim
2013-10-20T02:48:00.000
1
19,473,378
Solved. I have "set paste" and it disabled all user-defined key mappings under insert mode. It didn't influence GUI macvim since pasted mode was unnecessary for GUI editors.
0
437
false
0
1
How to make work in terminal.app on mac?
19,501,157
1
2
0
2
1
1
1.2
0
So I created my own modified version of a program with the GPLv3, and it's open source and everything. My question is how am I supposed to state that I modified it? Do I just put in a comment saying # Modified by yentup ? I've tried researching about this topic but I haven't found any directions on how to do so.
0
python,python-2.7,licensing,gpl
2013-10-21T01:35:00.000
0
19,484,981
You have no requirement to say that you modified it at all - your only obligation is to offer the source code to anyone who uses your version. However the best solution for you, the original authors and future users is probably to have your changes put back into the main source tree, assuming that they would be useful to other users! At which point you the version history would mark your changes, you could also add your name in a comment if you wished.
0
685
true
0
1
Is there a formal way to state modifications of a program covered with GPL?
19,485,013
1
1
0
2
1
1
1.2
0
I'm looking for a simple way to extract text from excel/word/ppt files. The objective is to index contents in whoosh for search with haystack. There are some packages like xlrd and pandas that work for excel, but they go way beyond what I need, and I'm not really sure that they will actually just print the cell's unformatted text content straight from the box. Anybody knows of an easy way around this? My guess is ms office files must be xml-shaped. Thanks! A.
1
python,django-haystack,whoosh
2013-10-21T17:07:00.000
0
19,500,625
I've done this "by hand" before--as it turns out, .(doc|ppt|xls)x files are just zip files which contain .xml files with all of your content. So you can use zipfile and your favorite xml parser to read the contents if you can find no better tool to do it.
0
631
true
0
1
Extract text from ms office files with python
19,500,864
6
7
0
1
2
0
0.028564
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences. Select the "Behaviour" section. On the field titled "Executable text files", select the option "Execute executable text files when opened".
0
12,507
false
0
1
how to make python script executable when click on the file
22,898,338
6
7
0
2
2
0
0.057081
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
Add #!/usr/bin/env python at the very beginning of file. Make chmod u+x filename.py Change your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute.
0
12,507
false
0
1
how to make python script executable when click on the file
19,510,082
6
7
0
0
2
0
0
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
If you don't have any specific version requirement then using first line as #!/usr/bin/env python will be more efficient and give the execute permission chmod u+x test.py
0
12,507
false
0
1
how to make python script executable when click on the file
19,510,040
6
7
0
5
2
0
0.141893
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
Add #!/bin/python as the very first line of your file. Or, if you don't know where your python executable is, type which python in a terminal; then copy the result of that and put it after the #!. Change the permissions of the file so that its executable chmod u+x test.py i try but it still open back as gedit Right click on the file in your gnome file browser or desktop. Select Properties Go to Open with and choose Python. If you don't see python in the list, add the command. Just type python in the command to be added.
0
12,507
false
0
1
how to make python script executable when click on the file
19,509,956
6
7
0
0
2
0
0
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
I use raspibian os (Linux) Add #!/usr/bin/python as the first line of the file.py right click file >> open with >> chose customize >> custom command line >> type python3 execute file with double click is working
0
12,507
false
0
1
how to make python script executable when click on the file
55,925,012
6
7
0
0
2
0
0
0
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
0
python
2013-10-22T05:47:00.000
1
19,509,911
Add #!/usr/bin/python as the first line of the file and set the permission to executable chmod 755 yourfile.
0
12,507
false
0
1
how to make python script executable when click on the file
19,509,975
3
5
0
-8
15
0
-1
0
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
0
python,linux,ubuntu
2013-10-22T23:17:00.000
1
19,530,015
First create the file you want, with any editor like vi r gedit. And save with. Py extension.In that the first line should be !/usr/bin/env python
0
205,865
false
0
1
How to run python script on terminal (ubuntu)?
28,650,632
3
5
0
0
15
0
0
0
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
0
python,linux,ubuntu
2013-10-22T23:17:00.000
1
19,530,015
Save your python file in a spot where you will be able to find it again. Then navigate to that spot using the command line (cd /home/[profile]/spot/you/saved/file) or go to that location with the file browser. If you use the latter, right click and select "Open In Terminal." When the terminal opens, type "sudo chmod +x Yourfilename." After entering your password, type "python ./Yourfilename" which will open your python file in the command line. Hope this helps! Running Linux Mint
0
205,865
false
0
1
How to run python script on terminal (ubuntu)?
42,282,440
3
5
0
0
15
0
0
0
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
0
python,linux,ubuntu
2013-10-22T23:17:00.000
1
19,530,015
Sorry, Im a newbie myself and I had this issue: ./hello.py: line 1: syntax error near unexpected token "Hello World"' ./hello.py: line 1:print("Hello World")' I added the file header for the python 'deal' as #!/usr/bin/python Then simple executed the program with './hello.py'
0
205,865
false
0
1
How to run python script on terminal (ubuntu)?
61,037,599
1
4
0
2
1
1
0.099668
0
I've heard about the PYTHONSTARTUP file as a way to automatically load specified modules and other code when starting python. But PYTHONSTARTUP is a global thing, for all instances of python. Is there such a thing as PYTHONSTARTUP that I can place in a specific directory and runs only when I start python in that directory?
0
python
2013-10-23T06:20:00.000
0
19,534,230
This sounds like you want to use virtualenv. It's a tool for creating isolated python environments with hooks for individual settings. Just put them in the bin/activate of your virtualenv.
0
2,921
false
0
1
A PYTHONSTARTUP file for a specific directory
19,534,829
1
1
0
2
1
0
1.2
0
Using HttpUwsgiModule with NGINX to control uWSGI has become quite popular since its release. I was wondering though, what is the advantage of it, compared to using NGINX as a reverse-proxy to uWSGI application? What are the gains and losses in two differing use cases?
0
python,nginx,webserver,reverse-proxy,uwsgi
2013-10-24T15:42:00.000
1
19,570,490
Simply put, when you use HttpUwsgiModule NGINX speaks the uwsgi protocol and it can leave out useless informations of the http protocol leading to less overhead and thus better performance.
0
125
true
1
1
What is the difference between using HttpUwsgiModule for NGINX and using NGINX as a reverseproxy to uWSGI?
19,688,569
1
1
0
8
4
0
1.2
0
I work on a machine per ssh where I run ipython for interactive work. Can I start a long-running Python function from IPython, sever the ssh connection and log back in later into the IPython session to observe the result?
0
python,shell,ssh,ipython
2013-10-24T18:53:00.000
0
19,574,210
Yes. Use screen, tmux (superior), or similar software. Both use the concept of sessions that you attach to and detach from. With tmux: Run tmux and then ipython. When you're finished, <Ctrl+b> d to detach. You're back in the normal shell. When you come back, tmux attach will take you back to ipython. Using screen, the commands are screen, <Ctrl+a> <Ctrl+d> and screen -r.
0
467
true
0
1
Is it possible to start an IPython session via ssh and log back in later?
19,574,232
1
3
0
2
3
0
0.132549
0
I need to run a python code that takes several hours and my computer disconnects from the ssh after a certain amount of inactive time. I have tried python test.py > output.txt & but my output file is empty. However, the python code "test" is still running after I log off and log back in to the ssh. I also tried python -u test.py > output.txt & which does write to the output.txt but it does not continue after the ssh connection is lost. I am very new to Linux so I do not know very many commands. I need the simplest/easiest to understand method. Thanks!
0
python,linux,background,ssh
2013-10-24T23:15:00.000
1
19,578,392
You can use screen, as Robin Krahl recommended, or you can just run your command with nohup, which suppresses the SIGHUP (hangup) signal from your SSH session disconnecting. nohup "python -u test.py > output.txt" &
0
183
false
0
1
Running python code in background
19,578,445
1
1
0
0
0
0
0
0
This goes out to anyone who is well versed in the Eclipse IDE and or PyDev perspective plug-in who is willing to offer some technical support. I am trying to write a python module that must take in arguments from the command prompt with sys.argv function calls. Rather than printing out the correct output when I enter E:\ ... \src>program.py arg1 arg2, all that happens is a new command line (E:\ ... \src>) is output and the Eclipse IDE window flashes orange without any code in my python module actually being executed. Also, if I close the Eclipse IDE and try to run program.py, it will just open Eclipse again and open my program in a new tab. I'm confused as to why it is not working now when just last week it was working perfectly while testing another program that took in arguments from the command prompt by sys.argv function calls. My question for everyone is whether or not you are aware of any settings that may have been altered by updates, etc. that could cause this problem; or has anybody out there ever run into this problem and figured out how to resolve it? I have already checked my PATH variable, so that is not the problem :-(. Any help you can provide would be greatly appreciated ... thank you. OS: Windows 8.1 Pro / Eclipse ver.: Kepler (4.3) / Python ver.: 3.3.2
0
eclipse,python-3.x,command-line-arguments,pydev,windows-8.1
2013-10-26T21:42:00.000
1
19,612,221
I answered my own question in the comment above. I just had to wait to post an answer due to the fact that I just created a stackoverflow account yesterday.
0
213
false
0
1
Python module will not run correctly from command prompt
19,624,100
2
3
0
0
1
0
1.2
0
I have a VPS with system-wide installed python 2.5. I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running. But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5. In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version? Thanks!
0
python,apache,unix,path,fastcgi
2013-10-28T05:30:00.000
1
19,627,743
I had a call to python interpreter via env program in my fast cgi dispatch script. When I explicitly put path to 2.7 to the first line of the script it works as expected.
0
137
true
1
1
Issue with path to python/pythonpath
19,962,347
2
3
0
0
1
0
0
0
I have a VPS with system-wide installed python 2.5. I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running. But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5. In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version? Thanks!
0
python,apache,unix,path,fastcgi
2013-10-28T05:30:00.000
1
19,627,743
I've set PYTHONPATH in my /home/me/.bashrc and all worked ok from terminal, but when Apache w/ mod_wsgi starts my python scripts, it acts under sysem or dedicated user, which knows nothing of my .bashrc. For this particular situation, I just used apache config (apache2.conf) to set python path for apache (WSGIPythonPath option).
0
137
false
1
1
Issue with path to python/pythonpath
27,295,744
1
1
0
2
2
0
0.379949
0
Following the tutorial, I have built the authentication system using Auth. APIs of Pyramid. I would like to learn how to introduce two things (tick boxes) to the login though: Remember my name Remember my password How can I achieve this? What do I need to do? Thank you.
0
python,authentication,python-2.7,authorization,pyramid
2013-10-28T10:45:00.000
0
19,632,667
if you are using the cookies based authenticate, then you can also save the user name into the cookies. For password, I am not sure it is a good idea to save it in client side. I think the better way is to use authenticated_userid to identity the user and return whatever necessary to the request.
0
135
false
0
1
Intoducing "remember my name" and "remember my password" options to Pyramid's Authentication
19,646,493
1
2
0
1
0
1
0.099668
0
I see from other discussions that reload is considered an unnecessary operation and a bad way to develop programmes. People say to use doctest and unittest. I must be missing something. To develop a programme I write it in a module, load the module into an eclipse console, experiment in the console by running little samples of code, then I spot an error in the module or decide to change something. Surely the quickest thing to do is save the module, reload it and carry on working in the console. Is there a better way?
0
python
2013-10-30T11:04:00.000
0
19,680,487
Basically instead of trying things out in the console, try things out by writing tests. It's almost the same amount of typing, but repeatable (you can check if things still work after you make changes) and it works as a rudimentary form of documentation.
0
119
false
0
1
Best way to develop a programme without using reload
19,684,314
1
1
0
1
1
0
1.2
0
I had PyQt4 running fine with python2 on Ubuntu 12.04. I then installed python-PySide. But the installation test would give me a module not found error. Then I installed python3-PySide and it works fine. So obviously something to do with my environment paths, but I'm not sure what I need to do. I'm guessing PySide is automatically checking if python3 exists and if it does then it'll use it regardless. I need PySide to work with python2.7 because of Qt4.8 compatibility issues. Any suggestions? some info about my system: which python /usr/bin/local/python which python3 /usr/bin/python3 EDIT: More details about installation test. After installation, I bring up the python console and try import PySide, as follows: python import PySide ImportError: No module name PySide But it works fine for python3: python3 import PySide PySide.version '1.1.2'
0
python,ubuntu,python-2.7,python-3.x,pyside
2013-10-31T01:40:00.000
1
19,696,973
You have two independent Python 2.7 installations, one in /usr and one in /usr/local. (And that's on top of the Python 3.x installation you also have.) This is bound to cause confusion, especially for novices. And it has caused exactly the kind of consuion it was bound to cause. You've installed PySide into the /usr installation, so it ended up in /usr/lib/python2.7/dist-packages. If you run /usr/bin/python, that import PySide will probably work fine. (If not, see below.) But the default thing called python and python2.7 on your PATH is the /usr/local installation, hence which python says /usr/local/bin/python, so it can't see PySide at all. So you need to get it installed for the other Python as well. Unless you know that you need a second Python 2.7 in /usr/local for some reason, the simplest thing to do would be to scrap it. Don't uninstall it and reinstall it; just uninstall it. You've already got a Python 2.7 in /usr, and you don't need two of them. If you really need to get PySide working with the second 2.7… Since you still haven't explained how you've been installing PySide despite being asked repeatedly, I can't tell you exactly how to do that. But generally, the key is to make sure to use explicit paths for all Python programs (python itself, python-config, pip, easy_install, etc.) that you have to run. For example, if the docs or blog or voices in your head tell you to run easy_install at some step, run /usr/local/bin/easy_install instead. If there is no such program, then you need to install that. The fact that you already have /usr/bin/easy_install doesn't help—in fact, it hurts. If you can get rid of the second Python, but that doesn't fix PySide yet, uninstall, rebuild, and reinstall PySide. Or, even simpler… PySide has pre-made, working binary Ubuntu packages for all of the major Python versions that have Ubuntu packages. Just install it that way.
0
1,553
true
0
1
Ubuntu - PySide module not found for python2 but works fine for python3
19,697,689
1
2
0
0
0
0
1.2
0
I'm new to all things programming, but am trying to build up some functionality for my team. I have a script in python that performs some useful analysis, and now I need it to communicate to a PHP script that I usually call from the command line with an argument that is a text file, which the script parses and operates on line by line. What I'm trying to do is pass to the script in the CLI a list variable from Python. Is the best way to do this to write the list to a text file on my server and then call the script with subprocess from Python or is there a more streamlined way to make this happen?
0
php,python,bash,command-line-interface
2013-10-31T03:52:00.000
1
19,698,151
Writing the data out to a text file in python and then loading that text file in php is definitely the easiest way. If you're willing to modify the php script, you could make it read the data from stdin, and set up a pipe between the two processes, but this going to be a little trickier.
0
74
true
0
1
Can I pass a list from python to a php script that usually takes a .txt file line-by-line to operate on?
19,698,635
2
2
0
0
3
1
0
0
I have to archive a large amount of data off of CDs and DVDs, and I thought it was an interesting problem that people might have useful input on. Here's the setup: The script will be running on multiple boxes on multiple platforms, so I thought python would be the best language to use. If the logic creates a bottleneck, any other language works. We need to archive ~1000 CDs and ~500 DVDs, so speed is a critical issue The data is very valuable, so verification would be useful The discs are pretty old, so a lot of them will be hard or impossible to read Right now, I was planning on using shutil.copytree to dump the files into a directory, and compare file trees and sizes. Maybe throw in a quick hash, although that will probably slow things down too much. So my specific questions are: What is the fastest way to copy files off a slow medium like CD/DVDs? (or does the method even matter) Any suggestions of how to deal with potentially failing discs? How do you detect discs that have issues?
0
python,backup,archive,cd,dvd
2013-10-31T21:56:00.000
0
19,717,288
Writing your own backup system is not fun. Have you considered looking at ready-to-use backup solutions? There are plenty, many free ones... If you are still bound to write your own... Answering your specific questions: With CD/DVD you first typically have to master the image (using a tool like mkisofs), then write image to the medium. There are tools that wrap both operations for you (genisofs I believe) but this is typically the process. To verify the backup quality, you'll have to read back all written files (by mounting a newly written CD) and compare their checksums against those of the original files. In order to do incremental backups, you'll have to keep archives of checksums for each file you save (with backup date etc).
0
1,815
false
0
1
What is the best way to archive a data CD/DVD in python?
19,717,555
2
2
0
1
3
1
1.2
0
I have to archive a large amount of data off of CDs and DVDs, and I thought it was an interesting problem that people might have useful input on. Here's the setup: The script will be running on multiple boxes on multiple platforms, so I thought python would be the best language to use. If the logic creates a bottleneck, any other language works. We need to archive ~1000 CDs and ~500 DVDs, so speed is a critical issue The data is very valuable, so verification would be useful The discs are pretty old, so a lot of them will be hard or impossible to read Right now, I was planning on using shutil.copytree to dump the files into a directory, and compare file trees and sizes. Maybe throw in a quick hash, although that will probably slow things down too much. So my specific questions are: What is the fastest way to copy files off a slow medium like CD/DVDs? (or does the method even matter) Any suggestions of how to deal with potentially failing discs? How do you detect discs that have issues?
0
python,backup,archive,cd,dvd
2013-10-31T21:56:00.000
0
19,717,288
When you read file by file, you're seeking randomly around the disc, which is a lot slower than a bulk transfer of contiguous data. And, since the fastest CD drives are several dozen times slower than the slowest hard drives (and that's not even counting the speed hit for doing multiple reads on each bad sector for error correction), you want to get the data off the CD as soon as possible. Also, of course, having an archive as a .iso file or similar means that, if you improve your software later, you can re-scan the filesystem without needing to dig out the CD again (which may have further degraded in storage). Meanwhile, trying to recovering damaged CDs, and damaged filesystems, is a lot more complicated than you'd expect. So, here's what I'd do: Block-copy the discs directly to .iso files (whether in Python, or with dd), and log all the ones that fail. Hash the .iso files, not the filesystems. If you really need to hash the filesystems, keep in mind that the common optimization of compression the data before hashing (that is, tar czf - | shasum instead of just tar cf - | shasum) usually slows things down, even for easily-compressable data—but you might as well test it both ways on a couple discs. If you need your verification to be legally useful you may have to use a timestamped signature provided by an online service, instead, in which case compressing probably will be worthwhile. For each successful .iso file, mount it and use basic file copy operations (whether in Python, or with standard Unix tools), and again log all the ones that fail. Get a free or commercial CD recovery tool like IsoBuster (not an endorsement, just the first one that came up in a search, although I have used it successfully before) and use it to manually recover all of the damaged discs. You can do a lot of this work in parallel—when each block copy finishes, kick off the filesystem dump in the background while you're block-copying the next drive. Finally, if you've got 1500 discs to recover, you might want to invest in a DVD jukebox or auto-loader. I'm guessing new ones are still pretty expensive, but there must be people out there selling older ones for a lot cheaper. (From a quick search online, the first thing that came up was $2500 new and $240 used…)
0
1,815
true
0
1
What is the best way to archive a data CD/DVD in python?
19,775,252
1
2
0
0
1
0
0
0
i have this necessity and i would like to know if it's possible to acomplish: I want to put part from my python code inside a WebServer. And, only after a authentication process, the user who is executing my script, will be able to read a file that is in my WebServer and use that content to execute it as part of script. Is there any function in Python that can read a text from file as a variable and execute that code as if it was written inside the script?
0
python,python-2.7
2013-11-01T23:30:00.000
0
19,737,084
Your approach must be a quite bad practice. But you can do for example: exec 'print 1 + 2'
0
6,263
false
0
1
Execute a code read from file
19,737,140
1
1
0
2
0
0
0.379949
0
Is there a way to modify PYTHONPATH automatically whenever I cd into a directory. I usually have multiple projects on my workstation, and whenever I am in one of those directories, I want that projects' src/ to override other src directories in PYTHONPATH.
0
python
2013-11-02T02:32:00.000
0
19,738,373
Have you tried adding './src' to the PYTHONPATH ahead of the other paths that you want to "override"? That ought to work. (Haven't tried it with Python, but most "path" lists allow relative paths to be used.)
0
54
false
0
1
Modify PYTHONPATH automatically
19,738,662
1
2
0
1
0
1
0.099668
0
I am looking to run a file I created in python from a matlab script. I have checked that my python file works if I run it from the python interface. However I have not been able to get my python to run from matlab. The following is the code situation I am in. In matlab., I have the following code:(My file name is pgcode.py) ! python pgcode.py and interchangeably I have use this code as well: system('python pgcode.py') The error that results in matlab is: "python: can't open file 'pgcode.py': [Errno 2] No such file or directory" I have set my PATH directory and I really think this is an issue with setting the path so that I can find the file I have created but I haven't been able to figure out how to do this. I am using windows and Python 2.7.5. Any help is much appreciated. Thanks in advance!
0
python,matlab,python-2.7,path,directory
2013-11-04T03:47:00.000
0
19,761,351
Your $PATH should control where python comes from, but I don't believe it will control where your pgcode.py comes from - at least, not in the way you're using it now. You might want to either use a #!/usr/bin/env python and make your script executable, or be very mindful of what directory you're in when you try to python pgcode.py (you can prepend "pwd;" to your python command to see), or specify a full path to pgcode.py. HTH
0
746
false
0
1
Run Python file from matlab .m file
19,761,894
1
2
0
2
0
0
1.2
1
I'm developing a python script and I need to find the fastest way for getting a JSON from remote server. Currently I'm using requests module, but still requesting JSON is the slowest part of the script. So, what is the fastest way for python HTTP GET request? Thanks for any answer.
0
python,http,get,httprequest
2013-11-05T16:08:00.000
0
19,793,448
Write a C module that does everything. Or fire up a profiler to find out in which part of the code the time is spent exactly and then fix that. Just as guideline: Python should be faster than the network, so the HTTP request code probably isn't your problem. My guess is that you do something wrong but since you don't provide us with any information (like the code you wrote), we can't help you.
0
2,147
true
0
1
Fastest way for python HTTP GET request
19,793,524
1
1
0
2
1
1
1.2
0
Is there a standard method to check if all functions of all files that are included in a test have a testcase? So if I have script_1.py, script_2.py and script_3.py with corresponding test_script_1.py, test_script_2.py and test_script_3.py, how can I check that every function in script_x.py gets called at least ones by the test scripts? I wrote the test functions in the format def test<Name_of_function>_<test_condition> so for example the function def sum(a, b) has test functions def testSum_valid_input and def testSum_invalid_input, so I could write a script that gets all the function names from the test scripts and compare that to the functions in the tested scripts, but I am hoping that there is already an easy way to do this.
0
python,unit-testing
2013-11-06T12:06:00.000
0
19,811,702
The best way is probably to use a coverage tool. It will tell you how much of your code is called at least one time by a test.
0
52
true
0
1
How to check that all functions have a test case?
19,811,744
1
2
0
1
5
0
0.099668
0
I'm new on Raspberry Pi and I would to know how can we simulate/mock the sensors (or GPIO) so I can test just my python code, mocking the Highs and Lows of the pins? Thanks in advance!
0
python,mocking,simulation,raspberry-pi,gpio
2013-11-11T18:17:00.000
0
19,913,092
IF you just don't want to trust a software layer, you could try manually setting the pin high: The GPIO pins on the Raspberry Pi work with a voltage of 3.3VDC. Pins 1 & 17 on the P1-GPIO header outputs 3.3VDC. You could CAREFULLY try to connect a jumper from Pin 1 or 17 to the GPIO input pin you want to test. Connect it to test high, disconnect to test for low. MAKE SURE YOU DON"T USE THE 5VDC GPIO PINS, YOU COULD/WILL DAMAGE/KILL YOUR PI!
0
6,042
false
0
1
Simulate Raspberry Pi GPIO signal
25,086,750
1
1
0
0
3
0
0
0
Is there an easy way to use PyMC's MCMC algorithms to efficiently sample a parameter space for a frequentists analysis? I'm not interested in the point density (for Bayesian analysis), but rather want a fast and efficient way to sample a multidimensional parameter space, so I would like to trace all tested points (i.e. in particular also the rejected points), while recurring points need to be saved only once in the trace. I would be grateful for any helpful comments. Btw, thanks for developing PyMC, it is a great package!
0
python,pymc
2013-11-11T18:38:00.000
0
19,913,421
You can create custom StepMethods to perform any kind of sampling you like. See the docs for how to create your own.
1
155
false
0
1
Using MCMC from PyMC as an efficient sampler for frequentist analysis?
19,960,199
1
4
0
0
65
1
0
0
I am trying to understand how Python works (because I use it all the time!). To my understanding, when you run something like python script.py, the script is converted to bytecode and then the interpreter/VM/CPython–really just a C Program–reads in the python bytecode and executes the program accordingly. How is this bytecode read in? Is it similar to how a text file is read in C? I am unsure how the Python code is converted to machine code. Is it the case that the Python interpreter (the python command in the CLI) is really just a precompiled C program that is already converted to machine code and then the python bytecode files are just put through that program? In other words, is my Python program never actually converted into machine code? Is the python interpreter already in machine code, so my script never has to be?
0
python,cpython,python-internals
2013-11-11T21:53:00.000
1
19,916,729
When we run the python programs: 1_python source code compile with Cpython to the bytecode (bytecode is the binary file with .pyc format which seralize with marshal and it is set of stack structures that solve with pvm) 2_then the pvm (python virtual machine/python interpreter) is stackbase machine (the machine which solve task with stack data structure) which loop inside bytecode line by line and execute it. What executes the bytecode? The bytecode tells the Python interpreter which C code to execute.
0
14,342
false
0
1
How exactly is Python Bytecode Run in CPython?
70,165,436
1
1
0
2
2
0
1.2
0
We want to use continuous deployment. We have: all sources (python) in a local RhodeCode (git) server. Jenkins for automated testing SSH connections to the production systems (linux). a tool which can update servers in one command. Now something like this should be implemented: run tests with Jenkins if there is a failure. Stop, mail developers If all tests are OK: deploy We are long enough in the business to write some scripts to do this. My questions: How to you update the version numbers? You could increment them, you could use a timestamp ... Since we already use Jenkins, I think we do it in a script called by Jenkins. Any reason to do it with a different (better) tool? My fear: Jenkins becomes a central server for things which are not related to testing (deploy). I think other tools like SaltStack or Ansible should be used for this. Up to now we use Fabric (simple layer above ssh). Maybe we should switch to a central management system before starting with continuous deployment.
0
python,jenkins,continuous-integration,continuous-deployment
2013-11-12T10:32:00.000
1
19,926,738
Since we already use Jenkins, I think we do it in a script called by Jenkins. Any reason to do it with a different (better) tool? To answer your question: No, there aren't any big reasons to not go with Jenkins for deployment. Pros: You already know Jenkins (and you probably know some of the quirks) You don't need to introduce yet another technology You said that you want to write scripts called by Jenkins, so you can switch easily to a different system later. Cons: there might be better tools out there for deployment Does not tie the best with Change Control tools. Additional Considerations: Do not use the same server for prod deployment and continuous build/integration. These are two different tasks performed by two different roles. Therefore two different permission schemes might be employed. Use permissions wisely. I use two different permissions for my deploy and CI servers. We have 3 Jenkins servers right now. CI and deploy to uncontrolled environments (Developers can play with these environments) Deploy to controlled environments. (QA environemnts and upwards) Deploy to prod (yes, that's the only purpose in live of this server.) with the most restrictive permission scheme. sandbox, actually there is this forth server for Jenkins admins to play with. Store your deployable artifacts outside of Jenkins (and you do if I read your question correctly). So depending on your existing infrastructure and procedure you decide for the tooling. Jenkins won't log you in as long as you keep as much of the logic as possible in scripts that are only executed by Jenkins.
0
1,215
true
0
1
Continuous Deployment: Version Numbering and Jenkins for Deployment?
19,932,927
1
1
0
0
2
0
0
0
I currently need to use a script that requires python and PHP to output the same random numbers given a seed. Is there any RNG that can let them do this? When I use mt_rand and mt_srand and python's default rng (which is supposed to be mersenne twist) with the same seed I get different results.
0
php,python
2013-11-13T01:22:00.000
0
19,943,476
There is absolutely no requirement than Python and PHP (or any other language) should generate the same random number for the same seed.
0
130
false
0
1
Python and PHP not returning the same results for a similiarly seeded RNG
19,951,713
1
2
0
0
0
0
1.2
1
I am using twiiter streaming api and twython module with python 2.7 windows 7 os. I want to click a button and streaming of tweets should start. and on clicking the streaming should stop.I am using python for backend and HTML on front end.I am communicating to python via php using passthru function.when i am giving an ajax call to php on clicking of button then all the tweets is displayed at a time. I want streaming.Can anyone help?Thanks
0
php,python,ajax,twitter,streaming
2013-11-13T05:41:00.000
0
19,946,192
I am using twython and using long polling technique for displaying the streams.
0
225
true
1
1
Streaming Tweets Via Python
22,292,555
1
1
0
1
0
0
1.2
0
I know there exists a plugin for nginx to load the config through perl. I was wondering, does anyone have any experience doing this without using a plugin? Possibly a fuse-backed Python script that queries a DB? I would really like to not use the perl plugin, as it doesn't seem that stable.
1
python,sql,configuration,nginx,fuse
2013-11-13T15:23:00.000
0
19,957,613
I haven't seen any working solution to solve your task, a quick google search doesn't give any useful information either (it doesn't look like HttpPerlModule could help with DB stored configuration). It sounds like it's a good task to develop and contribute to Nginx project !
0
722
true
0
1
Running Nginx with a database-backed config file
20,018,813
1
1
0
3
1
0
0.53705
1
I have a python script which reads all tweets about a specific sporting event and enters them into a database. While I was running it this weekend every time a big event occurred in the game the script would stop and I would get an error. It said it was with the code but I don't believe that is the case. I found this on Twitter's api site: "Falling behind Clients which are unable to process messages fast enough will be disconnected. A way to track whether your client is falling behind is to compare the timestamp of the Tweets you receive with the current time. If the difference between the timestamps increases over time, then the client is not processing Tweets as fast as they are being delivered. Another way to receive notifications that a client is falling behind is to pass the stall_warnings parameter when establishing the streaming connection." and I was wondering if this is whats happening to me and what would be the best way to implement a solution.
0
python,twitter,tweepy
2013-11-13T17:11:00.000
0
19,960,086
As straming API creates a permanent connection, Falling behind technically means that tweets are put in this connection faster than consumed by your client. Solution is straightforward, you have to process tweets faster, that is optimize your landscape. There must be a bottleneck/bottlenecks, identify them and handle properly. For example, it might be database latency, when your db can not process sufficient inserts per second, IO latency, when data cant be stored to disk as fast as needed; code inefficiency; high CPU load; network bandwidth bound etc. No silver bullet for all cases, but some obvious steps include: storing received from Twitter data as is, and do post-processing in windows of lower load; deploy of a cluster with several tweets consumers (processors) and data sharding; usage of faster disks/some raid configuration can speed-up IO; tweet query optimisation, making sure to request and process least amount of tweets possible; code optimisation; migration to a datacenter with higher bandwith;
0
599
false
0
1
Tweepy streaming API falling behind
19,960,645
1
2
0
0
0
0
0
0
I am using django_discover_jenkins module for generating jenkins reports as a part of unit test runs. Has anyone used this before and found it to be slower? The coverage tasks slow this down considerably. How do I remove coverage task from the django_discover_jenkins task set without editing the settings file.
0
python,django,jenkins
2013-11-13T18:58:00.000
0
19,962,129
Check the latest version of original django-jenkins library. It has same unit test discovery method and coverage disabled by default. Coverage could be enabled with --enable-coverage command line option.
0
560
false
1
1
Django Jenkins Test runner - Slow
25,029,569
1
2
0
1
0
1
0.099668
0
How do I see what is the version of the python-mosquitto package used by my program? How do I find an old version of python-mosquitto (version 0.15) and remove it? I'm running on Raspberry Pi, raspian
0
python,raspberry-pi,mqtt,mosquitto
2013-11-14T10:28:00.000
0
19,975,234
If you are using pip, use pip freeze | grep 'python-mosquitto' to get the package version, and pip remove python-mosquitto to remove it.
0
3,471
false
0
1
how to find python-mosquitto version
19,975,285
1
1
0
1
0
0
1.2
0
I have been looking at setting up a web server to use Python and I have installed Apache 2.2.22 on Debian 7 Wheezy with mod_wsgi. I have gotten the initial page up and going and the Apache will display the contents of the wsgi file that I have in my directory. However, I have been researching on how to deploy a Python application and I have to admin, I find some of it a little confusing. I am coming from a background in PHP where it is literally install what you need and you are up and running and PHP is processing the way it should be. Is this the same with Python? I can't seem to get anything to process outside of the wsgi file that I have setup. I can't import anything from other files without the server throwing a "500" error. I have looked on Google and Bing to try to find an answer to this, but I can't seem to find anything, or don't know that what I have been looking at is the answer. I really appreciate any help that you guys can offer. Thanks in advance! (If I need to post any coding, I can do that, I just don't know what you guys would need, if anything, as far as coding examples for this...)
0
python,apache2,mod-wsgi
2013-11-15T02:13:00.000
0
19,992,294
Python is different from PHP in that PHP executes your entire program separately for each hit to your website, whereas Python runs "worker processes" that stay resident in memory. You need some sort of web framework to do this work for you (you could write your own, but using someone else's framework makes it much easier). Flask is an example of a light one; Django is an example of a very heavy one. Pick one and follow that framework's instructions, or look for tutorials for that framework. Since the frameworks differ, most practical documentation on handling web services with Python are focused around a framework instead of just around the language itself. Nearly any python web framework will have a development server that you can run locally, so you don't need to worry about deploying yet. When you are ready to deploy, Apache will work, although it's usually easier and better to use Gunicorn or another python-specific webserver, and then if you need more webserver functionality, set up nginx or Apache as a reverse proxy. Apache is a very heavy application to use for nothing but wsgi functionality. You also have the option of deploying to a PaaS service like Heroku (free for development work, costs money for production applications) which will handle a lot of sysadmin work for you. As an aside, if you're not using virtualenv to set up your Python environment, you should look into it. It will make it much easier to keep track of what you have installed, to install new packages, and to isolate an environment so you can work on multiple projects on the same computer.
0
203
true
1
1
Python Web Server - mod_wsgi
19,992,498
2
3
0
2
0
0
0.132549
0
What kind of server configurations would I need to do in order to run a Python + Pygame code on a website. Is php able to call and execute the python on server side? Do I need to install python on the server? I believe python is installed, but do I need to install the pygame library? What if I compile my code, will I need to install pygame on the server after that? Can some one provide me a general list of things I will need to complete in order to make this happen? My case: I would like to put a game I made with Python on a website. I see how the python can run on the server no problem, but how can I ensure the client be able to play the game on their browser?
0
php,python,pygame
2013-11-16T22:54:00.000
0
20,024,964
Web Browser can display/run HTML+JavaScript+SVG+(HTML)Canvas or (Adobe) Flash. You can't use PyGame to create game running on page. PyGame doesn't generate HTML+JavaScript or Flash
0
289
false
0
1
Is it possible to run Python code on an Apache server
20,025,212
2
3
0
-2
0
0
-0.132549
0
What kind of server configurations would I need to do in order to run a Python + Pygame code on a website. Is php able to call and execute the python on server side? Do I need to install python on the server? I believe python is installed, but do I need to install the pygame library? What if I compile my code, will I need to install pygame on the server after that? Can some one provide me a general list of things I will need to complete in order to make this happen? My case: I would like to put a game I made with Python on a website. I see how the python can run on the server no problem, but how can I ensure the client be able to play the game on their browser?
0
php,python,pygame
2013-11-16T22:54:00.000
0
20,024,964
Yes, there is a mod like mod_php... The extension of files are .psp Python server pages
0
289
false
0
1
Is it possible to run Python code on an Apache server
20,025,127
2
5
0
0
10
1
0
0
Is it feasible to script in a Lisp, as opposed to Ruby/Python/Perl/(insert accepted scripting language)? By this I mean do things like file processing (open a text file, count the number of words, return the nth line), string processing (reverse, split, slice, remove punctuation), prototyping/quick computations, and other things you would normally use Python, etc. for. How productive would doing such tasks in a Lisp be, as opposed to Ruby/Python/Perl/scripting language of choice? I ask because I want to learn a Lisp but also use it to do something instead of only learning it for the sake of it. I looked around, but couldn't find much information about scripting in a Lisp. If it is feasible, what would be a good implementation? Thank you!
0
python,ruby,scripting,scheme,lisp
2013-11-18T07:49:00.000
0
20,042,607
WRT to your tasks, what about using Emacs, which comes with an interactive Python-shell. So you have the convenience of editing alongside with running scripts.
0
8,065
false
0
1
Is it feasible to use Lisp/Scheme as a scripting language?
20,050,698
2
5
0
1
10
1
0.039979
0
Is it feasible to script in a Lisp, as opposed to Ruby/Python/Perl/(insert accepted scripting language)? By this I mean do things like file processing (open a text file, count the number of words, return the nth line), string processing (reverse, split, slice, remove punctuation), prototyping/quick computations, and other things you would normally use Python, etc. for. How productive would doing such tasks in a Lisp be, as opposed to Ruby/Python/Perl/scripting language of choice? I ask because I want to learn a Lisp but also use it to do something instead of only learning it for the sake of it. I looked around, but couldn't find much information about scripting in a Lisp. If it is feasible, what would be a good implementation? Thank you!
0
python,ruby,scripting,scheme,lisp
2013-11-18T07:49:00.000
0
20,042,607
I'd say that Lisp/Scheme could be used to write small scripts or big application. But they are not yet ready for wide use. The big difference between python/ruby and scheme is that python has a huge library of modules centralized in one place. Ruby is quite similar to python with ruby gems. Scheme on the other hand might have a small library of modules scattered accross the internet. The quality of modules doesn't always compare to the popular modules in python and ruby. One could say that they are aiming at different goal but I'd say scheme just got old and people started to forget about it and how it could be used as a tool instead of just a school subject. About Lisp, I can't really say. But from your description, it's possible to write scripts that you'd like to write but if you need something specific it's possible that it's not there and you'll have to rewrite it yourself. All I can say, is jump in. And become someone who gives a future to this language. Don't be scared. This language has a bright future and you'll learn a lot from it.
0
8,065
false
0
1
Is it feasible to use Lisp/Scheme as a scripting language?
20,042,909
2
2
0
0
0
0
0
0
I have two system: System A: This will show translated system with ugettext from mo-files. System B: This will handle the po-files and translate the content. The two system are on different machines, but on the same servernode. The mo-translations are cached up so after read they will not be requested again. I'm looking for a good solution on how I can solve this. Update: I need a good way to get these two system to work together.
0
python,translation,gettext
2013-11-18T13:35:00.000
0
20,049,165
You could also just host the po-files on a shared drive and check for updates to the files.
0
61
false
0
1
Is it possible to have the translation-system and use-system on two different machines?
20,075,524
2
2
0
1
0
0
1.2
0
I have two system: System A: This will show translated system with ugettext from mo-files. System B: This will handle the po-files and translate the content. The two system are on different machines, but on the same servernode. The mo-translations are cached up so after read they will not be requested again. I'm looking for a good solution on how I can solve this. Update: I need a good way to get these two system to work together.
0
python,translation,gettext
2013-11-18T13:35:00.000
0
20,049,165
Simply create an API (via JSON-RPC, XML-RPC, SOAP, CORBA, DCOM, smoke signals, string and tin cans, it doesn't fricking matter...) that allows the client to specify the original string, language, count, and context, and have the server perform the translation and return the translated string. If the translation API reflects the gettext API then it could be used as a drop-in replacement for the gettext module and the client would not require any recoding except possibly to specify the server.
0
61
true
0
1
Is it possible to have the translation-system and use-system on two different machines?
20,067,415
1
2
0
0
3
0
0
0
Good Day! How to get created date of a file via ftp?. Im using web2py,python,ftplib and filezilla as a ftp server. I can get the modified date via f.sendcmd('MDTM '+filename). Any suggestions? Thanks!
0
python,web2py,filezilla,ftplib
2013-11-18T14:16:00.000
0
20,049,928
When I want to change the file modification time, I use an FTP client on the console. Log on to a remote FTP ftp ftp.dic.com cd commands go to the correct directory SITE command to move the extended command mode UTIME somefile.txt 20050101123000 20050101123000 20050101123000 UTC change the access time, modification time, it's time to create a directory on 2005-01-01 12:30:00 somefile.txt Complete example: site UTIME somefile.txt 20150331122000 20150331122000 20150331122000 UTC Of course you can use this command in any ftp client.
0
7,167
false
0
1
Created Date of file via ftp
29,468,765
1
2
0
2
1
0
0.197375
0
I usually work in remote server. I am currently using emacs for editing. while I open particular file, for example, "test.py", I can't get automatic indentation, color profiles for index, python keywords, functions etc. Is there any solution for that?? Moreover I love to use TextWrangler but I can't open file in this editer from my remote host. Is there away to open and edit files from TextWrangler??
0
python,emacs,remote-server
2013-11-18T15:18:00.000
0
20,051,289
Consider using TRAMP (built in to emacs). It allows you to edit remote files using a local emacs instance (it defaultly uses scp to get files to you, and pushes the edits back again).
0
79
false
0
1
Edit options while using remote server
20,052,642
1
1
0
0
0
0
0
0
The title may not be as explicit as I wish it would be but here is what I am trying to achieve: Using Boost.Python, I expose a set of class/functions to Python in the typical BOOST_PYTHON_MODULE(MyPythonModule) macro from C++ that produces MyPythonModule.pyd after compilation. I can now invoke a python script from C++ and play around with MyPythonModule without any issue (eg. create objects, call methods and use my registered converters). FYI: the converter I'm refering to is a numpy.ndarray to cv::Mat converter. This works fine, but when I try to write a standalone Python script that uses MyPythonModule, my converters are not available. I tried to expose the C++ method that performs the converter registration to Python without any luck. If my explanation isn't clear enough, don't hesitate to ask questions in the comments. Thanks a lot for your help / suggestions.
0
python,boost,converters
2013-11-18T19:05:00.000
0
20,055,758
I found the problem... The prototype of my C++ function was taking cv::Mat& as argument and the converter was registered for cv::Mat without reference. That was silly.
1
84
false
0
1
Boost.Python: Converters unavailable from standalone python script
20,058,784
1
1
0
6
1
0
1.2
0
If I'm performing blocking operations like querying a database, then what is the advantage? How does this add extra worthwhile capacity?
0
python,multithreading,deployment,process,uwsgi
2013-11-18T21:38:00.000
1
20,058,464
Python's native multithreading is affected by GIL limitations. Simply put, only one Python thread at a time is physically executed. An exception to this are blocking IO calls (e. g. DB query) that let other Python threads take over, which may increase performance of IO-bound operations. So the real performance gain would only be possible if your application is mostly IO-bound. However, in this case you should consider making the app asynchronous, which uWSGI also supports. Otherwise you should keep your app single-threaded and use multiprocess uWSGI to scale up.
0
1,418
true
0
1
What's the advantage of running multiple threads per UWSGI process?
20,062,339
1
2
0
-1
0
1
-0.099668
0
I'm using Linux Mint Debian Edition (eq. Debian Testing). There is no python2.6-dev package, which I'd need to install pycrypto for Python 2.6 (since it has a compilation step). Is there any way to get this package or an equivalent on my system? I already have installed Python 2.6 in my system and I can use it without a hitch. (The python2.7-dev package is there just fine. But I'm glued to 2.6, so it doesn't suit my needs.)
0
python,debian,python-2.6,apt
2013-11-20T16:41:00.000
1
20,101,721
I know this might seem extreme but if you need 2.6 that badly, try running debian stable in a virtual machine like virtualbox and install 2.6 through that.
0
1,188
false
0
1
How to install python2.6-dev on Debian Testing
20,102,657
1
2
0
2
2
1
1.2
0
Suppose I had a large project in Java, and a class, UsedEverywhere, which was used everywhere. If I changed the return type of the returnsSomething method of that class, my IDE would tell me about everything that broke because of that change. Now suppose I have a large project in Python with the same class and I make the same change. There is no way for me to know what impact I have had unless I also have a huge suite of regression unit tests (which I use regularly). This is due to the dynamic, duck typing system. The same goes for a situation where I remove a method from a class that is used everywhere. What is the best way to protect large projects from breaking without our knowing it? These breakages would never be detected until some kind of regression testing is done.
0
python,eclipse,pydev
2013-11-20T20:31:00.000
0
20,106,390
Two things: Automated tests, as you've suggested. Static analysis: Pylint, PyChecker and/or pyflakes. Of these, pylint is the most stringent.
0
94
true
0
1
Python: large projects and making changes to files used everywhere
20,107,118
1
2
0
0
0
1
0
0
I have to serialise a dynamically created class hierarchy. And a bunch of objects - instances of the latter classes. Python pickle is not of big help, its wiki says "Classes ... cannot be pickled". O there may be some trick that I cannot figure. Performance requirement: Deserialization should be pretty fast, because the serialised staff serves for cache and should save me the work of creating the same class hierarchy. Details: classes are created dynamically using type and sometimes meta-classes.
0
python,class,serialization,hierarchy
2013-11-21T11:07:00.000
0
20,119,271
Classes are normal python objects, so, in theory, should be picklable, if you provide __reduce__ (or implement other pickle protocol methods) for them. Try to define __reduce__ on their metaclass.
0
140
false
0
1
Python : serialise class hierarchy
20,126,494
3
3
0
13
14
1
1
0
What is the time complexity of the sum() function?
0
python,sum,time-complexity
2013-11-22T01:09:00.000
0
20,135,093
It's got to be O(n) for a large list of integers.
0
25,615
false
0
1
What is the time complexity of sum() in Python?
20,135,190
3
3
0
14
14
1
1.2
0
What is the time complexity of the sum() function?
0
python,sum,time-complexity
2013-11-22T01:09:00.000
0
20,135,093
It will make Theta(n) next calls on the iterator, and Theta(n) additions, where n is the number of items you're summing. That's as specific as you can be for the time complexity of an algorithm that calls unknown code. If the time taken for each addition depends on n (as for example it would when summing lists, like sum(list(range(i)) for i in range(n))), then that's going to affect the overall time complexity.
0
25,615
true
0
1
What is the time complexity of sum() in Python?
20,135,284
3
3
0
5
14
1
0.321513
0
What is the time complexity of the sum() function?
0
python,sum,time-complexity
2013-11-22T01:09:00.000
0
20,135,093
It depends on your data structure. For a flat list, you cannot do better than O(n) because you have to look at each item in the list to add them up. When in doubt, try it out: import profile is your friend.
0
25,615
false
0
1
What is the time complexity of sum() in Python?
20,135,182
1
1
0
1
0
1
0.197375
0
Python and R overs a friendly way for one to understand the source code written in these languages and users can stop at a given point and inspect the objects (as objects in these languages can be printed in a user friendly way while debugging). For C++, I don't know if there is similar way. I currently don't use IDE. I know the C++ source code can be compiled with the -g option to allow the use of gdb. But this is still much more difficult than what is in python and R. Does anybody know what might be the best to step through C++ source code and inspect objects when necessary (for code understanding purpose)? Thanks.
0
c++,python,r,debugging,gdb
2013-11-22T17:15:00.000
0
20,150,671
Because Python is an interpreted language, you can have this friendly "debugging experience". C++ is a compiled language so when the executable is running, the run-time knows nothing about the source code. That is why we have to use a GDB or something that can help us to associate the binary and the source code. So I think you have to get familiar with GDB or just pick a nice IDE. Eclipse is quite good! You can do anything with it because there are so many plugins for it.
0
111
false
0
1
Stepping through C++ programs like in python and R
20,153,521
1
1
0
5
11
0
1.2
0
What are the benefits of running uWSGI in master mode if I'm only running a single app? Does master mode offer process management benefits that make it more reliable than, say, running via Upstart?
0
python,uwsgi
2013-11-25T15:49:00.000
1
20,197,259
upstart is only a process manager, the uWSGI master has access to lot of memory areas of workers (well it is the opposite indeed) so it can make truly monitoring of the behaviour of workers, in addition to this it allows graceful reloading, exports statistics and dozens of other things. Running without it is not a good idea from various point of views.
0
4,022
true
1
1
What is uWSGI master mode?
20,199,153
1
4
0
2
22
0
0.099668
0
I am making a robot that will have a webcam on it to provide some simple object detection. For right now, I would like to simply stream the video to a webpage hosted on the robot and be able to view it from another device. I have written a simple test script in Python ( I will eventually move to C++, my language of choice) which can get a stream from my webcam, and then do whatever I need with it from there. The problem then, is that I can't write the video to a file while the app is running, it only writes the file after I quit the script. I already have a webserver running, and I can write the basic code in HTML to host a video from a file as well, and all of that works. To summarize: Is openCV2 in Python and/or C++ capable of livestreaming video using only openCV? If not, what library would you recommend that I try to take a CV capture object or Mat object and write it to a stream that I can then put on a webpage? In HTML, is the tag a good idea to stream video with? Thank you very much for the advice, I can use all the pointers* I can get! If you need something clarified/code posted/explanations further than what I have given, please ask and I will do so!
0
c++,python,html,opencv
2013-11-25T23:08:00.000
0
20,205,358
Under lab conditions you send full images You seem to be under lab conditions, so there is a simplistic, yet usable solution, just stream PNG's in Base64 using Websockets. On the client side (web browser) you just receive the base64 images and directly load them into the src of an <img>. It works for lab scenarios very well, albeit slow.
0
32,863
false
1
1
How do I stream an openCV video to an HTML webpage?
35,518,047
1
2
0
3
1
0
1.2
0
So I've been entering the world of Python just recently, and directed it to quick, personal programs made for myself and professional use for web application design with Django. I've taken a few introductory Python tutorials and most Django tutorials, and have been reading Python documentation whenever possible. I've recently seen that .pyc files are just bytecode (compiled) .py scripts, and don't make the Python language any faster, only lighter and non-human-readable. However, in a medium-low traffic site (let's say, 95% of web sites), this is negligible in difference from PHP, for example (and I find Python to be thousands of times more productive). The question is: can you execute Python programs from .pyc files where there is no .py file? If yes, is this also possible in Django? How? Is it a good way to make web apps "almost closed source"?
0
python,django
2013-11-26T03:19:00.000
0
20,207,882
can you execute Python programs from .pyc files where there is no .py file? Yes. Simply place the .pyc file wherever the .py file would normally be used (except into your text editor, of course). If yes, is this also possible in Django? How? No difference. The interpreter handles the files the same way regardless of what framework is being used. Is it a good way to make web apps "almost closed source"? Not really. Decompiling compiled Python bytecode is trivial.
0
115
true
1
1
Run compiled Python
20,207,935
1
1
0
2
0
0
0.379949
0
I want to send an email alert using the linux os when user delete python setup file. i made a screenshot program using python, unfortunately if user uninstall python setup file.I want to send an email to the admin. if you know the processing steps kindly share with me or please give any suggestions.
0
python,linux,python-3.x
2013-11-27T06:34:00.000
1
20,235,524
The easiest way is to not allow the user delete the script. Put the script in one of the non-core bin directories, e.g. into /usr/local/bin as root and regular user will not be able to remove it.
0
100
false
0
1
How to send email alert to admin after delete a python setup file using linux?
20,235,689
1
4
0
1
7
0
0.049958
0
In my development of Android and Java applications I have been using PHP scripts to interact with an online MySQL database, but now I want to migrate to Python. How does one run Python scripts on a web server? In my experience with PHP, I have been saving my files under /var/www folder in a Linux environment. Then I just call the file later with a URL of the path. Where do I save my Python scripts?
0
python
2013-11-27T12:24:00.000
0
20,242,434
Use a web application framework like CherryPy, Django, Webapp2 or one of the many others. For a production setup, you will need to configure the web server to make them work. Or write CGI programs with Python.
0
47,776
false
0
1
How to run Python scripts on a web server (e.g localhost)
20,242,742
1
2
0
0
1
0
0
0
I've set up a very simple python eve on a linux machine. Somehow, it always stops responding after running for a while. I don't have much experience on python programming and eve doesn't seem to have very nice log file. Can someone please help me to look into the root cause? Thanks, Chunan
0
python,eve
2013-11-28T08:06:00.000
1
20,260,726
I had the exact same problem. You are running something like this: >python yourPeve.py You need to run: >python yourPeve.py & The & simbol, will put the process in the background, so, when you close the terminal, the process won't be killed.
0
433
false
0
1
Python eve not responding after running for a couple of days
20,278,344
1
1
0
9
3
0
1.2
0
win32com is a general library to access COM objects from Python. One of the major hallmarks of this library is ability to manipulate excel documents. However, there is lots of customized modules, whose only purpose it to manipulate excel documents, like openpyxl, xlrd, xlwt, python-tablefu. Are these libraries any better for this specific task? If yes, in what respect?
1
python,excel,win32com,xlrd,openpyxl
2013-11-28T10:04:00.000
0
20,263,021
Open and write directly and efficiently excel files, for instance. win32com uses COM communication, which while being very useful for certain purposes, it needs to perform complicated API calls that can be very slow (so to say, you are using code that controls Windows, that controls Excel) openpyxl or others, just open an excel file, parse it and let you work with it. Try to populate an excel file with 2000 rows, 100 cells each, with win32com and then with any other direct parser. While a parser needs seconds, win32com will need minutes. Besides, openpyxl (I haven't tried the others) does not need that excel is installed in the system. It does not even need that the OS is windows. Totally different concepts. win32com is a piece of art that opens a door to automate almost anything, while the other option is just a file parser. In other words, to iron your shirt, you use a $20 iron, not a 100 ton metal sheet attached to a Lamborghini Diablo.
0
3,031
true
0
1
What do third party libraries like openpyxl or xlrd/xlwt have, what win32com doesn't have?
20,263,978
1
2
0
1
0
1
0.099668
0
I've recently been looking into Python's dictionaries (I believe they're called associate arrays in other languages) and was confused by a couple of the restrictions on its keys. First, dict keys must be immutable. When I looked up the logic behind it the answer was that dictionaries work like hash tables to look up the values for keys, and thus immutable keys (if they're hashable at all) may change their hash value, causing problems when retrieving the value. I understood why that was the case just fine, but I was still somewhat confused by what the point of using a hash table would be. If you simply didn't hash the keys and tested for true equality (assuming indentically constructed objects compare equal), you could replicate most of the functionality of the dictionary without that limitation just by using two lists. So, I suppose that's my real question - what's the rationale behind using hashes to look up values instead of equality? If I had to guess, it's likely simply because comparing integers is incredibly fast and optimized, whereas comparing instances of other classes may not be.
0
python,dictionary,hash
2013-11-28T14:42:00.000
0
20,268,901
By using hastables you achieve O(1) retrieval data, while comparing against each independent vale for equality will take O(n) (in a sequential search) or O(log(n)) in a binary search. Also note that O(1) is amortized time, because if there are several values that hash to the same key, then a sequential search is needed among these values.
0
90
false
0
1
Why use hashes instead of test true equality?
20,269,010
1
1
0
0
0
0
1.2
0
Ok, this is really weird. I have an old Mercurial 2.02. with python 2.6 on an old Ubuntu-something (I think 10.4). We are a windows shop, und push regularly, so I wanted kind of a review service. It absolutely worked on windows.. pretxnchangegroup referencing the python file on the drive, worked.. But I made the mistake to create the Mercurial hook on a new Mercurial 2.7, but then recognized the internal API changed, so I got back and fixed it, or tried to. I'm using windows, but need to deploy the hook to Linux, so I use WinSCP to copy the py file to my home directory. And then sudo cp it to the python 2.6 distro folder where the other hook file lie. I invoke the hook via the module pattern on the linux box: pretxnchangegroup.pushtest = python:mycompanyname.testcommit.exportpatches In the folder "mycompanyname" is the file testcommit.py and the function is named exportpatches. It works locally without a problem. The strange thing: It worked once, and kind of unstable: sometime it just says that the function "mycompanyname.testcommit.exportpatches" is not defined. And sometimes it just uses an old version of the hook (I see that because it gives an old exception message instead of the newer one). And I don't know how to get exception messages in python, so I'm lost there.. Second strange thing: these hook files also have a .pyc version, probably compiled, but my hook doesn't get such treatment. Is that autocompilation? If I try the directory approach to point to the file, I get a straight 500 internal error on push. I'm really lost and desperate by now, because the stuff has to work pretty soon, and I'm banging my head against the wall right now..
0
python,mercurial,mercurial-hook
2013-11-28T17:32:00.000
1
20,271,881
I don't know exactly what happened, but it seams like it was not using the script because an exceptions somehow prohibited it from compiling to a pyc, and Mercurial somehow fetched the old version of that pyc file. Not too sure, but that's my best guess (as somehow noone else seems to have an idea and the Mercurial guys made it really clear they only answer stuff on their mailing list instead of SO.. how .. nice).
0
44
true
0
1
Mercurial hook: isn't recompiled after change?
20,836,549
1
1
0
1
3
0
0.197375
0
Is there a way using StarUML for reverse engineering Python code to a class diagramm? In the StarUML docs, they say there are modules for language support, but I couldn't find any further information about where and how to install and use. Other UML tools I found didn't match my idea of how a diagramm should look like. I know it is a bit problematic generating class diagramms for python, because it's compiled to runtime and will probably change then. But I'm using Python to build my bachelor thesis and my Prof. loves UML. He really takes care of doing this correctly. Can anybody help me pls?
0
python,staruml
2013-11-29T10:00:00.000
0
20,283,021
There is a simple possibility: Use PyCharm, a python IDE, which has an integrated UML generator (only in the pro version which is free for students).
0
2,332
false
0
1
StarUML for Python
45,105,412
1
2
0
1
0
0
0.099668
0
I am basically writing an API in Python, using Flask, and I would like to restrict access to its endpoints so that only an entity, namely an Arduino, can have GET and POST access. How should I make this possible and what should I be looking for?
0
python,api,flask,arduino
2013-11-30T09:53:00.000
0
20,298,833
Configure your WSGI container or its associated web server to only allow access to the Flask application from the IP address assigned to the Arduino's network interface.
0
78
false
1
1
Restrict Python API access to single Arduino entity
20,298,873
2
2
0
0
2
1
0
1
I'm using twitter python library to fetch some tweets from a public stream. The library fetches tweets in json format and converts them to python structures. What I'm trying to do is to directly get the json string and write it to a file. Inside the twitter library it first reads a network socket and applies .decode('utf8') to the buffer. Then, it wraps the info in a python structure and returns it. I can use jsonEncoder to encode it back to the json string and save it to a file. But there is a problem with character encoding I guess. When I try to print the json string it prints fine in the console. But when I try to write it into a file, some characters appear such as \u0627\u0644\u0644\u06be\u064f I tried to open the saved file using different encodings and nothing has changed. It suppose to be in utf8 encoding and when I try to display it, those special characters should be replaced with actual characters they represent. Am I missing something here? How can I achieve this? more info: I'm using python 2.7 I open the file like this: json_file = open('test.json', 'w') I also tried this: json_file = codecs.open( 'test.json', 'w', 'utf-8' ) nothing has changed. I blindly tried, .encode('utf8'), .decode('utf8') on the json string and the result is the same. I tried different text editors to view the written text, I used cat command to see the text in the console and those characters which start with \u still appear. Update: I solved the problem. jsonEncoder has an option ensure_ascii If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. I made it False and the problem has gone away.
0
python,json,unicode,utf-8
2013-11-30T22:13:00.000
0
20,306,249
Well, since you won't post your solution as an answer, I will. This question should not be left showing no answer. jsonEncoder has an option ensure_ascii. If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. Make it False and the problem will go away.
0
984
false
0
1
Python unicode file writing
20,464,991
2
2
0
2
2
1
1.2
1
I'm using twitter python library to fetch some tweets from a public stream. The library fetches tweets in json format and converts them to python structures. What I'm trying to do is to directly get the json string and write it to a file. Inside the twitter library it first reads a network socket and applies .decode('utf8') to the buffer. Then, it wraps the info in a python structure and returns it. I can use jsonEncoder to encode it back to the json string and save it to a file. But there is a problem with character encoding I guess. When I try to print the json string it prints fine in the console. But when I try to write it into a file, some characters appear such as \u0627\u0644\u0644\u06be\u064f I tried to open the saved file using different encodings and nothing has changed. It suppose to be in utf8 encoding and when I try to display it, those special characters should be replaced with actual characters they represent. Am I missing something here? How can I achieve this? more info: I'm using python 2.7 I open the file like this: json_file = open('test.json', 'w') I also tried this: json_file = codecs.open( 'test.json', 'w', 'utf-8' ) nothing has changed. I blindly tried, .encode('utf8'), .decode('utf8') on the json string and the result is the same. I tried different text editors to view the written text, I used cat command to see the text in the console and those characters which start with \u still appear. Update: I solved the problem. jsonEncoder has an option ensure_ascii If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. I made it False and the problem has gone away.
0
python,json,unicode,utf-8
2013-11-30T22:13:00.000
0
20,306,249
jsonEncoder has an option ensure_ascii If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. Make it False and the problem will go away.
0
984
true
0
1
Python unicode file writing
20,528,987
1
2
0
2
2
0
0.197375
1
I have two web hosts. One with a standard shared hosting provider, and the other: AWS Free Tier. I would like for these two servers to be able to communicate with one another. Basically, I would like the shared server to send some information to the AWS server, causing the AWS server to run certain scripts. I am familiar with python, so am wondering if there is some python library I can use to quickly cook up a script that would listen to a certain port (on AWS). Also, security is in issue: I want AWS to only listen to requests from a certain IP. Is this possible? What python libraries could I use for something like this? I am fairly new to web programming and wasn't able to google the solution to this. Thanks!
0
python,web,amazon-web-services,server-communication
2013-12-01T15:55:00.000
0
20,314,048
Since you are already using aws, for something like this you couldconsider using AWS SQS to add a queue between the two hosts and communicate thru it instead of directly. Using SQS, it would be easy to write a script to add messages to the SQS queue when something needs to be run on the other host, and equally easy for the second host to poll the queue looking for messages. Adding a queue between the two hosts decouples them, and adds a bit of fault tolerance (i.e. one of the hosts could go off line for a bit without the messages being lost), and possibly gives you the ability to scale up if you need to a bit easier (for example, if you ever needed multiple instances at aws processing jobs from the other host you could just add them and tell them to also poll the same queue, as opposed to building in a 1-1 'always on' dependency between the two. Lots of different ways to skin this cat, so maybe the approach above is overkill in your case, but thought I'd throw it out there as something to consider.
0
43
false
0
1
What options are there to allow one server to send information to another server?
20,316,557
1
1
0
1
3
0
1.2
0
I am trying to compile a code which uses the Python.h header. In fact it is the lcm library. Now, I have Python2.7 and Python3.3 installed on my system. The respective header filer are found in /usr/include/python2.7/ and /usr/include/python3.3m/. The problem is that the code needs the 2.7 version, but gcc always prefers the 3.3 version. I tried setting ./configure --prefix /bla/bla CPPFLAGS=-I/usr/include/python2.7/ and export C_INCLUDE_PATH=/usr/include/python2.7, none of which worked. An intermediate workaround is to change the code to #include <python2.7/Python.h> but that makes it unportable, so it will not serve as a fix for the lcm people... There must be a way!!!
0
python,python-2.7,gcc,python-3.x,include-path
2013-12-02T07:38:00.000
1
20,323,084
GCC probably prefers the 3.3 version if it's installed as the default that's run when you call 'python' without a version? You could always point that binary at the 2.7 to make it the default on your system.. Looking at the m4 source, seems like you might be able to do the following on one line: PYTHON=/path/to/python2.7 PYTHON_INCLUDES="-I/usr/include/python2.7" ./configure --prefix /bla/bla
0
806
true
0
1
Python3.3 header preferred over Python2.7 header by gcc
20,325,445
1
2
0
0
0
0
1.2
0
and thanks ahead of time. I am relatively new to Linux and am using Ubuntu 12.04.3. Basically, I've been messing around with some files trying to get Django to work. Well, I though I should do another install of Python2.7 for some reason. Stupidly, I manually installed it. Now when I open the Python shell and do 'import django', it can't be found. I just want to go back to using the Python that was on Ubuntu by default, or overwrite the one I installed manually with one using apt-get. However, I am unable to figure out how to do this nor have I found a question that could help me. Any help is much appreciated. I've been working on this for 6 hours now... --EDIT-- Ok well I'm just trying to go ahead and have the PYTHONPATH look in the right place. I've seen in other posts that you should do this in the ~/.profile file. I went into that file and added this line export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages "import django" is still coming up with "no module found" I tried doing "import os" and then "os.environ["PYTHONPATH"], which gave me: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/UserDict.py", line 23, in getitem raise KeyError(key) KeyError: 'PYTHONPATH' As far as I can tell, this means that I do not have a PYTHONPATH variable set, but I am unsure as to what I am doing wrong. --ANOTHER EDIT-- As I am not a very reputable member, I am not allowed to answer my own question before 8 hours from my original question, so I am putting it as an update. Hey guys, thank you all for the quick responses and helpful tips. What I did was open a python shell and type: sys.path.append('/usr/local/lib/python2.7/dist-packages') and it worked! I should have done this from the beginning instead of trying to overwrite my manual Python installation. Once again, thank you all for the help. I feel so relieved now :)
0
python,django,ubuntu
2013-12-02T09:29:00.000
1
20,324,828
Sounds like an issue with your path - python not finding django becuase it doesnt know where to look for it. Look up issues regarding path and see if those help.
0
533
true
1
1
I need to overwrite an existing Python installation in ubuntu 12.04.3
20,324,883
1
1
0
3
0
1
1.2
0
I'm writing a python script to keep my dotfiles up to date with a repository on GitHub. It copies the dot files into a separate directory ( ~/dotfiles ) so that my home directory is not a git repo. Before copying the files, it does a filecmp.cmp( fileInLocalRepo,fileInHomeDir ) to see if the file has changed since it was last copied into the local repo. Once all the files are updated, if there have been any changes the changed files are pushed to GitHub. That works fine until I start updating dot files from more than one computer, then older files could potentially overwrite my remote ones. If I pull the files down to my local dotfiles repo first, filecmp.cmp() will still say the files are different and the script will overwrite the pulled down file with the local one, then push because it thinks there was a change. Is there any way I can figure out which file is actually newer? I know that git doesn't preserve update times in file properties, so I can't use that. How can I pull down files from GiHut to a local repo ( ~/dotfiles ) then compare them with the same dot files that are in my home directory to see which of each file is actually newer?
0
python,git,github,version,fileupdate
2013-12-02T22:51:00.000
0
20,339,505
Assuming all the computers you are setting this up on have accurate times, you could have it create a timestamp file for each dotfile, which just contains the local modified time of the dotfile. Then you can compare the local timestamp with the remote one. You could also just do the commit locally and try to merge with the remote branch. If the merge succeeds then assume it's ok. If it failed then there were two different changes to the same part of a file and the conflict needs to be resolved, in which case you notify yourself somehow. A potentially simpler and less error prone solution (because it's more manual) would be to have your dotfiles be symlinked to the dotfiles in the git. Then when you edit a dotfile the git one is updated, and you can manually commit and push the change easily.
0
311
true
0
1
Best way to compare remote git file versions with local file versions?
20,339,747
1
1
0
0
0
0
1.2
1
I am trying to develop a small automated tool in python that can check Forms inputs of a web application for XSS vulnerability. I hope to do this using python mechanize library so that I can automate form filling and submit and get the response from the python code. Though mechanize is also works as a browser, is there a way to detect a browser alert message for an input containing a script. Or else is there any other library for python such that I can perform this functionality. Any sample code will be a great favor. PS : I am trying to develop this so that I can find them in an application we are developing and include them in a report and NOT for Hacking purpose. Thank you.
0
python,mechanize,mechanize-python
2013-12-03T09:24:00.000
0
20,347,235
Answering my own question. Browser giving an alert message simply means that our the node is injected into DOM. By simply looking for the string that I injected in the response body, I could determine whether the given input is reflected through the browser without proper sanitization.
0
244
true
1
1
Identify Browser alert messges in Mechanize - Python
22,406,798
1
1
0
0
0
0
1.2
0
So I was making a simple chat app with python. I want to store user specific data in a database, but I'm unfamiliar with efficiency. I want to store usernames, public rsa keys, missed messages, missed group messages, urls to profile pics etc. There's a couple of things in there that would have to be grabbed pretty often, like missed messages and profile pics and a couple of hashes. So here's the question: what database style would be fastest while staying memory efficient? I want it to be able to handle around 10k users (like that's ever gonna happen). heres some I thought of: everything in one file (might be bad on memory, and takes time to load in, important, as I would need to load it in after every change.) seperate files per user (Slower, but memory efficient) seperate files per data value directory for each user, seperate files for each value. thanks,and try to keep it objective so this isnt' instantly closed!
1
python,database,performance,chat
2013-12-04T16:27:00.000
0
20,380,661
The only answer possible at this point is 'try it and see'. I would start with MySQL (mostly because it's the 'lowest common denominator', freely available everywhere); it should do everything you need up to several thousand users, and if you get that far you should have a far better idea of what you need and where the bottlenecks are.
0
45
true
0
1
efficient database file trees
20,382,525
1
1
0
2
0
0
1.2
0
I have a web frontend which uses data from a task that must be run frequently in bulk (which takes more time than I'd like to use PHP for). The data can be stored in a database so I was planning on writing a Java application to run the task and use the database as a middleman to get the results of this task accessible to the web. Problem is, a "preview" of this data is needed occasionally. IE, sometimes the user needs to request a sample of the data (which can be computed quickly) to be generated on cue. This presents a real problem for me, this preview IS more suited for a language like PHP even though it's essentially the same task. It's just two cases, in case A there are real jobs from many users to be done so the task takes a sufficiently long time to complete (longer than a PHP request can hold), in case B it's a baby job for just one user ran on the spot which could be completed in PHP without issue. I don't want to write this code twice, it would make maintenance a nightmare so I kind of need to pick a language and stick with it. The frontend is designed but not implemented so I have an oppertunity to write the site in PHP, Ruby or Python if need be. I know PHP, so I would only consider switching to Python or Ruby if one of those languages offered a solution to this problem. but I know so little about these languages that I really cannot begin to know if they offer a solution without learning them (which I don't have the time for atm). In short, is there a non-hackish way to write short, quick event-driven code AND long-running repetitive code with Ruby on Rails or Python? If not do you have any ideas how to satifsy these two cases with either PHP or Java?
0
php,python,ruby
2013-12-05T17:44:00.000
0
20,406,998
Language is irrelevant. Just put "short" operation in function (object, if it is complex) and use it from 2 places: web-code which needs "preview" will call it once and get its piece of data long-running background process will call it iteratively as much as needed and will store result of function in DB instead of returning it to user immediately Can be easily done in PHP. Long-running processeses are not a problem since 5.3
0
81
true
1
1
PHP / Python / Ruby - Long running tasks with short previews
20,409,383
1
1
0
1
0
0
1.2
0
I need a launch script which has access to "db" and other web2py modules. This script must be running constantly. I know that Web2py has launch parameters from which you can run python files in the web2py enviroment, but i don't know how that works. Can this parameter solve my problem and if so, how do I go about it? Thanks!
0
python,web2py
2013-12-06T15:09:00.000
0
20,427,217
Look at section 4.17.1 of the web2py manual (or Google "web2py cron"). You can run a script on startup of web2py by registering it in the crontab file as: "@reboot web2py *scripts/myscript.py" web2py should be the username that it will run as, which should be the same as what web2py runs as. In my setup I have a user named 'web2py' to run the app. The asterix before scripts/myscript.py indicates that you want to run the script in the web2py environment. Keep in mind that you run the risk of locking issues if your script is trying to use the database at the same time as the normal web2py process.
0
1,158
true
1
1
Web2py launch script
20,437,241
1
5
0
0
2
0
0
0
Here is my problem, I have a Python script that will be running indefinitely in a while(1) loop. I want some PHP script to somehow interact with the Python script, and when it does, the script needs to perform a function with the data submitted to the script. Any ideas would be appreciated!
0
php,python,sockets
2013-12-06T16:06:00.000
0
20,428,414
If the same machine, you can use file with command. Create a file cmd.txt , python will read it in loop every sec, Php script will write a command in file cmd.txt , python will do the job and erase the command from cmd.txt
0
4,830
false
0
1
Sending data to Python Script from PHP
20,429,263
1
1
0
5
3
0
1.2
0
I am developing an application in Python that communicates to a device over RS-485 two wire, half-duplex. I have enough of the application working that I can perform some performance tests. I am using a laptop with a USB to 485 converter. The communications is setup as 9600,N,8,1. For my speed test I send a message with a total length of 10 bytes including the check byte. Then I wait for the reply of 13 bytes. I decode the reply as it is coming in. When the response is complete. I then send the next message. I repeat this 100 times as fast as possible. This takes 2.895 seconds. From this I calculate that I am transmitting/receiving 23 bytes * 100 iterations / 2.895 seconds = 794 bytes/s. If I understand it correctly serial port communication of 9600 N-8-1 has 1 start bit, 8 data bits and 1 stop bit. This means that it has a 2 bit overhead. So the actual theoretical transmission rate is (9600 bits / s) * (8 data bits / 10 transmission bits) * (1 Byte / 8 bits) = 960 bytes / s. My program is transmitting/receiving at a combined rate of 794 bytes/s out of a possible 960 bytes / s = 82.7%. Should I be able to achieve near 100% of the 960 bytes/s. Or is it typical to have this much bandwidth un-utilized?
0
python,performance,serial-port,baud-rate
2013-12-07T04:49:00.000
0
20,437,735
You're going to give up some time when the direction of communication is reversed. So there's some "dead time" between when one side receives the last stop bit and when it loads the first response byte into the UART transmitter and starts driving the first start bit. I'm calculating that this dead time is 5 ms (almost 5 bit times, i.e. half a byte counting framing overhead) per two-way run, or 0.495 seconds of your 2.895 total seconds. This isn't bad, but it could be a little better. However, I'm not sure you'll get much improvement without writing your own UART driver. (This all assumes, of course, that the clocks both computers are using are crystal accurate. This isn't always true, since UARTs at 8N1 can tolerate up to about 2% clock difference between each end.) In embedded land, if we wanted to do this with absolute minimum bandwidth loss, we'd write the driver as a standard two-way full-duplex driver, with some way to know when to switch directions (e.g. on packet bounds). This driver would then only push bytes in the correct direction, leaving the other queue unused. At the user (application) level, we'd have to make sure those queues were never starved. That means that, in your example, the 13-byte response packet would need to be ready to go before the 10-byte incoming packet is fully received. The other end would need to do the same. With larger machines, the usual practice is to "coalesce" several packets in each direction and transmit them consecutively, so as to minimize the number of times that you have to change direction. This increases latency, though, and requires more memory, which could be a problem with a small microcontroller with only a couple kB of RAM. IMHO, given your small packets, frequent direction reversals, and lack of driver-level optimizations, that bandwidth looks about right.
0
1,777
true
1
1
RS-485 Serial Port Baud Rate Performance Efficiency
20,437,926
1
1
0
3
0
0
0.53705
0
Is there a way to do this without using smartmontools? I'd like to try to see how far I get with just Python if possible. A google search does not seem to yield too much.
0
python,linux,disk
2013-12-07T10:36:00.000
0
20,440,320
Get libatasmart which is a C library, and invoke it from Python via ctypes or cffi.
0
167
false
0
1
Accessing SMART attributes in Linux with only Python?
20,441,124
1
1
0
0
0
0
0
0
I am using ACE to allow people to code freely on my website. How would I run this code. I would like a run button in the bottom left corner (I can do that in css), but how would I run it, as it is python. I have added extra tags, as you can write these languages in the ace editor. When I mean, a run button, I mean like on codecademy, where you write some code, then it is submitted.
0
javascript,php,python,vbscript,cloud9-ide
2013-12-07T11:07:00.000
0
20,440,581
You could possibly make a temporary file in your system, and in an iframe, open the file. Important Note This could be insecure as they could get the URL and execute code to delete ../../../ or something, which could harm your files.
0
530
false
1
1
How do I try and run code that I have written in ACE Cloud 9?
20,442,855
1
1
0
1
1
1
0.197375
0
I'm working on string manipulation in Python (v3.3), and I'm wondering if there's a predictable way to detect the addition of diacritical markings on a given character. So for instance is there some relationship between 'α' # ord('α') = 945) (Greek unmarked alpha) and 'ᾶ' # ord('ᾶ') = 8118 (Greek alpha with a circumflex) and 'ω' # ord('ω') = 969 (Greek unmarked omega) and 'ῶ' # ord('ῶ') = 8182 (Greek omega with a circumflex)? Are there any manipulations that can be done to clear the diacritics? Or to add a diacritic, for example when marking a long vowel: 'ᾱ' # ord('ᾱ') = 8113? Thanks! Edit: I've played around with both the unidecode package and unicodedata. I'm not looking simply to normalize strings; I'm interested in resources for understanding the byte manipulations that happen behind the scenes to add, say, a circumflex or a macron to a standard alpha. Another way of asking that question is how does chr(945) # 'α' become or relate to chr(8113) # 'ᾱ' at a very low level? Maybe I'm thinking of this (text) in completely the wrong way, and I'd be interested in learning that too. This question doesn't actually have so much to do with Python as it does with text encoding in general, but I mention Python just in case any of its peculiarities come into play. Edit 2: I should also add that I'm more interested in how something like unidecode works than in actually using it at the moment. unidecode('ῶ') and unidecode('ὄ') # that's an omicron, not an 'o' both return 'o', and that return value isn't as helpful to me at the moment as a higher-level understanding of how the unidecode module arrives at that return value.
0
python,unicode,python-3.3
2013-12-08T20:16:00.000
0
20,458,503
As @Jongware and @SimeonVisser pointed out, "Unicode is basically just a big lookup table," so there's secret sauce along the lines of what I was looking for. Marking as answered--hopefully the directness here will help someone with a similar question in the future.
0
581
false
0
1
Unicode and (Greek) Diacritics in Python
20,459,315
2
4
0
5
8
0
0.244919
0
Can someone give me a guide for morons? I am somewhat out of my depth here. So far I have downloaded xlrd 0.9.2 and tried to follow the readme, but neither I nor ctrl-f can find the installer mentioned.
0
python,installation,xlrd
2013-12-09T01:53:00.000
0
20,461,790
If windows this should work. Browser to "folder with python"\scripts Open cmd here (shift + right click and and it should be an option in the context menu.) type inn: easy_install.exe xlrd It should download and install if for you.
0
43,595
false
0
1
I'm having a lot of trouble installing xlrd 0.9.2 for python
20,462,021
2
4
0
1
8
0
0.049958
0
Can someone give me a guide for morons? I am somewhat out of my depth here. So far I have downloaded xlrd 0.9.2 and tried to follow the readme, but neither I nor ctrl-f can find the installer mentioned.
0
python,installation,xlrd
2013-12-09T01:53:00.000
0
20,461,790
If you have installed pip which is available with python installation file; then just do the following steps: Open Command Line Type "pip install xlrd" Hope it will work
0
43,595
false
0
1
I'm having a lot of trouble installing xlrd 0.9.2 for python
52,548,713
1
2
0
4
0
0
1.2
1
Is there an easy way to get the number of followers an account has without having to loop through cursors? I'm looking for a simple function call which will return to me just the number of followers the use with a given Twitter ID has. Just looking for the physical number not access to anything else
0
python,twitter,twython
2013-12-09T07:23:00.000
0
20,465,269
What I ended up doing was .show_user(user_id=twitter_id) which returns (among other things) the followers count via ['followers_count']
0
907
true
0
1
Twython get followers count
20,511,726
1
5
0
13
29
1
1
0
I am enjoying PyCharm's optimizing of Python imports - as well as removing unused imports, following PEP8 gives them a sensible layout and makes them easier to read. Is there any way to get PyCharm to additionally alphabetize them (which would make scanning them faster, for me at least)?
0
python,pycharm
2013-12-09T10:49:00.000
0
20,468,670
PyCharm sorts imports only according to groups specified in PEP-8, not alphabetically.
0
10,848
false
0
1
Can PyCharm's optimize imports also alphabetize them?
20,634,928
1
2
0
2
8
1
0.197375
0
I have a pretty big Python package I've written, about 3500 statements, with a robust unit and acceptance test suite. I feel quite confident about the quality of the code itself, but I'm uneasy about the install process going smoothly for users of the package as I don't know how to reliably test the install in an appropriately isolated environment, short of something like keeping a spare machine around and re-imaging it with a fresh OS install for each test run. I suspect using virtualenv in the right way might provide a proper test fixture for testing installation, but after extended web searches have uncovered no helpful guidance. How can I effectively test my setup.py and other installation bits on my development machine?
0
python,integration-testing,setup.py
2013-12-10T08:32:00.000
0
20,489,514
If you really want isolation instead just doing python setup.py install in virtualenv. Then use virtualbox and install some free linux os in it. Take a snapshot of the machine after the install so you can revert easily with one click to the starting point at any time and try python setup.py install there.
0
1,343
false
0
1
How do I test the setup.py for my package?
20,489,835
1
2
0
0
0
0
0
0
I made a program which is saving sensor data in a log file (server site). This file is stored in a temporary directory (Ram-Disk). Each line contains a timestamp and a JSON string. The update rate is dependent on the sensor data, but the fastest is every 0.5s. What I want to do is, to stream every update in this file to a client application. I have several approaches in mind: maybe a shared folder on server site (samba) with a script (client site), just checking the file every 0.5s maybe a another server program running on the server, checking for updates (but this I don't want to do, because Raspberry Pi is slow) Has anyone maybe done something like this before and can share some ideas? Is there maybe a python module for this already (which opens a file like a stream and if something changed then this stream is giving it out)? Is it smart to check a file constantly for updates?
0
python,logging,streaming
2013-12-11T10:22:00.000
1
20,516,490
I'm doing something like that. I have a server running on my raspberry pi + client that parse the output of the server and sends it to another server on the web. What I'm doing is that the local server program write it's data in chunks. Every time it writes the data (by the way, also on tmpfs) it writes it on a different file, so I don't get errors when trying to parse the file while something else is writing to that file.. After it writes the file, it starts the client program in order to parse and send the data (Using subprocess with the name of the file as a parameter). Works great for me.
0
189
false
0
1
Streaming of a log text file with constant updates
21,938,560
1
1
0
0
0
0
0
0
Is there a way to run unittests for a module with setup.py using distutils? python3.3 distutils doesn't seem to support the 'test_suite' option: In setup.py I have the following code: test_suite = 'test.run_tests',
0
python,python-3.3,distutils
2013-12-11T15:00:00.000
0
20,522,465
No distutils version supports test integration: it’s a setuptools add-on. unittest in 2.7 and 3.2 gained support for auto-discovering tests, so even if you can’t run python setup.py test there’s still python -m unittest.
0
175
false
0
1
How to run unittest with distutils in python3.3
20,535,929
1
3
0
2
0
0
0.132549
0
Im writing a program in php which does almost everything it needs to do, but at one point i need to use a function that is written in python using the mechanize library, both these scripts will be hosted on the same server. My initial thoughts are to make a CURL call containing any arguments from the php script to the python script, and then return the results of the function again back to the php script using CURL. Im quite new to programming and not sure of the best conventions when doing something like this, is my setout workflow using CURL the usual way this would be done or is there another way ?
0
php,python,curl,cross-language
2013-12-13T23:23:00.000
0
20,577,682
If you need to be able to distribute the PHP code and the Python code independently, deploy them on separate servers, etc., then this is reasonable—you make the Python code a web service, make the PHP code call that web service, and you're done. But if the Python script is always going to be running locally, it's usually easier just to run it as a program—pass it command-line arguments and/or standard input, and retrieve its standard output. PHP has a few different ways to do this—system, popen, exec, passthru—which all have different upsides and downsides. For example, with exec, you just call escapeshellarg on each argument, put them together into a space-separated string with the path to the script, call exec, and you get the result back.
0
46
false
0
1
Calling a function in another lagnauge
20,577,730
2
3
0
0
0
0
0
1
As the title says, I'm looking for information about the best library to send HTTP requests in Python really fast. Do you know which one is the fastest and/or consume less CPU time/memory ? urllib2 httplib2 requests Thanks
0
python,http
2013-12-15T14:20:00.000
0
20,595,525
Sending HTTP request is pretty simple, I don't think it could be a block issue for most real world applications. If you really want to send request very fast, you can consider to use multi processes, not waste your time on choosing a faster library(Which likely to be helpless).
0
1,475
false
0
1
Best performance HTTP library in Python
20,595,734
2
3
0
2
0
0
0.132549
1
As the title says, I'm looking for information about the best library to send HTTP requests in Python really fast. Do you know which one is the fastest and/or consume less CPU time/memory ? urllib2 httplib2 requests Thanks
0
python,http
2013-12-15T14:20:00.000
0
20,595,525
urllib2 might be better for performance, but requests is much simpler to use.
0
1,475
false
0
1
Best performance HTTP library in Python
20,595,601