Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2012-07-17 04:17:08.710 | How to use multiprocessing queue in Python? | I'm having much trouble trying to understand just how the multiprocessing queue works on python and how to implement it. Lets say I have two python modules that access data from a shared file, let's call these two modules a writer and a reader. My plan is to have both the reader and writer put requests into two separat... | in "from queue import Queue" there is no module called queue, instead multiprocessing should be used. Therefore, it should look like "from multiprocessing import Queue" | 0.481382 | false | 1 | 1,982 |
2012-07-17 07:21:19.640 | Waiting for a program to finish its task | I'd like to know how to have a program wait for another program to finish a task. I'm not sure what I'd look for for that...
Also, I'm using a mac.
I'd like to use Python or perhaps even applescript (I could just osascript python if the solution if for applescript anyway)
Basically this program "MPEGstreamclip" convert... | I realized GUI applescript was the answer in this scenario. With it I could tell the PROCESS to get every window, and that worked. However, I'm leaving this up because I'd like to know other ways. I'm sure this GUI workaround won't work for everything. | 0.201295 | false | 1 | 1,983 |
2012-07-17 18:07:01.283 | How to upgrade virtualenv to use a new system python? | I had installed virtualenv on the system with python2.6.
I upgraded the system python to 2.7, but the virtualenv still has affinity for python2.6.
I tried easy_install --upgrade virtualenv, but that didn't change anything.
Does anyone know how to update the system installed virtualenv to use the new python2.7 on the sy... | You could try pip install -U python from within the virtual environment, not sure what it would break.
You could also change the symlinks that point to the old Python, but not sure what side effects that would have.
I would recommend the safest path, that is to first pip freeze > installed.txt and then recreate your vi... | 0.135221 | false | 1 | 1,984 |
2012-07-17 20:16:38.040 | Flask SQLAlchemy query, specify column names | How do I specify the column that I want in my query using a model (it selects all columns by default)? I know how to do this with the sqlalchmey session: session.query(self.col1), but how do I do it with with models? I can't do SomeModel.query(). Is there a way? | result = ModalName.query.add_columns(ModelName.colname, ModelName.colname) | 0.081452 | false | 1 | 1,985 |
2012-07-18 16:11:20.843 | Is it possible to TDD when writing a test runner? | I am currently writing a new test runner for Django and I'd like to know if it's possible to TDD my test runner using my own test runner. Kinda like compiler bootstrapping where a compiler compiles itself.
Assuming it's possible, how can it be done? | Bootstrapping is a cool technique, but it does have a circular-definition problem. How can you write tests with a framework that doesn't exist yet?
Bootstrapping compilers can get around this problem in several ways, but it's my understanding that usually the first implementation isn't bootstrapped. Later bootstraps wo... | 1.2 | true | 2 | 1,986 |
2012-07-18 16:11:20.843 | Is it possible to TDD when writing a test runner? | I am currently writing a new test runner for Django and I'd like to know if it's possible to TDD my test runner using my own test runner. Kinda like compiler bootstrapping where a compiler compiles itself.
Assuming it's possible, how can it be done? | Yes. One of the examples Kent Beck works through in his book "Test Driven Development: By Example" is a test runner. | 0.999909 | false | 2 | 1,986 |
2012-07-19 18:48:04.390 | Scanning MySQL table for updates Python | I am creating a GUI that is dependent on information from MySQL table, what i want to be able to do is to display a message every time the table is updated with new data. I am not sure how to do this or even if it is possible. I have codes that retrieve the newest MySQL update but I don't know how to have a message ev... | Quite simple and straightforward solution will be just to poll the latest autoincrement id from your table, and compare it with what you've seen at the previous poll. If it is greater -- you have new data. This is called 'active polling', it's simple to implement and will suffice if you do this not too often. So you ha... | 1.2 | true | 1 | 1,987 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | I suggest using configuration files for that and to not version them.
You can however version examples of the files.
I don't see any problem of sharing development settings. By definition it should contain no valuable data. | 0.235586 | false | 6 | 1,988 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | EDIT: I assume you want to keep track of your previous passwords versions - say, for a script that would prevent password reusing etc.
I think GnuPG is the best way to go - it's already used in one git-related project (git-annex) to encrypt repository contents stored on cloud services. GnuPG (gnu pgp) provides a very s... | 0.095744 | false | 6 | 1,988 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | Encrypt the passwords file, using for example GPG. Add the keys on your local machine and on your server. Decrypt the file and put it outside your repo folders.
I use a passwords.conf, located in my homefolder. On every deploy this file gets updated. | 0.047982 | false | 6 | 1,988 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | Provide a way to override the config
This is the best way to manage a set of sane defaults for the config you checkin without requiring the config be complete, or contain things like hostnames and credentials. There are a few ways to override default configs.
Environment variables (as others have already mentioned) ar... | 0.071905 | false | 6 | 1,988 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | You could use EncFS if your system provides that. Thus you could keep your encrypted data as a subfolder of your repository, while providing your application a decrypted view to the data mounted aside. As the encryption is transparent, no special operations are needed on pull or push.
It would however need to mount th... | 0 | false | 6 | 1,988 |
2012-07-20 08:11:06.813 | How can I save my secret keys and password securely in my version control system? | I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.
But passwords--like any other setting--seem like they should be versioned. So what ... | This is what I do:
Keep all secrets as env vars in $HOME/.secrets (go-r perms) that $HOME/.bashrc sources (this way if you open .bashrc in front of someone, they won't see the secrets)
Configuration files are stored in VCS as templates, such as config.properties stored as config.properties.tmpl
The template files cont... | 0.047982 | false | 6 | 1,988 |
2012-07-20 19:04:05.503 | MySQL Joins Between Databases On Different Servers Using Python? | Database A resides on server server1, while database B resides on server server2.
Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).
In such a case, is it possible to perform a join between a table ... | I don't know python, so I'm going to assume that when you do a query it comes back to python as an array of rows.
You could query table A and after applying whatever filters you can, return that result to the application. Same to table B. Create a 3rd Array, loop through A, and if there is a joining row in B, add that ... | 0 | false | 2 | 1,989 |
2012-07-20 19:04:05.503 | MySQL Joins Between Databases On Different Servers Using Python? | Database A resides on server server1, while database B resides on server server2.
Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).
In such a case, is it possible to perform a join between a table ... | Without doing something like replicating database A onto the same server as database B and then doing the JOIN, this would not be possible. | 0 | false | 2 | 1,989 |
2012-07-21 06:48:35.803 | sqlite timezone now | I am using python and sqlite3 to handle a website. I need all timezones to be in localtime, and I need daylight savings to be accounted for. The ideal method to do this would be to use sqlite to set a global datetime('now') to be +10 hours.
If I can work out how to change sqlite's 'now' with a command, then I was going... | you can try this code, I am in Taiwan , so I add 8 hours:
DateTime('now','+8 hours') | 0.386912 | false | 1 | 1,990 |
2012-07-21 13:05:13.397 | keyboard interrupt doesn't stop my interpreter | I am testing a Log-parser that does a infinite loop (on purpose) with a cool down of 3 seconds every recurrence.
Eventually I will link all the data to a GUI front-end so I can call a stop to the loop when the user is ready with parsing.
The (small) problem now is, when testing the output in the Terminal (in OSX) when ... | CTRL + Z sends to background, CTRL + C is to kill. However I am talking Linux here and Mac might be something different. | 1.2 | true | 1 | 1,991 |
2012-07-21 16:47:26.823 | how to select next item of wxlistbox in wxpython? | I am making a music player in python/wxpython. I have a listbox with all the songs, and the music player plays the selected song. I am now trying to make a "next button" to select the next item in the listbox and play it. How would I go about doing that? Is there something like GetNextString() or something along those ... | Not to my knowledge. Just keep track of the currently selected item's placement in the list and update it by incrementing or decrementing it. | 1.2 | true | 1 | 1,992 |
2012-07-23 09:37:05.457 | Difference between Model and Form validation | I'm currently working on a model that has been already built and i need to add some validation managment. (accessing to two fields and checking data, nothing too dramatic)
I was wondering about the exact difference between models and forms at a validation point of view and if i would be able to just make a clean method... | Generally models represent business entities which may be stored in some persistent storage (usually relational DB). Forms are used to render HTML forms which may retreive data from users.
Django supports creating forms on the basis of models (using ModelForm class). Forms may be used to fetch data which should be save... | 0 | false | 1 | 1,993 |
2012-07-23 11:10:23.967 | User Input Python Script Executing Daemon | I am working on a web service that requires user input python code to be executed on my server (we have checks for code injection). I have to import a rather large module so I would like to make sure that I am not starting up python and importing the module from scratch each time something runs (it takes about 4-6s). ... | You could perhaps consider to create a pool of python daemon processes?
Their purpose would be to serve one request and to die afterwards.
You would have to write a pool-manager that ensures that there are always X daemon processes waiting for an incoming request. (X being the number of waiting daemon processes: depend... | 1.2 | true | 1 | 1,994 |
2012-07-24 09:23:55.767 | Keep cmd.exe open | I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output?
EDIT: the problem was that it gave the whole path not only the filename. | Another possible option is to create a basic TKinter GUI with a textarea and a close button. Then run that with subprocess or equiv. and have that take the stdout from your python script executed with pythonw.exe so that no CMD prompt appears to start with.
This keeps it purely using Python stdlib's and also means you ... | 0.081452 | false | 2 | 1,995 |
2012-07-24 09:23:55.767 | Keep cmd.exe open | I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output?
EDIT: the problem was that it gave the whole path not only the filename. | Either right-click your script and remove Program->Close on exit checkbox in its properties, or use cmd /k as part of its calling line.
Think twice before introducing artificial delays or need to press key - this will make your script mostly unusable in any unattended/pipe calls. | 0.081452 | false | 2 | 1,995 |
2012-07-24 20:10:24.333 | Using POUND SIGN as a string in PYTHON? | I want to have a string containing 4 pound signs..how can I accomplish this in Python without commenting the string out due to the pound signs? | If some IDE interprets '####' as a half-baked string plus a comment, change the IDE! | 0.135221 | false | 1 | 1,996 |
2012-07-25 10:33:19.880 | How do I debug a Python extension written in C? | How do I debug a Python extension written in C? I found some links that said we need to get the Python debug built, but how do we do that if we don't have root access? I have Python 2.7 installed. | You can compile a debug-enabled version python in your home folder without having root access and develop the C extension against that version. | 0.386912 | false | 1 | 1,997 |
2012-07-26 01:22:24.130 | How to start Python IDLE from python.exe window if possible, and if not, what is python.exe even used for? | I am running Windows 7 currently, and I remember when using Linux at the school computers I was able to type "gedit &" into the terminal for example to open up the gedit text editor. I was wondering whether there is a similar process to open IDLE, and for that matter a Python program/script by typing it into the "termi... | python.exe is Python, the python interpreter specifically. | 0 | false | 1 | 1,998 |
2012-07-26 11:55:29.427 | Unmake move vs copy board in chess programming | I'm at the start of creating a chess engine. When I created a function that checks if a move is legal, first I had to make the move and then check if the move had put my king in check and then unmake it.
After giving some thought on how to make a function that unmakes a move, I decided it's much simpler to just copy t... | Generally the unmake approach is used more as it avoids unnecessary copying of the board. This is especially true if you want to keep your pieces in two different forms in your Position class; as a traditional 8x8 array and as a set of 64-bit unsigned integers (bitboards).
You need to create a class to store your Unma... | 0.986614 | false | 1 | 1,999 |
2012-07-27 13:08:46.357 | How to show continuous real time updates like facebook ticker, meetup.com home page does? | How to show continuous real time updates in browser like facebook ticker, meetup.com home page does? In python, PHP, node.js and what would be the performance impact at the server side ?
Also how could we achieve the same update thing if the page is cached by an CDN like akamai? | You could use a poll, long-poll or if you want a push system. Easiest would be a poll. However, all solutions require client side coding.
Performance impact depends on your solution. Easiest to implement would be a poll. A poll with short frequency does effectively a request every, say 100ms ot simulate real time. A lo... | 0 | false | 1 | 2,000 |
2012-07-27 13:53:32.747 | Python, UTF-8 filesystem, iso-8859-1 files | I have an application written in Python 2.7 that reads user's file from the hard-drive using os.walk.
The application requires a UTF-8 system locale (we check the env variables before it starts) because we handle files with Unicode characters (audio files with the artist name in it for example), and want to make sure w... | Use character encoding detection, chardet modules for python work well for determining actual encoding with some confidence. "as appropriate" -- You either know the encoding or you have to guess at it. If with chardet you guess wrong, at least you tried. | 0 | false | 1 | 2,001 |
2012-07-27 17:50:27.053 | How to create a DLL with SWIG from Visual Studio 2010 | I've been trying for weeks to get Microsoft Visual Studio 2010 to create a DLL for me with SWIG. If you have already gone through this process, would you be so kind as to give a thoughtful step-by-step process explanation? I've looked everywhere online and have spent many many hours trying to do this; but all of the tu... | Step-by-step instructions. This assumes you have the source and are building a single DLL extension that links the source directly into it. I didn't go back through it after creating a working project, so I may have missed something. Comment on this post if you get stuck on a step. If you have an existing DLL and w... | 1.2 | true | 1 | 2,002 |
2012-07-27 21:06:23.343 | How do I tell my main GUI to wait on a worker thread? | I have successfully outsourced an expensive routine in my PyQT4 GUI to a worker QThread to prevent the GUI from going unresponsive. However, I would like the GUI to wait until the worker thread is finished processing to continue executing its own code.
The solution that immediately comes to my mind is to have the threa... | This is a really bad plan. Split up the 'before thread action' and 'after thread action'. The 'after thread action' should be a slot fired by a QueuedConnection that the thread can signal.
Do not wait in GUI event handlers! | 0.201295 | false | 2 | 2,003 |
2012-07-27 21:06:23.343 | How do I tell my main GUI to wait on a worker thread? | I have successfully outsourced an expensive routine in my PyQT4 GUI to a worker QThread to prevent the GUI from going unresponsive. However, I would like the GUI to wait until the worker thread is finished processing to continue executing its own code.
The solution that immediately comes to my mind is to have the threa... | If the GUI thread called the wait() function on the worker thread object, it would not return from it until the worker thread returns from its main function. This is not what you want to do.
The solution you describe using signal and slots seems to make plenty of sense to me. Or you could just use a boolean. | 0 | false | 2 | 2,003 |
2012-07-28 00:47:13.267 | Python: trying to raise multi-purpose exception for multiple error types | I'm working with urllib and urllib2 in python and am using them to retrieve images from urls.
Using something similar to :
try:
buffer=urllib2.url_open(urllib2.Request(url))
f.write(buffer)
f.close
except (Errors that could occur): #Network Errors(?)
print "Failed to retrieve "+url
pass
Now wha... | There are only two exceptions you'll see, HTTPError (HTTP status codes) and URLError (everything that can go wrong), so it's not like it's overkill handling both of them. You can even just catch URLError if you don't care about status codes, since HTTPError is a subclass of it. | 1.2 | true | 1 | 2,004 |
2012-07-29 00:57:40.280 | Using Regular Expression with Twill | I'm currently using urllib2 and BeautifulSoup to open and parse html data. However I've ran into a problem with a site that uses javascript to load the images after the page has been rendered (I'm trying to find the image source for a certain image on the page).
I'm thinking Twill could be a solution, and am trying to ... | I'd rather user CSS selectors or "real" regexps on page source. Twill is AFAIK not being worked on. Have you tried BS or PyQuery with CSS selectors? | 0 | false | 1 | 2,005 |
2012-07-29 21:53:11.163 | Need to create thumbnail from user submitted url like reddit/facebook | I am pretty new to Django so I am creating a project to learn more about how it works. Right now I have a model that contains a URL field. I want to automatically generate a thumbnail from this url field by taking an appropriate image from the webite like facebook or reddit does. I'm guessing that I should store this i... | You'll first need to parse the html content for img src urls with something like lxml or BeautifulSoup. Then, you can feed one of those img src urls into sorl-thumbnail or easy-thumbnails as Edmon suggests. | 1.2 | true | 1 | 2,006 |
2012-07-30 06:58:15.400 | Can each node of selenium grid run different script/test? - how to setup? | Can each node of selenium grid run different python script/test?
- how to setup? | Yes, use different browser configurations in the hub, and use two or more programs to contact the grid with different browsers | 1.2 | true | 1 | 2,007 |
2012-07-30 10:26:54.803 | Looking for a way to use Pywinauto on Win x64 | I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't.
On installation there are several assertions about wrong win structures size. If commented o... | win32structure.py
ensure HANDLE is c_void_p
redefine other handles like HBITMAP to HANDLE
ensure pointers are pointers and not long | -0.201295 | false | 2 | 2,008 |
2012-07-30 10:26:54.803 | Looking for a way to use Pywinauto on Win x64 | I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't.
On installation there are several assertions about wrong win structures size. If commented o... | Azurin, you always can use python32bit + pywinauto on your x64 OS. If you realy need python64 you also can use py2exe to compile a test in .exe and use it everywhere, even on OSes where python is not installed. :) | 0.101688 | false | 2 | 2,008 |
2012-07-30 16:03:35.777 | Group chat application in python using threads or asycore | I am developing a group chat application to learn how to use sockets, threads (maybe), and asycore module(maybe).
What my thought was have a client-server architecture so that when a client connects to the server the server sends the client a list of other connects (other client 'user name', ip addres) and then a perso... | For a group chat application, the general approach will be:
Server side (accept process):
Create the socket, bind it to a well known port (and on appropriate interface) and listen
While (app_running)
Client_socket = accept (using serverSocket)
Spawn a new thread and pass this socket to the thread. That thread handles... | 1.2 | true | 1 | 2,009 |
2012-07-30 16:11:33.347 | python: How to detect when my thread become orphan? | I have a program using a thread. When my program is closed, my thread is still running and that's normal. I would like to know how my thread can detect that the main program is terminated; by itself ONLY. How would I do that?
My thread is in an infinite loop and process many object in a Queue. I can't define my thread ... | Would it work if your manager tracked how many open threads there were, then the children killed themselves when starved of input? So the parent would start pushing data on to the queue, and the workers would consume data from the queue. If a worker found nothing on the queue for a certain timeout period, it would ki... | 0 | false | 2 | 2,010 |
2012-07-30 16:11:33.347 | python: How to detect when my thread become orphan? | I have a program using a thread. When my program is closed, my thread is still running and that's normal. I would like to know how my thread can detect that the main program is terminated; by itself ONLY. How would I do that?
My thread is in an infinite loop and process many object in a Queue. I can't define my thread ... | If you can get a handle to the main thread, you can call is_alive() on it.
Alternatively, you can call threading.enumerate() to get a list of all currently living threads, and check to see if the main thread is in there.
Or if even that is impossible, then you might be able to check to see if the child thread is the ... | 1.2 | true | 2 | 2,010 |
2012-07-30 20:51:50.040 | Build systems in Sublime Text | I'm just beginning to learn programming (on C++ and Python), and by beginning I mean total beginning ("hello world" beginning...). Not wanting to use multiple IDE's, I would like to be able to code and build–simple–programs with my text editor, Sublime Text 2. Could someone indicate me, with a step-by-step tutorial, ho... | windows(install minigw, python2.7 and added to the system path)
cpp:
build: ctrl+b
run: ctrl+shift+b
python:
build and run: ctrl+b
you may try to learn the the .sublime-build files in your Tools -> Build system -> New build system | 0.201295 | false | 1 | 2,011 |
2012-07-30 22:36:57.290 | Trouble giving values to deck of cards | (Cards numbered 2-10 should be valued from 2-10, respectively. J,Q, and K should be 10, and A should be either 1 or 11, depending on the value of the hand).
How do I assign the deck these values? Also, the game needs to be 3 rounds. The way I did it is only one round. How do I make the game go three times, while keepin... | You should probably calculate the total dynamically. Also, you need some kind of way to store the money of each individual player. Right now, there is no way of knowing the distribution of money since you only have one total. | 0 | false | 1 | 2,012 |
2012-08-01 08:34:00.397 | many selects (dropdowns) on html form, how to get just the value of the select that was changed | In a python cgi script I have many selects in a form (100 or so), and each select has 5 or 6 options to choose from. I don't want to have a separate submit button, so I am using onchange="submit();" to submit the form as soon as an option is selected from one of the many selects. When I read the form data with form.... | If every select should be the only value that's needed, then every select is basically a form on its own.
You could either remove all other selects when you activate a single select (which is prone to errors), or simply put every select in its own form instead of using one giant form. Otherwise all data is going to be ... | 1.2 | true | 1 | 2,013 |
2012-08-01 09:13:02.930 | Django: writing test for multiple database site | I have 2 sites: A and B. A relies on some tables from B so it has an entry in its DATABASES settings pointing to B together with some entries under its DATABASE_ROUTERS settings to route certain model access to B's database.
Now I'm trying to write a test on A but just running manage.py test immediately fails because s... | I finally get the tests running, here's what I did:
disabled DATABASE_ROUTERS settings when running tests
maintain B alias in DATABASES settings but the name is the same as A
append B's INSTALLED_APPS that aren't present to A's INSTALLED_APPS | 0 | false | 1 | 2,014 |
2012-08-01 14:53:02.740 | Get Image File Size From Base64 String | I'm working on a python web service.
It calls another web service to change the picture of a profile.
It connects to another web service.
This web service can only accept pictures that are 4 MB or smaller.
I will put the checking in the first web service.
It uses PIL to check if the base64 string is a valid image.
Howe... | Multiply the length of the data by 3/4, since encoding turns 6 bytes into 8. If the result is within a few bytes of 4MB then you'll need to count the number of = at the end. | 1.2 | true | 1 | 2,015 |
2012-08-01 15:15:16.247 | Memory usage in django-imagekit is unacceptable -- ideas on fixes? | Django-imagekit, which I'm using to process user uploaded images on a social media website, uses an unacceptably high level of memory. I'm looking for ideas on how to get around this problem.
We are using django-imagekit to copy user uploaded images it into three predefined sizes, and saves the four copies (3 processe... | Try to change image size with PIL from console and see if memory usage is ok. Image resize is a simple task, I don't believe you should use side applications. Besides, split your task into 3 tasks(3 images?). | 1.2 | true | 1 | 2,016 |
2012-08-01 15:32:20.857 | Pass information from javascript to django app and back | So I'm trying to basically set up a webpage where a user chooses an id, the webpage then sends the id information to python, where python uses the id to query a database, and then returns the result to the webpage for display.
I'm not quite sure how to do this. I know how to use an ajax call to call the data generated ... | Yes, it is possible. If you pass the id as a parameter to the view you will use inside your app, like:
def example_view (request,id)
and in urls.py, you can use something like this:
url(r'^example_view/(?P<id>\d+)/', 'App.views.example_view').
The id in the url /example_view_template/8 will get access to the result... | 0.135221 | false | 1 | 2,017 |
2012-08-01 17:37:08.147 | Submitting Multiple Forms At The Same Time (Edit Profile Page) | My question I suppose is rather simple. Basically, I have a profile. It has many variables being passed in. For instance, name, username, profile picture, and many others that are updated by their own respective pages. So one page would be used to update the profile picture, and that form would submit data from the for... | I've used django on most of my webapps, but the concept should be the same; I use ajax to send the data to the backend whenever the user hits submit (and the form returns false) so the user can keep editing it. With ajax, you can send the data to different handlers on the backend. Also, using jQuery, you can set flag... | 1.2 | true | 1 | 2,018 |
2012-08-01 17:51:35.407 | Login as root in Ajaxterm | I am trying to use Ajaxterm and I remember that when I used it for the first time about a year ago, there was something about logging in as root.
Can anyone tell me how to enable root login or point me to a guide? Many different google searches have returned no results.
P.S. My question is NOT whether or not I should... | Once you have logged in as a non-root user you can just su to the root user | 1.2 | true | 1 | 2,019 |
2012-08-01 18:14:23.060 | How to use a different database host in development vs deployment? | I'm new to Python and Django and have over the past few weeks managed to set up my first deployment - a very basic site with user authentication and a few pages, which I hope to fill with content in the next couple of weeks.
I have managed to find the answer to probably 40+ questions I have encountered so far by searc... | You can have two copies of your settings.py file, one for production and one for development. Whatever you need to be the default, name it as settings.py
Just set DJANGO_SETTINGS_MODULE to the python path for the file that you would like to use.
So, if your settings files are myproject/settings.py, myproject/settings_d... | 1.2 | true | 1 | 2,020 |
2012-08-02 00:30:42.147 | rpy2: Convert FloatVector or Matrix back to a Python array or list? | I'm using rpy2 and I have this issue that's bugging me: I know how to convert a Python array or list to a FloatVector that R (thanks to rpy2) can handle within Python, but I don't know if the opposite can be done, say, I have a FloatVector or Matrix that R can handle and convert it back to a Python array or list...can ... | In the latest version of rpy2, you can simply do this in a direct way:
import numpy as np
array=np.array(vector_R) | 0.296905 | false | 1 | 2,021 |
2012-08-02 02:36:03.857 | Distinguishing post request's from possible poster elements | So, what issue im running into is how do i know what element of my page made a post request? I have multiple elements that can make the post request on the page, but how do i get the values from the element that created the request? It seems like this would be fairly trivial,but i have come up with nothing, and when do... | You could add a hidden input field to each form on the page with a specific value. On the server side, check the value of this field to detect which form the post request came from. | 1.2 | true | 1 | 2,022 |
2012-08-02 21:49:06.363 | How to hook custom file parser to Gstreamer Decoder? | The HTTP file and its contents are already downloaded and are present in memory. I just have to pass on the content to a decoder in gstreamer and play the content. However, I am not able to find the connecting link between the two.
After reading the documentation, I understood that gstreamer uses httpsoupsrc for downlo... | You can use appsrc. You can pass chunks of your data to app source as needed. | 1.2 | true | 1 | 2,023 |
2012-08-03 08:58:21.680 | Using WebSphere MQ with Twisted | I'm trying to work out how to approach building a "machine" to send and receive messages to WebSphere MQ, via Twisted. I want it to be as generic as possible, so I can reuse it for many different situations that interface with MQ.
I've used Twisted before, but many years ago now and I'm trying to resurrect the knowled... | If you're going to use this functionality a lot, then having a native Twisted implementation is probably worth the effort. A wrapper based on deferToThread will be less work, but it will also be harder to test and debug, perform less well, and have problems on certain platforms where Python threads don't work extremel... | 1.2 | true | 1 | 2,024 |
2012-08-03 10:27:29.657 | recompile vim with +python | When I try to use omnicomplete in a .py file vim says that I need to compile vim with +python support. I already have a bunch of plugins downloaded in my vimfiles with pathogen so how do I recompile vim 7.3 with +python support without losing my settings? Thanks | Your settings won't be lost if you recompile vim: recompilation will simply create a new vim executable. If you are using a common Linux distribution, though, you might not need to compile anything: Archlinux, for example, bundles "vim compiled with +python" in the gvim package. Your distro might do something similar. | 1.2 | true | 1 | 2,025 |
2012-08-04 14:39:18.463 | Monitor concurrency (sharing object across processes) in Python | I'm new here and I'm Italian (forgive me if my English is not so good).
I am a computer science student and I am working on a concurrent program project in Python.
We should use monitors, a class with its methods and data (such as condition variables). An instance (object) of this class monitor should be shared accross... | shared memory between processes is usually a poor idea; when calling os.fork(), the operating system marks all of the memory used by parent and inherited by the child as copy on write; if either process attempts to modify the page, it is instead copied to a new location that is not shared between the two processes.
Thi... | 0 | false | 1 | 2,026 |
2012-08-04 15:38:09.870 | All paths of length L from node n using python | Given a graph G, a node n and a length L, I'd like to collect all (non-cyclic) paths of length L that depart from n.
Do you have any idea on how to approach this?
By now, I my graph is a networkx.Graph instance, but I do not really care if e.g. igraph is recommended.
Thanks a lot! | A very simple way to approach (and solve entirely) this problem is to use the adjacency matrix A of the graph. The (i,j) th element of A^L is the number of paths between nodes i and j of length L. So if you sum these over all j keeping i fixed at n, you get all paths emanating from node n of length L.
This will also un... | 0.454054 | false | 1 | 2,027 |
2012-08-05 02:36:58.583 | How do I create a simple pdf file in python? | I'm looking for a way to output a VERY simple pdf file from Python. Basically it will consist of two columns of words, one in Russian (so utf-8 characters) and the other in English.
I've been googling for about an hour, and the packages I've found are either massive overkill (and still don't provide useful examples) su... | A simpler approach would be to use the csv package to write the two columns to a .csv file, then read it into a spreadsheet & print to pdf. Not 100% python but maybe 90% less work ... | 0 | false | 1 | 2,028 |
2012-08-06 03:10:44.763 | python file object how to remove byte from current seed postion to end | python file object how to remove byte from current seed postion to end
f = open(filename, "a+")
truncate_pos = f.tell()
f.truncate(truncate_pos)
seems not work,how could i do? | Opening a file in a+ positions the pointer at the end of the file; truncation from there results in no change to the file. | 0.673066 | false | 1 | 2,029 |
2012-08-06 06:42:15.417 | Python multiprocessing and Django - I'm confused | I'm trying to write a Web app in Python, which is to consist of two parts:
A Django-based user interface, which allows each user to set up certain tasks
Worker processes (one per user), which, when started by the user, perform the tasks in the background without freezing the UI.
Since any object I create in a view is... | You can try celery as it's django friendly.
But if to be honest i'm not fond of it (bugs :)
We are going to switch to Gearman.
Writing your own job producers and consumers (workers) are a kind of a fun! | 0 | false | 1 | 2,030 |
2012-08-06 08:06:17.357 | How to run a python script with Python Tools for Visual Studio in a virtualenv? | I don't know how to run the activate.bat in a Python Tools for Visual Studio Project. I have a directory environment in my project with my virtualenv. But, I don't know how I can run ./env/Scripts/activate.bat before the project run my main python script. | I found that if :
main.py is set as Startup File,
in the Properties of the project -> Debug tab -> Interpreter Path field, I put the path C:...\env\Scripts\python.exe (i.e. the python executable of the virtualenv)
It works ! | 1.2 | true | 1 | 2,031 |
2012-08-06 23:24:08.767 | rename a build in buildbot | Is there a way to rename a build in buildbot without losing all of the logs?
For instance I have several windows slaves which all might build: "Windows 2008+ DEBUG" but I want to rename this build to: "Windows 2008R2+ DEBUG".
How do I set compare_attr (if that's even what I need to do) so that all of the logs/etc... ar... | If you don't care about the name of the directory, just the name of the builder, you can set the builddir attribute of the builder to be whatever it currently is, then name you builder however you want.
The data stored in the builder directory is in pickles. Looking at the code, I think the only data could cause issues... | 1.2 | true | 1 | 2,032 |
2012-08-07 14:55:04.177 | How to run Python script with one icon click? | Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it.
How to run a python script/bytecode/.pyc (any compiled python code) without going through the terminal. Basically on Nautilus: "on double click of the python script, it'll run" or "on select then [Enter], it'll r... | Adding " #!/usr/bin/env python " at the top of the .py file works! Hmm, although don't appreciate the pop-up, but nevermind. :P
From PHPUG:
You do not invoke the pyc file. It's the .py file that's invoked. Python is an interpreted language.
A simpler way to make a python exectuable (explained):
1) Add #!/usr/bin/env ... | 1.2 | true | 2 | 2,033 |
2012-08-07 14:55:04.177 | How to run Python script with one icon click? | Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it.
How to run a python script/bytecode/.pyc (any compiled python code) without going through the terminal. Basically on Nautilus: "on double click of the python script, it'll run" or "on select then [Enter], it'll r... | You should make the .py files executable and click on them. The .pyc files cannot be run directly. | 0.496174 | false | 2 | 2,033 |
2012-08-07 21:41:06.547 | Checking the quality of an Incoming Video with python | I am new to python and programming in general. I was wondering if there is a way to validate that you are getting a video feed and not just a black screen from an incoming call. I have automated a script in Python that makes a call and answers the call, but some of the issues we are testing is how often we get black ... | I do something similar with C++ in OpenCV. There are a couple of ways to go about this.
I use TCP/IP protocols - make sure I don't have packet loss.
Next, To test quality, I send and receive a Video file (that I recorded from the camera) instead of stream "new" video from the camera. Now, I can check the quality by che... | 0 | false | 1 | 2,034 |
2012-08-08 16:27:51.913 | Using TIFF G4 image in PIL | I wrote a pure python TIFF G4 decompress for use with tifffile.py. I know there are ways to add libtiff to a custom PIL, but I never could get that working very well in a mixed virtualenv. I want to manipulate the image in PIL. I am looking for pointers in hooking my decompressor to stock PIL for TiffImagePlugin.py.
A... | It appears that TiffImagePlugin does not easily allow me to hook in additional decompressors. Replacing TiffImageFile._decoder with a dictionary of decoders might work, but you would have to examine and test each release of PIL to ensure it hasn't broken. This level of maintenance is just as bad as a custom PIL. I a... | 1.2 | true | 1 | 2,035 |
2012-08-09 03:52:41.093 | how to make my console in python not to close? | I'm making a application in python from Windows. When I run it in the console, it stops, shows an error, and closes. I can't see the error becase its too fast, and I can't read it. I'm editing the code with IDLE (the program that came with python when I instaled it), and when I run it with the python shell, there are n... | Run your program from a Windows command prompt. That will not automatically close when the program finishes.
If you run your program by double-clicking on the .py file icon, then Windows will close the window when your program finishes (whether it was successful or not). | 1.2 | true | 1 | 2,036 |
2012-08-10 01:18:38.537 | Preparing a pyramid app for production | So as I near the production phase of my web project, I've been wondering how exactly to deploy a pyramid app. In the docs, it says to use ../bin/python setup.py develop to put the app in development mode. Is there another mode that is designed for production. Or do I just use ../bin/python setup.py install. | Well the big difference between python setup.py develop and python setup.py install. Is that install will install the package in your site-packages directory. While develop will install an egg-link that point to the directory for development.
So yeah you can technically use both method. But depending on how you did yo... | 1.2 | true | 1 | 2,037 |
2012-08-10 01:37:09.963 | Testing memory usage of python frameworks in Virtualenv | I'm creating an app in several different python web frameworks to see which has the better balance of being comfortable for me to program in and performance. Is there a way of reporting the memory usage of a particular app that is being run in virtualenv?
If not, how can I find the average, maximum and minimum memory u... | It depends on how you're going to run the application in your environment. There are many different ways to run Python web apps. Recently popular methods seem to be Gunicorn and uWSGI. So you'd be best off running the application as you would in your environment and you could simply use a process monitor to see how muc... | 0.135221 | false | 1 | 2,038 |
2012-08-10 09:03:29.410 | Stop python script in infinite loop | I'm working on a Python script that will constantly scrape data, but it will take quite a long time. Is there a safe way to stop a long running python script? The loop will run for more than 10 minutes and I need a way to stop it if I want, after it's already running.
If I execute it from a cron job, then I'm assuming ... | I guess one way to work around the issue is having a script for one loop run, that would:
check no other instance of the script is running
look into the queue and process everything found there
Now, then you can run this script from cron every minute between 8 a.m. and 8 p.m. The only downside is that new items may s... | 0 | false | 1 | 2,039 |
2012-08-10 14:02:37.470 | Unittest binary file output | I have an array of pixels which I wish to save to an image file. Python appears to have a few libraries which can do this for me, so I'm going to use one of them, passing in my pixel array and using functions I didn't write to write the image headers and data to disk.
How do I do unit testing for this situation?
I ca... | Bit old on Python.
But this is how I would approach it.
Grab the image doing a manual test. Compute a check sum (MD5 perhaps). Then the automated tests need to compare it by computing the MD5 (in this example) with the one done on the manual test.
Hope this helps. | 1.2 | true | 1 | 2,040 |
2012-08-12 21:28:39.213 | Read a file of mixed items and retain their data types | I have a TSV file that consists of integers along with some false data that could be anything such as floats or characters etc.
The idea is to read the contents of the file and find out which ones are bad (containing data other than integers)
Each line can be read using the readline method once the file has been open... | The TSV file has already lost all the type information.
If the pickle module had been used to write out the file, you would have been able to easily unpickle it, however it looks like you just get to read the damaged file, so pickle is no use to you here
The best you can do is attempt to convert each field to int and h... | 0 | false | 1 | 2,041 |
2012-08-13 06:20:34.553 | OpenERP : Saving field value (amount) into an account | I'm new to OpenERP and python and I need some help saving an amount into a particular account.
I have created a field in the invoice form that calculates a specific amount based on some code and displays that amount in the field. What I want to do is to associate an account with this field, so when the invoice is valid... | You can override "pay_and_reconcile" function to write in account field, this function is called at time of Pay.
action_date_assign()
action_move_create()
action_number()
this 3 function are called at time of validating invoice.
You can override any one from this or you can add your own function . in workflow for the ... | 1.2 | true | 1 | 2,042 |
2012-08-15 13:23:36.320 | Website sync of contacts and reminders with iCloud | I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well. | I would recommend that you sync using the google contacts api. Then, you can tell iPhone people to use that instead of iCloud. | 0 | false | 2 | 2,043 |
2012-08-15 13:23:36.320 | Website sync of contacts and reminders with iCloud | I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well. | To the best of my knowledge, there is no way to interface with iCloud directly; it can only be done through an iOS or Mac OS app, and by calling the correct iCloud Objective-C APIs with UI/NSDocument classes. Since you are not using Cocoa, let alone Objective-C, you will most likely not be able to do this. I may be wro... | 0.101688 | false | 2 | 2,043 |
2012-08-15 13:35:18.467 | Background python program inspect GUI events | I am thinking of writing a python program that runs in the background and can inspect user's GUI events.
My requirements is very simple:
1) When user right click the mouse, it can show an option; and when this option is chosen, my program should know this event.
2) When user select a file and click some predefined key ... | If you're talking about doing this stuff inside of a wxPython program, then it's all pretty simple. There's a PopupMenu widget for the first one and an AcceratorTable for the second one. If you're wanting to catch mouse and keyboard events outside of a wxPython program, then you have to go very low-level and hook into ... | 0.386912 | false | 1 | 2,044 |
2012-08-16 13:49:03.683 | How to run PyCharm using port 80 | I can't run my PyCharm IDE using port 80.
I need to use PayPal that requires me to use port 80.
But using Mac OS X 10.8 I can't have it working because of permission issues.
I've already tried running PyCharm with SUDO command.
Does anyone know how to run Pycharm using port 80, or any other solution?
Thanks. | To give PyCharm permissions, one has to run as Administor (Windows) or using sudo if on OSX/Linux: sudo /Applications/PyCharm.app/Contents/MacOS/pycharm. Note that this truly runs PyCharm as a new user, so you'll have to register the app again and set up your customizations again if you have any (ie theme, server prof... | 0.201295 | false | 2 | 2,045 |
2012-08-16 13:49:03.683 | How to run PyCharm using port 80 | I can't run my PyCharm IDE using port 80.
I need to use PayPal that requires me to use port 80.
But using Mac OS X 10.8 I can't have it working because of permission issues.
I've already tried running PyCharm with SUDO command.
Does anyone know how to run Pycharm using port 80, or any other solution?
Thanks. | For the ones who are looking for the answer of this question, please check your Pycharm Run/Debug Configurations. Run->Edit Configurations ->Port | 0.101688 | false | 2 | 2,045 |
2012-08-16 14:29:29.977 | When to disconnect from mongodb | I am fairly new to databases and have just figured out how to use MongoDB in python2.7 on Ubuntu 12.04. An application I'm writing uses multiple python modules (imported into a main module) that connect to the database. Basically, each module starts by opening a connection to the DB, a connection which is then used for... | You can use one pymongo connection across different modules. You can open it in a separate module and import it to other modules on demand. After program finished working, you are able to close it. This will be the best option.
About other questions:
You can leave like this (all connections will be closed when script ... | 1.2 | true | 1 | 2,046 |
2012-08-16 19:54:55.030 | Logging an unknown number of floats in a python C extension | I'm using python to set up a computationally intense simulation, then running it in a custom built C-extension and finally processing the results in python. During the simulation, I want to store a fixed-length number of floats (C doubles converted to PyFloatObjects) representing my variables at every time step, but I ... | You might want to consider doing this in Cython, instead of as a C extension module. Cython is smart, and lets you do things in a pretty pythonic way, even though it at the same time lets you use C datatypes and python datatypes.
Have you checked out the array module? It allows you to store lots of scalar, homogeneou... | 1.2 | true | 2 | 2,047 |
2012-08-16 19:54:55.030 | Logging an unknown number of floats in a python C extension | I'm using python to set up a computationally intense simulation, then running it in a custom built C-extension and finally processing the results in python. During the simulation, I want to store a fixed-length number of floats (C doubles converted to PyFloatObjects) representing my variables at every time step, but I ... | This is going to be more a huge dump of ideas rather than a consistent answer, because it sounds like that's what you're looking for. If not, I apologize.
The main thing you're trying to avoid here is storing billions of PyFloatObjects in memory. There are a few ways around that, but they all revolve on storing billion... | 0.201295 | false | 2 | 2,047 |
2012-08-16 23:43:42.840 | How to develop an AI script | I am amateur Programmer looking to develop a game. I've decided to use Python and pygame. (I know, there are better options out there, but I really don't know C++ or java that well.) The issue I'm having is that I really have no idea how to create a decent AI. I'm talking about the sort of AI that has monsters move thi... | basically its
Default Behavior:Random Walk
if player is within X distance: Melee Attack
if player is within Y distance: Charge Player
if player is within Z distance: Cast spell
if player is outside range and MOB has agro move toward player
thats the extent of most AI... at least game AI
its too cpu intensive to do ... | 0.265586 | false | 1 | 2,048 |
2012-08-17 02:48:36.830 | Is it possible to use complex numbers as target labels in scikit learn? | I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.
I cannot find any documenta... | Several regressors support multidimensional regression targets. Just view the complex numbers as 2d points. | 0.496174 | false | 3 | 2,049 |
2012-08-17 02:48:36.830 | Is it possible to use complex numbers as target labels in scikit learn? | I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.
I cannot find any documenta... | Good question. How about transforming angles into a pair of labels, viz. x and y co-ordinates. These are continuous functions of angle (cos and sin). You can combine the results from separate x and y classifiers for an angle? $\theta = \sign(x) \arctan(y/x)$. However that result will be unstable if both classifiers ret... | 0.135221 | false | 3 | 2,049 |
2012-08-17 02:48:36.830 | Is it possible to use complex numbers as target labels in scikit learn? | I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.
I cannot find any documenta... | So far I discovered that most classifiers, like linear regressors, will automatically convert complex numbers to just the real part.
kNN and RadiusNN regressors, however, work well - since they do a weighted average of the neighbor labels and so handle complex numbers gracefully.
Using a multi-target classifier is anot... | 1.2 | true | 3 | 2,049 |
2012-08-17 05:25:01.070 | Does Eclipse have indentation guides? | Recently, I use Eclipse to edit my python code. But lacking indentation guides, I feel not very well. So how to add the auto indentation guides for Eclipse? Is there certain plugin?
What's more, I have tried the EditBox. But, you know, that is not very natural under some themes............... | As for me, all I do with Eclipse for working with Python:
Install pydev
Set tabs to be replaced by spaces
Set tab length to 4
you can make tabs and spaces visual by displaying non-printable symbols.
Hopefully, this is what you meant. | 0.081452 | false | 1 | 2,050 |
2012-08-17 12:09:13.097 | python how to overcome global interpretor lock | I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading.
To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest ses... | I don't think you'll have RuntimeErrors because of the GIL. Can you paste the traceback? If you have some critical parts of the code that are not re entrant, you'll have to isolate them using some concurrency primitives.
The main issue with the GIL is that it will forcibly serialise computation. The result is reduced ... | 0.386912 | false | 2 | 2,051 |
2012-08-17 12:09:13.097 | python how to overcome global interpretor lock | I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading.
To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest ses... | Instead of using threads, use different processes and use some sort of IPC to communicate between each process. | 0.545705 | false | 2 | 2,051 |
2012-08-17 23:03:05.907 | How do I communicate between 2 Python programs using sockets that are on separate NATs? | I want to send and receive messages between two Python programs using sockets. I can do this using the private IPs when the computers are connected to the same router, but how do I do it when there are 2 NATs separating them?
Thanks (my first SO question) | Redis, could work but not the exact same functionality. | 0 | false | 1 | 2,052 |
2012-08-18 06:32:30.260 | Making a 2d game in Python - which library should be used? | I'm looking to make a 2d side scrolling game in Python, however I'm not sure what library to use. I know of PyGame (Hasn't been updated in 3 years), Pyglet, and PyOpenGL. My problem is I can't find any actually shipped games that were made with Python, let alone these libraries - so I don't know how well they perform i... | Pygame should suffice for what you want to do. Pygame is stable and if you look around the websites you will find games which have been coded in pygame. What type of game are you looking to implement? | 0.135221 | false | 1 | 2,053 |
2012-08-19 00:55:57.253 | Selenium in Python: how to click non-English link? | I want to find a link by its text but it's written in non-English characters (Hebrew to be precise, if that matters). The "find_element_by_link_text('link_text')" method would have otherwise suited my needs, but here it fails. Any idea how I can do that? Thanks. | In the future you need to pastebin a representative snippet of your code, and certainly a traceback. I'm going to assume that when you say "the code does not compile" that you mean that you get an exception telling you you haven't declared an encoding.
You need a line at the top of your file that looks like # -*- codin... | 0 | false | 1 | 2,054 |
2012-08-20 08:25:06.820 | From MongoDB to PostgreSQL - Django | Could any one shed some light on how to migrate my MongoDB to PostgreSQL? What tools do I need, what about handling primary keys and foreign key relationships, etc?
I had MongoDB set up with Django, but would like to convert it back to PostgreSQL. | Whether the migration is easy or hard depends on a very large number of things including how many different versions of data structures you have to accommodate. In general you will find it a lot easier if you approach this in stages:
Ensure that all the Mongo data is consistent in structure with your RDBMS model and... | 0.201295 | false | 1 | 2,055 |
2012-08-20 11:11:25.890 | Making a job fail in jenkins | This question might sound weird, but how do I make a job fail?
I have a python script that compiles few files using scons, and which is running as a jenkins job. The script tests if the compiler can build x64 or x86 binaries, I want the job to fail if it fails to do one of these.
For instance: if I'm running my scrip... | I came across this as a noob and found the accepted answer is missing something if you're running python scripts through a Windows batch shell in Jenkins.
In this case, Jenkins will only fail if the very last command in the shell fails. So your python command may fail but if there is another line after it which changes... | 0 | false | 1 | 2,056 |
2012-08-20 23:51:03.063 | sqlite3: safe multitask read & write - how to? | I have two programs: the first only write to sqlite db, and the second only read. May I be sure that there are never be some errors? Or how to avoid from it (in python)? | generally, it is safe if there is only one program writing the sqlite db at one time.
(If not, it will raise exception like "database is locked." while two write operations want to write at the same time.)
By the way, it is no way to guarantee the program will never have errors. using Try ... catch to handle exception ... | 0.201295 | false | 1 | 2,057 |
2012-08-21 11:14:07.727 | Previous weekday in Python | In Python, given a date, how do I find the preceding weekday? (Weekdays are Mon to Fri. I don't care about holidays) | in datetime module you can do something like this: a = date.today() - timedelta(days=1)
and then a.weekday(). Where monday is 0 and sunday is 6. | 0.101688 | false | 1 | 2,058 |
2012-08-22 11:53:01.197 | Stop packets at the network card | This is the problem I'm trying to solve,
I want to write an application that will read outbound http request packets on the same machine's network card. This would then be able to extract the GET url from it.On basis of this information, I want to be able to stop the packet, or redirect it , or let it pass.
However I ... | Using pcap you cannot stop the packets, if you are under windows you must go down to the driver level... but you can stop only packets that your machine send.
A solution is act as a pipe to the destination machine: You need two network interfaces (without address possibly), when you get a packet that you does not found... | 0 | false | 1 | 2,059 |
2012-08-23 14:38:06.910 | Decode SIP messages with Python | I need python script that can sniff and decode SIP messages in order to check their correctness.
As a base for this script I use python-libpcap library for packets sniffing. I can catch UDP packet and extract SIP payload from it, but I don't know how to decode it. Does python has any libraries for packets decoding? I'v... | Finally I did this with help of pyshark from the sharktools (http://www.mit.edu/~armenb/sharktools/). In order to sniff IP packages I used scapy instead of libpcap. | 1.2 | true | 1 | 2,060 |
2012-08-23 19:01:46.957 | How can I trigger a function anytime there is a new session in a GAE/Python Application? | I am a newbie to Google App Engine and Python.
I want to create an entry in a SessionSupplemental table (Kind) anytime a new user accesses the site (regardless of what page they access initially).
How can I do this?
I can imagine that there is a list of standard event triggers in GAE; where would I find these documente... | I am trying to be pretty general here as I don't know whether you are using the default users service or not and I don't know how you are uniquely linking your SessionSupplemental entities to users or whether you even have a way to identify users at this point. I am also assuming you are using some version of webapp as... | 0 | false | 1 | 2,061 |
2012-08-23 19:17:20.943 | Static factory for PyTypeObject | I am using the Python C API and trying to create a function that will allocate new instances of PyTypeObjects to use in several C++ classes. The idea is that each class would have a pointer to a PyTypeObject that would get instantiated with this factory. The pointers must be static.
However, I'm having issues with thi... | Try this: create a 'template' PyTypeObject, and use struct copying (or memcpy) to clone the basic template. Then you can fill it in with the requisite field definitions after that. This solves (2), since you only have to declare the full PyTypeObject once.
For your first point, you just set the static variable from you... | 0 | false | 1 | 2,062 |
2012-08-24 01:15:40.230 | how to set python IDLE's default python? | I installed python 3.2 and later installed python 2.7. Somehow the IDLE, which I open it by right-click on python file -> Edit with IDLE, are using python 2.7 instead of python 3.2.
It seems that python 2.7 was set as default with IDLE. Even if I changed the PATH environment variable in windows advance setting back to ... | The IDLE context menu plug-in is registered when you install Python and points to the version of IDLE supplied with the Python installed. (IDLE itself has significant code changes between Python 2 and 3 because it's written in Python and the language changed a lot.) To change it, simply re-install the version of Python... | 0.386912 | false | 1 | 2,063 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.