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-08-24 08:38:31.130
Executing a python script in a subprocess - with graphics
I've seen a lot of stuff about running code in subprocesses or threads, and using the multiprocessing and threading modules it's been really easy. However, doing this in a GUI adds an extra layer of complication. From what I understand, the GUI classes don't like it if you try and manipulate them from multiple threads ...
I don't no much about wx, I work with jython(python implemented in java and you can use java) and swing. Swing has its own worker thread, and if you do gui updates you wrap your code into a runnable and invoke it with swing.invokelater. You could see if wx has something like that, if you however are only allowed to man...
0.101688
false
1
2,064
2012-08-24 11:45:04.293
How can use Google App Engine with MS-SQL
I use python 2.7 pyodbc module google app engine 1.7.1 I can use pydobc with python but the Google App Engine can't load the module. I get a no module named pydobc error. How can I fix this error or how can use MS-SQL database with my local Google App Engine.
You could, at least in theory, replicate your data from the MS-SQL to the Google Cloud SQL database. It is possible create triggers in the MS-SQL database so that every transaction is reflected on your App Engine application via a REST API you will have to build.
0
false
1
2,065
2012-08-24 15:05:17.463
Django databases and threads
In one model I've got update() method which updating few fields and creates one object of some other model. The problem is that data I use to update is fetched from another host (unique for each object) and it could take a moment (host may be offline, and timeout is set to 3sec). And now, I need to update couple of hun...
You can perform actions from different thread manually (eg with Queue and executors pool), but you should note, that Django's ORM manages database connections in thread-local variables. So each new thread = new connection to database (which will be not good idea for 50-100 threads for one request - too many connections...
1.2
true
1
2,066
2012-08-26 20:57:45.717
pause system functionality until my python script is done
I have written a simple python script that runs as soon as a certain user on my linux system logs in. It ask's for a password... however the problem is they just exit out of the terminal or minimize it and continue using the computer. So basically it is a password authentication script. So what I am curious about is ho...
You want the equivalent of a "modal" window, but this is not (directly) possible in a multiuser, multitasking environment. The next best thing is to prevent the user from accessing the system. For example, if you create an invisible window as large as the display, that will intercept any mouse events, and whatever is "...
0.265586
false
2
2,067
2012-08-26 20:57:45.717
pause system functionality until my python script is done
I have written a simple python script that runs as soon as a certain user on my linux system logs in. It ask's for a password... however the problem is they just exit out of the terminal or minimize it and continue using the computer. So basically it is a password authentication script. So what I am curious about is ho...
There will always be a way for the user to get past your script. Let's assume for a moment that you actually manage to block the X-server, without blocking input to your program (so the user can still enter the password). The user could just alt-f1 out of the X-server to a console and kill "your weird app". If you mana...
0.386912
false
2
2,067
2012-08-27 18:11:03.897
is snmp required
is snmp really required to manage devices ? i'd like to script something with python to manage devices (mainly servers), such as disk usage, process list etc. i'm learning how to do and many article speak about snmp protocole. I can't use, for example, psutil, or subprocess or os modules, and send information via udp ...
No, it's not required, but your question is sort of like asking if you're required to use http to serve web pages. Technically you don't need it, but if you don't use it you're giving up interoperability with a lot of existing client software.
0.201295
false
2
2,068
2012-08-27 18:11:03.897
is snmp required
is snmp really required to manage devices ? i'd like to script something with python to manage devices (mainly servers), such as disk usage, process list etc. i'm learning how to do and many article speak about snmp protocole. I can't use, for example, psutil, or subprocess or os modules, and send information via udp ...
The SNMP is a standard monitoring (and configuration) tool used widely in managing network devices (but not only). I don't understand your question fully - is it a problem that you cannot use SNMP because device does not support it (what does it support then?) To script anything you have to know what interface is expos...
1.2
true
2
2,068
2012-08-27 22:18:52.980
PHP Exec() and Python script scaleability
I have a php application that executes Python scripts via exec() and cgi. I have a number of pages that do this and while I know WSGI is the better way to go long-term, I'm wondering if for a small/medium amount of traffic this arrangement is acceptable. I ask because a few posts mentioned that Apache has to spawn ...
In case of CGI, server starts a copy of PHP interpreter every time it gets a request. PHP in turn starts Python process, which is killed after exec(). There is a huge overhead on starting two processes and doing all imports on every request. In case of FastCGI or WSGI, server keeps couple processes warmed up (min and m...
1.2
true
1
2,069
2012-08-28 16:50:06.783
pickle/zodb: how to handle moving .py files with class definitions?
I'm using ZODB which, as I understand it, uses pickle to store class instances. I'm doing a bit of refactoring where I want to split my models.py file into several files. However, if I do this, I don't think pickle will be able to find the class definitions, and thus won't be able to load the objects that I already hav...
Unfortunately, there is no easy solution. You can convert your old-style objects with the refactored ones (I mean classes which are in another file/module) by the following schema add the refactored classes to your code without removing the old-ones walk through your DB starting from the root and replacing all old obj...
0.135221
false
2
2,070
2012-08-28 16:50:06.783
pickle/zodb: how to handle moving .py files with class definitions?
I'm using ZODB which, as I understand it, uses pickle to store class instances. I'm doing a bit of refactoring where I want to split my models.py file into several files. However, if I do this, I don't think pickle will be able to find the class definitions, and thus won't be able to load the objects that I already hav...
As long as you want to make the pickle loadable without performing a migration to the new class model structure: you can use alias imports of the refactored classes inside the location of the old model.py.
0.386912
false
2
2,070
2012-08-28 21:00:42.300
Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()
I got this: tu = ("func1", "func2", "func3") And with the operation I am looking for I would get this for the first string: moduleA.func1() I know how to concatenate strings, but is there a way to join into a callable string?
If you mean get a function or method on a class or module, all entities (including classes, modules, functions, and methods) are objects, so you can do a func = getattr(thing 'func1') to get the function, then func() to call it.
0
false
2
2,071
2012-08-28 21:00:42.300
Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()
I got this: tu = ("func1", "func2", "func3") And with the operation I am looking for I would get this for the first string: moduleA.func1() I know how to concatenate strings, but is there a way to join into a callable string?
getattr(moduleA, 'func1')() == moduleA.func1()
1.2
true
2
2,071
2012-08-29 08:16:34.980
MatPlotLib with Sublime Text 2 on OSX
I want to use matplotlib from my Sublime Text 2 directly via the build command. Does anybody know how I accomplish that? I'm really confused about the whole multiple python installations/environments. Google didn't help. My python is installed via homebrew and in my terminal (which uses brew python), I have no problem ...
I had the same problem and the following fix worked for me: 1 - Open Sublime Text 2 -> Preferences -> Browse Packages 2 - Go to the Python folder, select file Python.sublime-build 3 - Replace the existing cmd line for this one: "cmd": ["/Library/Frameworks/Python.framework/Versions/Current/bin/python", "$file"], Then...
1.2
true
1
2,072
2012-08-29 13:37:33.443
Meaning of @classmethod and @staticmethod for beginner?
Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define th...
I'm a beginner on this site, I have read all above answers, and got the information what I want. However, I don't have the right to upvote. So I want to get my start on StackOverflow with the answer as I understand it. @staticmethod doesn't need self or cls as the first parameter of the method @staticmethod and @clas...
0.034
false
3
2,073
2012-08-29 13:37:33.443
Meaning of @classmethod and @staticmethod for beginner?
Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define th...
A slightly different way to think about it that might be useful for someone... A class method is used in a superclass to define how that method should behave when it's called by different child classes. A static method is used when we want to return the same thing regardless of the child class that we are calling.
0
false
3
2,073
2012-08-29 13:37:33.443
Meaning of @classmethod and @staticmethod for beginner?
Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define th...
@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance. @staticmethod means: when this method is called, we d...
1
false
3
2,073
2012-08-29 18:56:51.107
Widgets in a Tkinter popup taking Tab focus from widgets in another window
I am noticing an issue in my Tkinter application when I create a new Toplevel popup (actually a subclass of tkSimpleDialog.Dialog) and try to navigate through its widgets with the Tab key. It works as expected, except whatever I had selected in a Listbox in my application's main window becomes unselected, as if the wi...
Solution: When creating the entry widgets in the popup, set their exportselection property to 0. Then selecting them won't affect any other selections.
1.2
true
1
2,074
2012-08-29 19:32:44.717
Unicode characters in Django usernames
I am developing a website using Django 1.4 and I use django-registration for the signup process. It turns out that Unicode characters are not allowed as usernames, whenever a user enters e.g. a Chinese character as part of username the registration fails with: This value may contain only letters, numbers and @/./+/-/_...
It is really not a problem - because this character restriction is in UserCreationForm (or RegistrationForm in django-registration) only as I remember, and you can easily make your own since field in database is just normal TextField. But those restriction is there not without a reason. One of the possible problems I c...
1.2
true
1
2,075
2012-08-29 23:16:43.323
How can I stream data, on my Mac, from a bluetooth source using R?
I have a device that is connected to my Mac via bluetooth. I would like to use R (or maybe Python, but R is preferred) to read the data real-time and process it. Does anyone know how I can do the data streaming using R on a Mac? Cheers
there is a strong probability that you can enumerate the bluetooth as serial port for the bluetooth and use pyserial module to communicate pretty easily... but if this device does not enumerate serially you will have a very large headache trying to do this... see if there are any com ports that are available if there ...
1.2
true
1
2,076
2012-08-30 16:00:25.883
how to implement an on_revoked event in celery
I have a task that retries often, and I would like a way for it to cleanup if it is revoked while it is in the retry state. It seems like there are a few options for doing this, and I'm wondering what the most acceptable/cleanest would be. Here's what I've thought of so far: Custom Camera that picks up revoked tasks a...
Use AbortableTask as a template and create a RevokableTask class to your specification.
0
false
1
2,077
2012-08-30 18:23:39.060
Draw an inner map of a certain place (like a house blueprint) in Django
i'll try to be the most specific possible. I have a Django project and i want to be able to draw a inner map of a certain place. By that, i mean a graphical representation of important objects like the tables positions, bathrooms etc. I'm trying to avoid Flash as an option. Is there an existing API that i can use? Or h...
Assuming you mean drawing plans interactively in the browser, rather than maps in the sense of Google Maps, you need something like HTML5 canvas or SVG, and a library like fabric.js (for canvas) or Raphael (for SVG). Your JS code will then handle the mechanics of drawing lines from mouse input, producing a picture in t...
0.673066
false
1
2,078
2012-08-31 06:56:42.750
Split large collection into smaller ones?
I have a collection that is potentially going to be very large. Now I know MongoDB doesn't really have a problem with this, but I don't really know how to go about designing a schema that can handle a very large dataset comfortably. So I'm going to give an outline of the problem. We are collecting large amounts of dat...
It sounds like the larger set (A if I followed along correctly), could reasonably be put into its own database. I say database rather than collection, because now that 2.2 is released you would want to minimize lock contention between the busier database and the others, and to do that a separate database would be best...
1.2
true
1
2,079
2012-08-31 07:46:41.480
Block windows key wxPython
I am creating an application with wxpython for writing tests in schools, and it needs to be able to block the windows key, alt-tab and so on to prevent cheating. Is this possible and if it is, how do you do it? I know that you can't block ctrl + alt + del, but is it possible to detect when it is pressed?
The simple answer is No, unless this is a touchscreen application with no access to the computer hardware. That would probably work. Otherwise you'll have to look into how to lockdown your PC with Microsoft Policies etc. Or you might be able to do it with a locked down Linux install. Regardless, it's not really somethi...
0
false
1
2,080
2012-08-31 09:24:01.650
Jumping to Python library sources with epy/emacs
I am using epy/ropemacs for my python project. "C-c g" (rope-goto-definition) works fine if the target is my source file. But it doesnt jump to third party source files. What I want to be able to do is jump to relevant third party source files. This might be just a matter of letting rope know what the path the librari...
Ok found the solution. Edit .ropeproject/config.py and add these lines to to set_prefs function def set_prefs(prefs):     ...     prefs.add('python_path', '<path to your external library>') Example:     prefs.add('python_path', '/usr/local/google_appengine')
1.2
true
1
2,081
2012-08-31 15:08:45.167
How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS
I am working on C++ programming with perforce (a version control tool) on VMS. I need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. I am familiar with Linux, python but not DCL (a script language) on VMS. I need to find a way to make programming/debug/code-review as easy as possible. I p...
Indeed, it's not clear from your question what sort of programming you want to do on VMS: C++ or python?? Assuming your first goal is to get familiar with the code-base, i.e. you want the ease of cross-ref'ing the sources: If you have Perforce server running on VMS, then you may try to connect to it directly with Linu...
0
false
2
2,082
2012-08-31 15:08:45.167
How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS
I am working on C++ programming with perforce (a version control tool) on VMS. I need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. I am familiar with Linux, python but not DCL (a script language) on VMS. I need to find a way to make programming/debug/code-review as easy as possible. I p...
Your question is pretty broad so it's tough to give a specific answer. It sounds like you have big goals in mind which is good, but since you are on VMS, you won't have a whole lot of tools at your disposal. It's unlikely that kscope works on VMS. Correct me if I'm wrong. I believe a semi-recent version of python...
0.201295
false
2
2,082
2012-09-01 05:42:42.693
nose.run() seems to hold test files open after the first run
I'm having the same problem on Windows and Linux. I launch any of various python 2.6 shells and run nose.py() to run my test suite. It works fine. However, the second time I run it, and every time thereafter I get exactly the same output, no matter how I change code or test files. My guess is that it's holding onto fil...
Solved* it with some outside help. I wouldn't consider this the proper solution, but by searching through sys.modules for all of my test_modules (which point to *.pyc files) and deling them, nose finally recognizes changes again. I'll have to delete them before each nose.run() call. These must be in-memory versions of ...
0
false
1
2,083
2012-09-01 17:30:24.403
deleted version are still being serverd in appspot.com
I'm at lost as to why I have deleted some versions of my apps in appspot.com, but event after clearing out the cache on both local browsers and appspot.com under pagespeed service. Old versions are still accessible. How long before deleted versions are gone? Also, I have upload changes, but it does not show up at all. ...
Google's GSLB proxy will cache your static files for hours, even if you have disable your appspot application and then re-enable it. My solution is to append version number at every css, js, jpg url.
0.201295
false
2
2,084
2012-09-01 17:30:24.403
deleted version are still being serverd in appspot.com
I'm at lost as to why I have deleted some versions of my apps in appspot.com, but event after clearing out the cache on both local browsers and appspot.com under pagespeed service. Old versions are still accessible. How long before deleted versions are gone? Also, I have upload changes, but it does not show up at all. ...
If you go to the App Engine Admin page, you should be able to see all the instances you have running. Kill all the instances for the old versions and it should stop serving.
0
false
2
2,084
2012-09-02 08:57:08.483
Multiple GUI Kits in a single Python app
I'm a Python newbie but I'm interested in going into the depths of the language. I learned recently how to make simple GUI apps with wxPython and I loved it, I've read around that is the best cross-platform GUI kit around - yet, there are better "native" GUI kits (pyGTK, IronPython (if I'm not mistaken), pyObjc, etc.),...
The grate benefit from wxPython is its use of native widgets where possible, so on GTK platform it'll use GTK, on windows it will use win32, and on mac it will use cocoa/carbon. If you don't write a cross-platform app, then you should better use the specific API to this platform, e.g. pyGTK (Gnome etc.), PyWin32T (Wind...
1.2
true
1
2,085
2012-09-05 00:55:39.480
string matching with substitution using PYTHON
I have a string and I need match that string with an sequence and determine the number of times the matched sequence is found in that sequence But it has following conditions Sequence can contain only ACGT valid chars so seq could be ACGTGTCTG the string could be ACGnkG where n could be replaced by A or G k could b...
re.findall(pattern, string) will return a list with all matches for pattern in string. len(...) will return the number of items in a list.
0.386912
false
1
2,086
2012-09-05 09:02:10.273
python clear csv file
how can I clear a complete csv file with python. Most forum entries that cover the issue of deleting row/columns basically say, write the stuff you want to keep into a new file. I need to completely clear a file - how can I do that?
The Python csv module is only for reading and writing whole CSV files but not for manipulating them. If you need to filter data from file then you have to read it, create a new csv file and write the filtered rows back to new file.
0.135221
false
1
2,087
2012-09-05 21:00:22.823
Passing variables through Selenium send.keys instead of strings
I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: this works name_element.send_keys("John Doe") but this doesnt name_element.send_keys(username) Does anyone know how I can accomplish this? Pretty big Python noob, but used Google ...
I think username might be a variable in the python library you are using. Try calling it something else like Username1 and see if it works??
0
false
2
2,088
2012-09-05 21:00:22.823
Passing variables through Selenium send.keys instead of strings
I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: this works name_element.send_keys("John Doe") but this doesnt name_element.send_keys(username) Does anyone know how I can accomplish this? Pretty big Python noob, but used Google ...
Try this. username = r'John Doe' name_element.send_keys(username) I was able to pass the string without casting it just fine in my test.
0.081452
false
2
2,088
2012-09-05 22:29:26.937
How do you add the scrapy framework to portable python?
I need to create a portable python install on a usb but also install the scrapy framework on it, so I can work on and run my spiders on any computer. Has anyone else done this? Is it even possible? If so how do you add scrapy onto the portable python usb and then run the spiders? Thanks
you can easily download scrapy executable, extract it with python, copy scrapy folder and content to c:\Portable Python 2.7.5.1\App\Lib\site-packages\ and you'll have scrapy in your portable python. I just had my similar problem with SciKit this way.
0
false
1
2,089
2012-09-06 08:20:07.210
Export a website to an XML Page
I need to export a website(.html page) to a XML file. The website contains a table with some data which i require for using in my web project. The table in the website is formed using some javascript, so i cannot get the data by getting the page source. Please tell me how I can export the table in the website to a XML ...
You could try to reverse engineer the javascript code. Maybe it's making an ajax request to a service, that delivers the data as json. Use your browsers developer tools/network tab to see what's going on.
1.2
true
1
2,090
2012-09-06 09:03:49.273
How to draw a chart with excel using python?
Hi I intend to draw a chart with data in an xlsx file. In order to keep the style, I HAVE TO draw it within excel. I found a package named win32com, which can give a support to manipulate excel file with python on win32 platform, but I don't know where is the doc..... Another similar question is how to change the style...
Documentation for win32com is next to non-existent as far I know. However, I use the following method to understand the commands. MS-Excel In Excel, record a macro of whatever action you intend to, say plotting a chart. Then go to the Macro menu and use View Macro to get the underlying commands. More often than not, t...
0.101688
false
1
2,091
2012-09-06 11:12:37.337
how can i debug openerp code in to the eclipse
how can I debug python code in to the eclipse.if it will be done then we face less effort and fast do our work.can any one tell me???
To debug your Openerp+python code in eclipse, start eclipse in debug perspective and follow the given steps: 1: Stop your openERP running server by pressing "ctr+c". 2: In eclipse go to Menu "Run/Debug Configurations". In configuration window under "Python Run", create new debug configuration(Double click on 'Python Ru...
1.2
true
1
2,092
2012-09-07 12:46:51.010
Confused about the choice between Python 2 vs Python 3
I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.
If you're looking to learn new things, and aren't looking to make a "must work today" type project, try Python3. It will be easier to move forward into the future with Python3, as it will become the standard over time. If you're making something quick and dirty, you'll typically get better library support with Python 2...
0.545705
false
2
2,093
2012-09-07 12:46:51.010
Confused about the choice between Python 2 vs Python 3
I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.
Nowadays, quite a number of libraries support Python 3. There is not a single list of these, so you'll have to check the frameworks you'd like to use for Python 3 compatibility. Some support Python 3 only in some beta stage, but that doesn't mean those are bad. I would start off nowadays with Python 3, and see where yo...
0.067922
false
2
2,093
2012-09-08 22:53:56.963
Putting password for fabric rsync_project() function
I'd like to pass somehow user password for rsync_project() function (that is wrapper for regular rsync command) from Fabric library. I've found the option --password-file=FILE of rsync command that requires password stored in FILE. This could somehow work but I am looking for better solution as I have (temporarily) pas...
If rsync using ssh as a remote shell transport is an option and you can setup public key authentication for the users, that would provide you a secure way of doing the rsync without requiring passwords to be entered.
1.2
true
1
2,094
2012-09-09 07:36:52.993
How secure is Django Admin interface
I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects. So, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin. ...
Besides serving static files through django is considered a bad idea, the django admin itself is pretty safe. You can take additional measure by securing it via .htaccess and force https access on it. You could also restrict access to a certain IP. If the admin is exposed to the whole internet you should at least be ca...
0
false
2
2,095
2012-09-09 07:36:52.993
How secure is Django Admin interface
I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects. So, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin. ...
How secure is a Google Login ;) ? You can't tell as you can't look behind the scenes (Update: Of Google Login of course.). I would guess that Django's admin code is pretty safe, as it's used in lots of production systems. Still, beside the code, it also matters how you set it up. In the end, it depends on the level of ...
-0.386912
false
2
2,095
2012-09-09 18:12:58.290
Error when installing mod_wsgi
When installing mod_wsgi I get stuck after doing ./config Apparently I am missing the apxs2 Here is the result: checking for apxs2... no checking for apxs... /usr/sbin/apxs checking Apache version... 2.2.22 checking for python... /usr/bin/python configure: creating ./config.status config.status: creating Makefile What...
You have Apache 2.2 core package installed, but possibly have the devel package for Apache 1.3 instead of that for 2.2 installed. This isn't certain though, as for some Apache distributions, such as when compiled from source code, 'apxs' is still called 'apxs'. It is only certain Linux distros that have changed the nam...
0
false
2
2,096
2012-09-09 18:12:58.290
Error when installing mod_wsgi
When installing mod_wsgi I get stuck after doing ./config Apparently I am missing the apxs2 Here is the result: checking for apxs2... no checking for apxs... /usr/sbin/apxs checking Apache version... 2.2.22 checking for python... /usr/bin/python configure: creating ./config.status config.status: creating Makefile What...
checking for apxs... /usr/sbin/apxs ... config.status: creating Makefile It succeeded. Go on to the next step.
0.386912
false
2
2,096
2012-09-09 20:44:18.520
pyqt4, function Mute / Un mute microphone and also speakers [PJSIP]
Hello friends and colleagues I am trying to make a function mute / un mute microphone and also speakers for my program softphone on pyt4 and using library PJSIP I found this in the code pjsip pjsip: def conf_set_tx_level(self, slot, level): """Adjust the signal level to be transmitted from the bridge t...
himself answer :-) in my case it was so # call window ################ self.MuteMic = False self.MuteSpeaker = False ################ #btn signals self.connect(self.MuteUnmuteMicButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteMic) self.connect(self...
1.2
true
1
2,097
2012-09-09 20:45:06.963
Delete pieces of Session on browser close
I am going to be storing a significant amount of information inside Django's session cookie. I want this data to persist for the entire time the user is on the website. When he leaves, the data should be deleted, but the session MUST persist. I do not want to user to need to log in every time he returns to the website...
You're confusing things a bit. The only thing stored inside "Django's session cookie" is an ID. That ID refers to the data which is stored inside the session backend: this is usually a database table, but could be a file or cache location depending on your Django configuration. Now the only time that data is updated is...
1.2
true
1
2,098
2012-09-10 00:44:19.633
How to stop python interpreter from closing on Windows 7?
I have that issue with python interpreter - it's closing immediately after script execution. I'm trying to learn pygtk; I wrote "hello world" after tutorial and all I can see is a quick flash of two windows, one interpreter's and one gtk's. I tried to run the script from command.com instead of by double-click - didn't ...
I suggest that you run your code in some sort of editor (pretty much any will do: Eclipse, Geany, Spyder, IDLE, etc.). The reason for this is that when the program is executed, you are most likely getting a fatal error in your code somewhere. Python IDEs have a tendency to keep the windows used to execute the code open...
0
false
1
2,099
2012-09-10 01:42:59.440
how do i know what parameters a python function takes with wingware IDE
in visual studio all you had to do was type the first parenthesis and it showed you the parameters required. It's not doing that in python / wingware, what is the best / easiest way to do this?
Python is a "dynamically-typed" programming language, that meaning that the odds are against the IDE in providing code-intelligence. That said, Wing-IDE is the very best for Python, and there are a few things you can do: first be sure to have open the "Source Assistant" panel, i.e., press F2 and locate it to your righ...
0
false
1
2,100
2012-09-10 08:56:26.277
how do i pass multiple files as arguments in command line for python using regular expressions?
I'm not able to do this ptags.py *.py or python *.py i'm getting an error saying "Cannot open file named *.py" but i'm able to open all the python files in vim using this command vim *.py python 2.7 in windows 7 command prompt
You cannot using standard Windows cmd shell. You can use something like bash from Cygwin, maybe PowerShell. If you want to open *.py from application like vim but in Python, then you can use glob module.
1.2
true
1
2,101
2012-09-10 12:30:49.550
How to redirect print statements to Tkinter text widget
I have a Python program which performs a set of operations and prints the response on STDOUT. Now I am writing a GUI which will call that already existing code and I want to print the same contents in the GUI instead of STDOUT. I will be using the Text widget for this purpose. I do not want to modify my existing code w...
The function which normally prints to stdout should instead put the text into text widget.
-0.16183
false
1
2,102
2012-09-10 16:05:07.727
Multi feature recommender system representation
I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on. So far, a few mysql tables have been enough to handle ...
I recommend using tensors, which is multidimensional arrays. You can use any data table or simply text files to store a tensor. Each line or row is a record / transaction with different features all listed.
0
false
2
2,103
2012-09-10 16:05:07.727
Multi feature recommender system representation
I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on. So far, a few mysql tables have been enough to handle ...
An SQL database should work fine in your case. In fact, you can store all the training examples in just one database, each row representing a particular training set and each column representing a feature. You can add features by adding collumns as and when required. In a relational database, you might come across acce...
0
false
2
2,103
2012-09-11 17:43:54.570
IMAP in Corporate Gmail
I am trying to download emails using imaplib with Python. I have tested the script using my own email account, but I am having trouble doing it for my corporate gmail (I don't know how the corporate gmail works, but I go to gmail.companyname.com to sign in). When I try running the script with imaplib.IMAP4_SSL("imap.gm...
IMAP server is still imap.gmail.com -- try with that?
0.386912
false
1
2,104
2012-09-12 06:19:31.393
Terminate python application waiting on semaphore
I would like to know why doesn't python2.7 drop blocking operations when ctrl+c is pressed, I am unable to kill my threaded application, there are several socket waits, semaphore waits and so on. In python3 ctrl+c dropped every blocking operation and garbage-collected everything, released all the sockets and whatsoever...
I guess you are launching the threads and then the main thread is waiting to join them on termination. You should catch the exception generated by Ctrl-C in the main thread, in order to signal the spawned threads to terminate (changing a flag in each thread, for instance). In this manner, all the children thread will t...
1.2
true
1
2,105
2012-09-12 07:53:52.497
Authenticate by IP address in Django
I have a small Django application with a view that I want to restrict to certain users. Anyone from a specific network should be able to see that view without any further authentication, based on IP address alone. Anyone else from outside this IP range should be asked for a password and authenticated against the defaul...
There's no need to write an authentication backend for the use case you have written. Writing an IP based dispatcher in the middleware layer will likely be sufficient If your app's url(s) is/are matched, process_request should check for an authenticated django user and match that user to a whitelist.
0.201295
false
1
2,106
2012-09-12 08:04:15.370
Tornado secure cookie expiration (aka secure session cookie)
How can I set in Tornado a secure cookie that expires when the browser is closed? If I use set_cookie I can do this without passing extra arguments (I just set the cookie), but how if I have to use set_secure_cookie? I tried almost everything: passing nothing: expiration is set to its default value, that is 1 month ...
It seems to me that you are really on the right track. You try lower and lower values, and the cookie has a lower and lower expiration time. Pass expires_days=None to make it a session cookie (which expires when the browser is closed).
1.2
true
1
2,107
2012-09-12 18:54:39.747
Which one data load method is the best for perfomance?
For example, I have object user stored in database (Redis) It has several fields: String nick String password String email List posts List comments Set followers and so on... In Python programm I have class (User) with same fields for this object. Instances of this class maps to object in database. The question is h...
The method entirely depends on the requirements. If there is only one client reading and modifying the properties, this is a rather simple problem. When modifying data, just change the instance attributes in your current Python program and -- at the same time -- keep the DB in sync while keeping your program responsive...
1.2
true
1
2,108
2012-09-13 20:49:34.043
how the python interpreter find the modules path?
I'm new to python, and I find that to see the import search paths, you have to import the sys module and than access the list of paths using sys.path, if this list is not available until I explicitly import the sys module, so how the interpreter figure out where this module resides. thanks for any explanation.
The module search path always exists, even before you import the sys module. The sys module just makes it available for you. It reflects the contents of the system variable $PYTHONPATH, or a system default, if you have not set that environment variable.
1.2
true
1
2,109
2012-09-14 05:50:08.220
Use compressed JavaScript file (not run time compression)
I have to deploy a heavily JS based project to a embedded device. Its disk size is no more than 16Mb. The problem is the size of my minified js file all-classes.js is about 3Mb. If I compress it using gzip I get a 560k file which saves about 2.4M. Now I want to store all-classes.js as all-classes.js.gz so I can save s...
What you need to do, when the "all-classes.js" file is requested, is to return the content of "all-classes.js.gzip" with the additional "Content-Encoding: gzip" HTTP header. But it's only possible if the request contained the "Accept-Encoding: gzip" HTTP header in the first place...
1.2
true
1
2,110
2012-09-14 20:55:56.227
Usage of pypy compiler
Is there a difference in python programming while using just python and while using pypy compiler? I wanted to try using pypy so that my program execution time becomes faster. Does all the syntax that work in python works in pypy too? If there is no difference, can you tell me how can i install pypy on debian lunux and...
pypy is a compliant alternative implementation of the python language. This means that there are few (intentional) differences. One of the few differences is pypy does not use reference counting. This means, for instance, you have to manually close your files, they will not be automatically closed when your file variab...
0.386912
false
1
2,111
2012-09-15 18:39:04.983
How to rollback the database in SQL Alchemy?
For my database project, I am using SQL Alchemy. I have a unit test that adds the object to the table, finds it, updates it, and deletes it. After it goes through that, I assumed I would call the session.rollback method in order to revert the database changes. It does not work because my sequences are not reverted. My ...
Postgres does not rollback advances in a sequence even if the sequence is used in a transaction which is rolled back. (To see why, consider what should happen if, before one transaction is rolled back, another using the same sequence is committed.) But in any case, an in-memory database (SQLite makes this easy) is the...
1.2
true
1
2,112
2012-09-16 04:55:40.777
Auto Text Summarization
I have decided to develop a Auto Text Summarization Tool using Python/Django. Can someone please recommend books or articles on how to get started? Is there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? Also, would you like to suggest me the new challenging FYP...
About papers, I would like to add to the previous answer next ones: "Text Data Management and Analysis" by ChengXiang Zhai and Sean Massung, chapter 16. "Texts in Computer Science: Fundamentals of Predictive Text Mining" by Sholom M. Weiss, Nitin Indurkhya and Tong Zhang (second edition), chapter 9.
0
false
2
2,113
2012-09-16 04:55:40.777
Auto Text Summarization
I have decided to develop a Auto Text Summarization Tool using Python/Django. Can someone please recommend books or articles on how to get started? Is there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? Also, would you like to suggest me the new challenging FYP...
First off for Paper, I recommend: 1- Recent automatic text summarization techniques: a survey by M.Gambhir and V.Gupta 2- A Survey of Text Summarization Techniques, A.Nenkova As for tools for Python, I suggest taking a look at these tools: The Conqueror: NLTK The Prince: TextBlob The Mercenary: Stanford CoreNLP Th...
0.386912
false
2
2,113
2012-09-17 07:49:03.207
How to input and process audio files to convert to text via pyspeech or dragonfly
I have seen the documentation of pyspeech and dragonfly, but don't know how to input an audio file to be converted into text. I have tried it with microphone via speaking to it and the speech is converted into text, but If I want to input a previously recorded audio file. Can anyone help with an example?
Both PySpeech and Dragonfly are relatively thin wrappers over SAPI. Unfortunately, both of them use the shared recognizer, which doesn't support input selection. While I'm familiar with SAPI, I'm not that familiar with Python, so I haven't been able to assist anyone with moving PySpeech/Dragonfly over to an in-proces...
0
false
1
2,114
2012-09-18 03:43:37.437
Fast algorithm comparing unsorted data
I have data that needs to stay in the exact sequence it is entered in (genome sequencing) and I want to search approximately one billion nodes of around 18 members each to locate patterns. Obviously speed is an issue with this large of a data set, and I actually don't have any data that I can currently use as a discret...
probably what you want is called "de novo assembly" an approach would be to calculate N-mers, and use these in an index nmers will become more important if you need partial matches / mismatches if billion := 1E9, python might be too weak also note that 18 bases* 2 bits := 36 bits of information to enumerate them. That ...
1.2
true
1
2,115
2012-09-18 04:33:30.110
Scrolling starfield with gl_points in pyglet
For a game I am working on I would like to implement a scrolling starfield. All the game so far is being drawn from OpenGL primitives and I would like to continue this and gl_points seems appropriate. I am using pyglet (python) and know I could achieve this storing the positions of a whole bunch or points updating them...
Can you clarify what sort of starfield? 2D scrolling (for a side or top scrolling game, maybe with different layers) or 3D (like really flying through a starfield in an impossibly fast spaceship)? In the former, a texture (or layers of textures blended additively) is probably the cleanest and fastest approach. [EDIT:...
1.2
true
1
2,116
2012-09-18 07:38:32.873
install OSQA using xampp on windows 7
can anyone tell me that how can i install osqa on windows 7 with xampp localhost ? i don't know xampp support python. Thanks in advance.
If you're flexible about xampp, try bitnami native installer: http://bitnami.org/stack/osqa It took me about 10min for the installer to run, then I had running on Win7 localhost.
1.2
true
1
2,117
2012-09-18 14:35:41.960
creating a configurable permissions system in django
I am using django to create a web based app. This app will be used as a service by multiple clients. It has several models / tables that represent a hierarchical relationship. Users are given access based on this hierarchical relationship - ex County -> Schools -> Divisions -> Classrooms. So a user having access to a...
What about storing the new levels in a prefix tree? you could use each level as a node of a branch of the tree. When a new user wants do define a new level, the prefix tree will be updated starting from the level where the user belongs. If your problem is just about giving visibility to the user of the sub-branch of t...
0.386912
false
1
2,118
2012-09-19 01:33:04.983
python regular expression repeating pattern match
I would like some thoughts on how to write a regular expression which validates a pattern ex. .??2 one of more characters followed by two question marks followed by one or more numbers and if only if there is another repeating pattern then the seperator will be a semi colon. more examples --??9;.??50;,??3 - in this ex...
The basic pattern is .+?\?\?\d+. We have made the first .+ non-greedy so it won't try to match the whole string right away. Use a repeated group to capture the subsequent patterns: r'(.+?\?\?\d+)(;.+?\?\?\d+)*'
1.2
true
1
2,119
2012-09-19 09:50:39.963
How to write own map generator?
I would like to write for myself a simple map generator and I do not know how to bite. field will have to draw lots hexagonal. When I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the m...
I think the most important thing is to denote your hexagons on the map in a way which makes checking neighbours easy... One sensible choice could be to use 2D tuples, so that the hexagon (1,1)'s 6 neighbours are (1,0),(2,0),(2,2),(1,2),(0,2) and (1,1) - starting from north/up and going clockwise. To populate the map yo...
0
false
2
2,120
2012-09-19 09:50:39.963
How to write own map generator?
I would like to write for myself a simple map generator and I do not know how to bite. field will have to draw lots hexagonal. When I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the m...
There is probably no need to use recursion. Since you do this as a learning exercise, I will only provide you with an outline of how to progress. The hexagonal grid will need a coordinate system, for the rows and columns. Create a function neighbours that, given the coordinates x,y of a tile returns all the neighbours ...
0
false
2
2,120
2012-09-19 18:22:58.327
Django: How to upload directly files submitted by a user to another server?
I'm using Django 1.4. There are two servers (app server and file server). The app server provide a web service using django, wsgi, and apache. User can upload files via the web service. I'd like to upload directly these files to the file server. "directly" means that the files aren't uploaded via the app server. I'd li...
You can't actually do both of these at once: I'd like to upload directly these files to the file server. I'd like to make the file server simple as possible. The file server just serve files. Under your requirements, the file server needs to both Serves Files and Accepts Uploads of files. There are a few ways to get ...
0.201295
false
1
2,121
2012-09-20 11:37:28.063
Merging of two dictionaries
I have two dictionaries as follows: D1={'a':1,'b':2,'c':3} and D2={'b':2,'c':3,'d':1} I want to merge these two dictionaries and the result should be as follows: D3={'a':1,'b':2,'c':3,'b':2,'c':3,'d':1} how can I achieve this in python?
What are you asking is not possible, since you cannot have two different keys with the same value in a Python dictionary. The closest answer to your question is: D3 = dict( D1.items() + D2.items() ) Note: if you have different values for the same key, the ones from D2 will be the ones in D3. Example: D1 = { 'a':1, 'b'...
0.16183
false
1
2,122
2012-09-21 00:38:48.580
change character set for tempfile.NamedTemporaryFile
I'm writing a python3 program that generates a text file that is post-procesed with asciidoc for the final report in html and pdf. The python program generates thousands files with graphics to be included in the final report. The filenames for the files are generated with tempfile.NamedTemporaryFile The problem it that...
Maybe you could create a temporary directory using tempfile.tempdir and generate the filenames manually such as file1, file2, ..., filen . This way you easily avoid "_" characters and you can just delete the temporary directory after you are finished with that.
0
false
1
2,123
2012-09-21 14:34:39.297
Python Audio library for fast, gapless looping of many short audio tracks
I'm writing an application to simulate train sounds. I got very short (0.2s) audio samples for every speed of the train and I need to be able to loop up to 20 of them (one for every train) without gaps at the same time. Gapless changing of audio samples (train speed) is also a Must-Have. I've been searching for possibl...
I am using PyAudio for a lot of things and are quite happy with it. If it can do this, I do not know, but I think it can. One solution is to feed sound buffer manually and control / set the needed latency. I have done this and it works quite well. If you have the latency high enough it will work. An other solution, s...
0
false
1
2,124
2012-09-22 08:22:44.580
Separating class definition and implementation in python
I am a Python beginner and my main language is C++. You know in C++, it is very common to separate the definition and implementation of a class. (How) Does Python do that? If not, how to I get a clean profile of the interfaces of a class?
For some reason, many Python programmers combine the class and its implementation in the same file; I like to separate them, unless it is absolutely necessary to do so.     That's easy. Just create the implementation file, import the module in which the class is defined, and you can call it directly.     So, if the c...
0.101688
false
1
2,125
2012-09-22 16:07:30.390
A web application to serve static files
I am thinking to design my own web app to serve static files. I just don't want to use Amazon services.. So, can anyone tell me how to start the project? I am thinking to develop in Python - Django on Openshift (Redhat's). This is how ideas are going through in my mind: A dashboard helps me to add/ delete/ manage sta...
How about this: Use nginx to serve static files Keep the files in some kind of predefined directory structure, build a django app as the dashbord with the filesystem as the backend. That is, moving, adding or deleting files from the dashboard changed them the filesystem and nginx doesn't have to be aware of this dashb...
0.995055
false
1
2,126
2012-09-23 14:36:39.700
Messed up records - separator inside field content
I am provided with text files containing data that I need to load into a postgres database. The files are structured in records (one per line) with fields separated by a tilde (~). Unfortunately it happens that every now and then a field content will include a tilde. As the files are not tidy CSV, and the tilde's not e...
If you know what each field is supposed to be, perhaps you could write a regular expression which would match that field type only (ignoring tildes) and capture the match, then replace the original string in the file?
0
false
1
2,127
2012-09-24 16:24:51.737
WingIDE -- Python 2 and Python 3
Suppose I have both Python 2 and Python 3 installed. In WingIDE 101, how do I choose whether I am using Python 2 or Python 3? For example, I was currently working with python 3 and now I need to use the image module which is only supported in python 2. How do I change it? Thanks.
there is a python icon on the interface .click and change
0.999909
false
1
2,128
2012-09-24 22:40:17.763
Options for Image Caching
I am running a website on google app engine written in python with jinja2. I have gotten memcached to work for most of my content from the database and I am fuzzy on how I can increase the efficiency of images served from the blobstore. I don't think it will be much different on GAE than any other framework but I wan...
Blobstore is fine. Just make sure you set the HTTP cache headers in your url handler. This allows your files to be either cached by the browser (in which case you pay nothing) or App Engine's Edge Cache, where you'll pay for bandwidth but not blobstore accesses. Be very careful with edge caching though. If you set an...
0.135221
false
1
2,129
2012-09-25 05:34:48.330
file name vs file object as a function argument
If a function takes as an input the name of a text file, I can refactor it to instead take a file object (I call it "stream"; is there a better word?). The advantages are obvious - a function that takes a stream as an argument is: much easier to write a unit test for, since I don't need to create a temporary file just...
There are numerous functions in the python standard library which accept both -- strings which are filenames or open file objects (I assume that's what you're referring to as a "stream"). It's really not hard to create a decorator that you can use to make your functions accept either one. One serious drawback to usi...
1.2
true
1
2,130
2012-09-26 14:11:53.743
How does a python web server overcomes GIL
Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented? Do they use multiple processes and use IPC for state sharing?
You usually have many workers(i.e. gunicorn), each being dispatched with independent requests. Everything else(concurrency related) is handled by the database so it is abstracted from you. You don't need IPC, you just need a "single source of truth", which will be the RDBMS, a cache server(redis, memcached), etc.
0.265586
false
2
2,131
2012-09-26 14:11:53.743
How does a python web server overcomes GIL
Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented? Do they use multiple processes and use IPC for state sharing?
As normal. Web serving is mostly I/O-bound, and the GIL is released during I/O operations. So either threading is used without any special accommodations, or an event loop (such as Twisted) is used.
0.135221
false
2
2,131
2012-09-27 03:14:19.030
How to automate the sending of files over the network using python?
Here's what I need to do: I need to copy files over the network. The files to be copied is in the one machine and I need to send it to the remote machines. It should be automated and it should be made using python. I am quite familiar with os.popen and subprocess.Popen of python. I could use this to copy the files, BUT...
per my experience, use sftp the first time will prompt user to accept host public key, such as The authenticity of host 'xxxx' can't be established. RSA key fingerprint is xxxx. Are you sure you want to continue connecting (yes/no)? once you input yes, the public key will be saved in ~/.ssh/known_hosts, and next t...
0
false
1
2,132
2012-09-27 13:59:30.600
Python libraries after removing MacPorts and installing homebrew
I recently removed Macports and all its packages and installed Python, Gphoto and some other bits using Homebrew. However python is crashing when looking for libraries as it is looking for them in a MacPorts path. My PATH is correct and the python config show the right path /usr/local/Cellar etc. Can someone tell me h...
I wouldn't use the Macports packages in Homebrew. I'd reinstall them all. A lot of Python packages are compiled , or at least have compiled elements. You're asking for a lot of potential troubles mixing them up.
1.2
true
1
2,133
2012-09-27 17:59:01.660
Counting number of symbols in Python script
I have a Telit module which runs [Python 1.5.2+] (http://www.roundsolutions.com/techdocs/python/Easy_Script_Python_r13.pdf)!. There are certain restrictions in the number of variable, module and method names I can use (< 500), the size of each variable (16k) and amount of RAM (~ 1MB). Refer pg 113&114 for details. I wo...
This post makes me recall my pain once with Telit GM862-GPS modules. My code was exactly at the point that the number of variables, strings, etc added up to the limit. Of course, I didn't know this fact by then. I added one innocent line and my program did not work any more. I drove me really crazy for two days until ...
0
false
1
2,134
2012-09-27 23:32:14.100
Optimizing the size of embedded Python interpreter
I spent the last 3 hours trying to find out if it possible to disable or to build Python without the interactive mode or how can I get the size of the python executable smaller for linux. As you can guess it's for an embedded device and after the cross compilation Python is approximately 1MB big and that is too much ...
There may be ways you can cram it down a little more just by configuring, but not much more. Also, the actual interactive-mode code is pretty trivial, so I doubt you're going to save much there. I'm sure there are more substantial features you're not using that you could hack out of the interpreter to get the size down...
0.386912
false
1
2,135
2012-09-28 09:00:37.293
Moving nodes from one tree to another with Dynatree
I'm currently working on a django project and i'm using dynatree to build treeview. I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to "unselect" the item so the selected item wil...
I've solved my problem using the copy/paste concept of context menu. And for the second problem, I used global variable to store the original parent node so when user unselect the item, it will move back to its original parent.
1.2
true
3
2,136
2012-09-28 09:00:37.293
Moving nodes from one tree to another with Dynatree
I'm currently working on a django project and i'm using dynatree to build treeview. I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to "unselect" the item so the selected item wil...
There is a difference between 'selected' and 'active'. Selection is typically done using checkboxes, while only one node can be activated (typically by a mouse click). A 2nd click on an active node will not fire an 'onActivate' event, but you can implement the 'onClick' handler to catch this and call node.deactivate()
0
false
3
2,136
2012-09-28 09:00:37.293
Moving nodes from one tree to another with Dynatree
I'm currently working on a django project and i'm using dynatree to build treeview. I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to "unselect" the item so the selected item wil...
I have a dynamTree on a DIV dvAllLetterTemplates (which contains a master List) and a DIV dvUserLetterTemplates to which items are to be copied. //Select the Parent Node of the Destination Tree var catNode = $("#dvUserLetterTemplates").dynatree("getTree").selectKey(catKey, false); if (catNode != null) { //Select the s...
0.135221
false
3
2,136
2012-09-30 03:39:24.383
Installing a django site on GoDaddy
I have never deployed a Django site before. I am currently looking to set it up in my deluxe GoDaddy account. Does anyone have any documentation on how to go about installing python and django on GoDaddy?
I am not familiar with GoDaddy's setup specifically, but in general, you cannot install Django on shared hosting unless it is supported specifically (a la Dreamhost). So unless GoDaddy specifically mentions Django (or possibly mod_wsgi or something) in their documentation, which is unlikely, you can assume it is not s...
0.240117
false
1
2,137
2012-09-30 08:08:20.687
Windows:What actually happens when Ctrl+C is pressed in windows explorer
I am designing a Copy/Paste Application for Windows os using Python.Now I want to a Register my application with hotkey for "Ctrl+V" So that when any one press "Ctrl+V" Paste is done through my application and not through windows default Copy/Paste application.But I don't know how to get the list of files path which ar...
When someone presses the Ctrl+C key in Explorer, Explorer calls OleSetClipboard() with an IDataObject containing various formats, which may include CF_FILES, CFSTR_FILECONTENTS and CFSTR_SHELLIDLIST.
1.2
true
1
2,138
2012-09-30 10:24:15.680
Pyramid app not releasing memory between views
I've got a Pyramid view that's misbehaving in an interesting way. What the view does is grab a pretty complex object hierarchy from a file (using pickle), does a little processing, then renders an html form. Nice and simple. Setup: I'm running Ubuntu 12.04 64bit, Python3.2, Pyramid 1.3.3, SQLAlchemy 0.7.8 and using the...
Pyramid's debug toolbar keeps objects alive. Deactivating it fixes most memory leak problems. The leak that was the cause of my searching for errors in Pyramid doesn't seem to be a problem with Pyramid at all
1.2
true
1
2,139
2012-10-02 20:57:24.367
How to debug Celery/Django tasks running locally in Eclipse
I need to debug Celery task from the Eclipse debugger. I'm using Eclipse, PyDev and Django. First, I open my project in Eclipse and put a breakpoint at the beginning of the task function. Then, I'm starting the Celery workers from Eclipse by Right Clicking on manage.py from the PyDev Package Explorer and choosing "De...
I create a management command to test task.. find it easier than running it from shell..
0.081452
false
1
2,140
2012-10-02 22:11:13.900
Finding the different combinations
How do you find all the combinations of a 40 letter string? I have to find how many combinations 20 D and 20 R can make. as in one combination could be... DDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRR thats 1 combination, now how do I figure out the rest?
There are a lot of permutations. It usually isn't a good idea to generate them all just to count them. You should look for a mathematical formula to solve this, or perhaps use dynamic programming to compute the result.
0.081452
false
1
2,141
2012-10-03 06:48:56.457
Open(file) - Does it stay open?
I'm learning how to use open(file, 'r') and was wondering: If I say open(file1, 'r')and then later try to access that same file using open() again, will it work? Because I never did close() on it. And does it close immediately after opening, because it's not assigned to any variable?
i don't know if i understood you well, but using open() you create object representing file stream. until you keep reference to this object, the file stream is opened. but if you call open() again for the same file, you'll make another object representing file stream. target of stream will be the sames but object's wil...
0.135221
false
1
2,142
2012-10-03 11:08:05.013
IRC msg to send to server to send a "whisper" message to a user in channel
I'm writing up an IRC bot from scratch in Python and it's coming along fine. One thing I can't seem to track down is how to get the bot to send a message to a user that is private (only viewable to them) but within a channel and not a separate PM/conversation. I know that it must be there somewhere but I can't find it ...
Are you looking for /notice ? (see irchelp.org/irchelp/misc/ccosmos.html#Heading227)
1.2
true
1
2,143
2012-10-03 15:14:41.423
suspend embedded python script execution
I have an app that embeds python scripting. I'm adding calls to python from C, and my problem is that i need to suspend the script execution let the app run, and restore the execution from where it was suspended. The idea is that python would call, say "WaitForData" function, so at that point the script must suspend (p...
Well, the only way I could come up with is to run the Python engine on a separate thread. Then the main thread is blocked when the python thread is running. When I need to suspend, I block the Python thread, and let the main thread run. When necessary, the OnIdle of the main thread, i block it and let the python contin...
1.2
true
1
2,144
2012-10-05 00:39:28.420
Follow image contour using marching square in Python
I am new to Python and would be grateful if anyone can point me the right direction or better still some examples. I am trying to write a program to convert image (jpeg or any image file) into gcode or x/y coordinate. Instead of scanning x and y direction, I need to follow the contour of objects in the image. For exam...
I would suggest the following procedure: 1) Convert your image to a binary image (nxn numpy array): 1(object pixels) and 0 (background pixels) 3) Since you want to follow a contour, you can see this problem as: finding the all the object pixels belonging to the same object. This can be solved by the Connected Component...
0
false
1
2,145