Q_Id
int64
2.93k
49.7M
CreationDate
stringlengths
23
23
Users Score
int64
-10
437
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
DISCREPANCY
int64
0
1
Tags
stringlengths
6
90
ERRORS
int64
0
1
A_Id
int64
2.98k
72.5M
API_CHANGE
int64
0
1
AnswerCount
int64
1
42
REVIEW
int64
0
1
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
15
5.1k
Available Count
int64
1
17
Q_Score
int64
0
3.67k
Data Science and Machine Learning
int64
0
1
DOCUMENTATION
int64
0
1
Question
stringlengths
25
6.53k
Title
stringlengths
11
148
CONCEPTUAL
int64
0
1
Score
float64
-1
1.2
API_USAGE
int64
1
1
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
15
3.72M
12,105,855
2012-08-24T08:38:00.000
1
0
1
1
0
python,wxpython
0
12,106,760
0
4
0
false
0
0
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 manipulate the gui from the thread in which you created it try something similar. create a proxy object for your gui, which forwards all your calls to your thread which forwards them to the gui. But proxying like this gets messy. how about you let them define classes, with an 'updateGui' function, that they should hand back to you over a queue and that you will execute in your gui thread.
1
0
0
0
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 (or processes). The workaround is to send the data from whatever thread you created it in to the thread responsible for the graphics and then render it there. Unfortunately, for the scenario I have in mind this is not an option: The gui I've created allows users to write their own plotting code which is then executed. This means I have no control over how they plot exactly, nor do I want to have it. (Update: these plots are displayed in separate windows and don't need to be embedded anywhere in the main GUI. What I want is for them to exist separated from the main GUI, without sharing any of the underlying stack of graphics libraries.) So what I'm wondering now is Is there some clean(ish) way of executing a string of python code in a whole new interpreter instance with its own ties to the windowing system? In response to the comments: The current application is set up as follows: A simple python script loads a wxPython gui (a wx.App). Using this gui users can set up a simulation, part of which involves creating a script in plain python that runs the simulation and post-processes the results (which usually involves making plots and displaying them). At the moment I'm doing this by simply calling exec() on the script code. This works fine, but the gui freezes while the simulation is running. I've experimented with running the embedded script in a subprocess, which also works fine, right up until you try to display the created graphs (usually using matplotlib's show()). At this point some library deep down in the stack of wxPython, wx, gtk etc starts complaining because you cannot manipulate it from multiple threads. The set-up I would like to have is roughly the same, but instead of the embedded script sharing a GUI with the main application, I would like it to show graphics in an environment of its own. And just to clarify: This is not a question about "how do I do multithreading/multiprocessing" or even "how do I do multithreading/multiprocessing within a single wxpython gui". The question is how I can start a script from a gui that loads an entirely new gui. How do I get the window manager to see this script as an entirely separate application? The easiest way would be to generate it in a temporary folder somewhere and then make a non-blocking call to the python interpreter, but this makes communication more difficult and it'd be quite hard to know when I could delete the temp files again. I was hoping there was a cleaner, dynamical way of doing this.
Executing a python script in a subprocess - with graphics
0
0.049958
1
0
0
973
12,108,816
2012-08-24T11:45:00.000
0
0
0
1
1
python,sql-server,google-app-engine
1
12,116,542
0
2
0
false
1
0
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.
1
3
0
0
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.
How can use Google App Engine with MS-SQL
0
0
1
1
0
2,793
12,111,983
2012-08-24T15:05:00.000
7
0
0
0
1
python,mysql,django,multithreading
0
12,115,563
0
2
0
true
1
0
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). On the other hand, you should check database "bandwith".
1
7
0
0
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 hundred objects, 3-4 times per hour - of course updating every one in a row is not an option, because it could take all day. My first thought was split it up for 50-100 threads so each one could update its own part of objects. 99% of update function time is waiting for server respond (there is few bytes of data only, so pings are the problem), I think the CPU won't be a problem, I'm more worried about: Django ORM. Can it handle it? Getting all objects, splitting it up, and updating from >50 threads? Is it a good idea to solve this? If it is - how to do it and don't screw a database? Or maybe I shouldn't care about so little records? If it isn't a good way, how to do it right?
Django databases and threads
0
1.2
1
0
0
5,194
12,133,857
2012-08-26T20:57:00.000
2
1
0
1
0
python,linux,passwords
0
12,134,029
0
3
0
false
0
0
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 "behind" will be unaccessible. At that point you have the problem of preventing the user from using the keyboard to terminate the application, or to switch to another application, or to another virtual console (this last is maybe the most difficult). So you need to access and lock the keyboard, not only the "standard" keyboard but the low-level keys as well. And to do this, your application needs to have administrative rights, and yet run in the user environment. Which starts to look like a recipe for disaster, unless you really know what you are doing. What you want to do should be done through a Pluggable Authentication Module (PAM) that will integrate with your display manager. Maybe, you can find some PAM module that will "outsource" or "callback" some external program, i.e., your Python script.
2
0
0
0
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 how to make the python script stay up and not let them exit or do anything else until they entered the correct password. Is there some module I need to import or some command that can pause the system functions until my python script is done? Thanks I am doing it just out of interest and I know a lot could go wrong but I think it would be a fun thing to do. It can even protect 1 specific system process. I am just curious how to pause the system and make the user do the python script before anything else.
pause system functionality until my python script is done
0
0.132549
1
0
0
223
12,133,857
2012-08-26T20:57:00.000
3
1
0
1
0
python,linux,passwords
0
12,134,000
0
3
0
false
0
0
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 manage to block that too he could ssh to the box and kill your app. There is most certainly no generic way to do something like this; this is what the login commands for the console and the session managers (like gdm) for the graphical display are for: they require a user to enter his password before giving him some form of interactive session. After that, why would you want yet another password to do the same thing? the system is designed to not let users use it without a password (or another form of authentication), but there is no API to let programs block the system whenever they feel like it.
2
0
0
0
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 how to make the python script stay up and not let them exit or do anything else until they entered the correct password. Is there some module I need to import or some command that can pause the system functions until my python script is done? Thanks I am doing it just out of interest and I know a lot could go wrong but I think it would be a fun thing to do. It can even protect 1 specific system process. I am just curious how to pause the system and make the user do the python script before anything else.
pause system functionality until my python script is done
0
0.197375
1
0
0
223
12,147,224
2012-08-27T18:11:00.000
1
0
0
1
0
python,monitoring,snmp
0
12,147,545
0
2
0
true
0
0
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 exposed to you (if not a MIB files then what?). Did you read about NETCONF?
2
0
0
0
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 ? Thanks a lot
is snmp required
1
1.2
1
0
1
197
12,147,224
2012-08-27T18:11:00.000
1
0
0
1
0
python,monitoring,snmp
0
12,148,746
0
2
0
false
0
0
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.
2
0
0
0
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 ? Thanks a lot
is snmp required
1
0.099668
1
0
1
197
12,150,405
2012-08-27T22:18:00.000
0
1
0
1
0
php,python,exec
0
12,151,910
0
1
0
true
0
0
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 max amount of running processes is configurable), so at price of some memory you get rid of starting new process every time. However, you still have to start/stop Python process on every exec() call. If you can use a Python app without exec(), eg port PHP part to Python, it would boost performance a lot. But as you mentioned this is a small project so the only important criteria is if your current server can sustain current load.
1
4
0
0
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 a new process for each instance of the Python interpreter which increases overhead, but I don't know how significant it is for a smaller project. Thank you.
PHP Exec() and Python script scaleability
0
1.2
1
0
0
266
12,163,918
2012-08-28T16:50:00.000
1
0
1
0
0
python,refactoring,pickle,zodb
0
12,164,152
0
3
0
false
1
0
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 objects with new equivalents compress your database (that's important) now you can remove your old classes from the sources
2
7
0
0
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 have stored in the database. What's the best way to handle this problem?
pickle/zodb: how to handle moving .py files with class definitions?
0
0.066568
1
0
0
745
12,163,918
2012-08-28T16:50:00.000
3
0
1
0
0
python,refactoring,pickle,zodb
0
12,164,218
0
3
0
false
1
0
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.
2
7
0
0
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 have stored in the database. What's the best way to handle this problem?
pickle/zodb: how to handle moving .py files with class definitions?
0
0.197375
1
0
0
745
12,167,452
2012-08-28T21:00:00.000
5
0
1
0
0
python,string,function
0
12,167,479
0
3
0
true
0
0
getattr(moduleA, 'func1')() == moduleA.func1()
2
1
0
0
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?
Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()
1
1.2
1
0
0
186
12,167,452
2012-08-28T21:00:00.000
0
0
1
0
0
python,string,function
0
12,167,492
0
3
0
false
0
0
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.
2
1
0
0
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?
Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()
1
0
1
0
0
186
12,173,541
2012-08-29T08:16:00.000
5
0
0
0
0
python,matplotlib,sublimetext2,sublimetext
0
12,610,165
0
2
0
true
0
0
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 click CMD+B and your script with matplotlib stuff will work.
1
3
1
0
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 importing matplotlib from there. But Sublime Text shows me an import Error (No module named matplotlib.pyplot). I have installed Matplotlib via EPD free. The main matplotlib .dmg installer refused to install it on my disk, because no system version 2.7 was found. I have given up to understand the whole thing. I just want it to work. And, I have to say, for every bit of joy python brings with it, the whole thing with installations and versions and path, environments is a real hassle. Beneath a help for this specific problem I would appreciate any helpful link to understand and this environment mess.
MatPlotLib with Sublime Text 2 on OSX
0
1.2
1
0
0
3,245
12,179,271
2012-08-29T13:37:00.000
0
0
1
0
0
python,oop,static-methods,class-method
0
41,840,490
0
12
0
false
0
0
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.
3
1,809
0
0
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 the class method without adding @classmethod or @staticmethod or any @ definitions? tl;dr: when should I use them, why should I use them, and how should I use them?
Meaning of @classmethod and @staticmethod for beginner?
0
0
1
0
0
721,840
12,179,271
2012-08-29T13:37:00.000
279
0
1
0
0
python,oop,static-methods,class-method
0
12,179,325
0
12
0
false
0
0
@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 don't pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can't access the instance of that class (this is useful when your method does not use the instance).
3
1,809
0
0
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 the class method without adding @classmethod or @staticmethod or any @ definitions? tl;dr: when should I use them, why should I use them, and how should I use them?
Meaning of @classmethod and @staticmethod for beginner?
0
1
1
0
0
721,840
12,179,271
2012-08-29T13:37:00.000
1
0
1
0
0
python,oop,static-methods,class-method
0
45,264,634
0
12
0
false
0
0
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 @classmethod wrapped function could be called by instance or class variable @staticmethod decorated function impact some kind 'immutable property' that subclass inheritance can't overwrite its base class function which is wrapped by a @staticmethod decorator. @classmethod need cls (Class name, you could change the variable name if you want, but it's not advised) as the first parameter of function @classmethod always used by subclass manner, subclass inheritance may change the effect of base class function, i.e. @classmethod wrapped base class function could be overwritten by different subclasses.
3
1,809
0
0
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 the class method without adding @classmethod or @staticmethod or any @ definitions? tl;dr: when should I use them, why should I use them, and how should I use them?
Meaning of @classmethod and @staticmethod for beginner?
0
0.016665
1
0
0
721,840
12,184,739
2012-08-29T18:56:00.000
2
0
0
0
1
python,tkinter
0
12,184,877
0
1
0
true
0
1
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
1
0
0
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 widget in the popup took the focus from it. Does anyone know why this is happening and how to prevent it? My Tkinter knowledge doesn't cover how interactions between windows affect the focus...
Widgets in a Tkinter popup taking Tab focus from widgets in another window
1
1.2
1
0
0
236
12,185,218
2012-08-29T19:32:00.000
5
0
0
0
1
python,django,unicode,internationalization,django-registration
0
12,185,565
0
2
0
true
1
0
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 can think of now is creating links - usernames are often used for that and it may cause a problem. There is also bigger possibility of fake accounts with usernames looking the same but being in fact different characters, etc.
1
6
0
0
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 @/./+/-/_ characters. Is it possible to change it so Unicode characters are allowed in usernames? If yes, how can I do it? Also, can it cause any problem?
Unicode characters in Django usernames
1
1.2
1
0
0
2,967
12,187,795
2012-08-29T23:16:00.000
0
0
0
1
0
python,macos,r,bluetooth
0
12,187,989
0
1
0
true
0
0
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 are its almost definitely enumerating as a serial connection
1
0
1
0
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
How can I stream data, on my Mac, from a bluetooth source using R?
0
1.2
1
0
0
377
12,200,972
2012-08-30T16:00:00.000
0
0
0
1
1
python,celery
0
18,464,160
0
1
0
false
1
0
Use AbortableTask as a template and create a RevokableTask class to your specification.
1
0
0
0
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 and calls on_revoked Custom Event Consumer that knows to process on_revoked on tasks that get revoked Using AbortableTasks and using abort instead of revoke (I'd really like to avoid this) Are there any other options that I am missing?
how to implement an on_revoked event in celery
0
0
1
0
0
355
12,203,149
2012-08-30T18:23:00.000
2
0
0
0
0
python,django,flash,api,graphics
0
12,203,505
0
1
0
false
1
0
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 the browser. You can then extract that picture using JS and pass it back to the server for saving as a PNG or whatever. If you're targeting modern browsers, canvas is definitely the way to go - it's a much nicer API, has better libraries (IMO) and is easier to extract PNGs from. SVG isn't too bad, but getting PNGs out is tricky - it relies either on hacks (converting the SVG to canvas in JS, rendering it in an invisible element, then converting that to PNG!) or sending the whole SVG to the server to be rendered there. I've recently implemented something requiring very similar mechanics, although for a very different purpose, so if you have any more detailed questions feel free to ask.
1
0
0
0
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 how can i get this thing working? I don't mean to draw soemthing in 3d, just a simple view from above, like a blueprint. Thanks in advance.
Draw an inner map of a certain place (like a house blueprint) in Django
0
0.379949
1
0
0
211
12,210,307
2012-08-31T06:56:00.000
1
0
0
0
1
python,mongodb
0
12,216,914
0
1
0
true
0
0
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 (2.2 introduced database level locking). That is looking at this from a single replica set model, of course. Also the index sizes sound a bit out of proportion to your data size - are you sure they are all necessary? Pruning unneeded indexes, combining and using compound indexes may well significantly reduce the pain you are hitting in terms of index growth (it would potentially make updates and inserts more efficient too). This really does need specifics and probably belongs in another question, or possibly a thread in the mongodb-user group so multiple eyes can take a look and make suggestions. If we look at it with the possibility of sharding thrown in, then the truly important piece is to pick a shard key that allows you to make sure locality is preserved on the shards for the pieces you will frequently need to access together. That would lend itself more toward a single sharded collection (preserving locality across multiple related sharded collections is going to be very tricky unless you manually split and balance the chunks in some way). Sharding gives you the ability to scale out horizontally as your indexes hit the single instance limit etc. but it is going to make the shard key decision very important. Again, specifics for picking that shard key are beyond the scope of this more general discussion, similar to the potential index review I mentioned above.
1
2
0
0
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 data for our customers. Basically, when we gather this data it is represented as a 3-tuple, lets say (a, b, c), where b and c are members of sets B and C respectively. In this particular case we know that the B and C sets will not grow very much over time. For our current customers we are talking about ~200,000 members. However, the A set is the one that keeps growing over time. Currently we are at about ~2,000,000 members per customer, but this is going to grow (possibly rapidly.) Also, there are 1->n relations between b->a and c->a. The workload on this data set is basically split up into 3 use cases. The collections will be periodically updated, where A will get the most writes, and B and C will get some, but not many. The second use case is random access into B, then aggregating over some number of documents in C that pertain to b \in B. And the last usecase is basically streaming a large subset from A and B to generate some new data. The problem that we are facing is that the indexes are getting quite big. Currently we have a test setup with about 8 small customers, the total dataset is about 15GB in size at the moment, and indexes are running at about 3GB to 4GB. The problem here is that we don't really have any hot zones in our dataset. It's basically going to get an evenly distributed load amongst all documents. Basically we've come up with 2 options to do this. The one that I described above, where all data for all customers is piled into one collection. This means we'd have to create an index om some field that links the documents in that collection to a particular customer. The other options is to throw all b's and c's together (these sets are relatively small) but divide up the C collection, one per customer. I can imangine this last solution being a bit harder to manage, but since we rarely access data for multiple customers at the same time, it would prevent memory problems. MongoDB would be able to load the customers index into memory and just run from there. What are your thoughts on this? P.S.: I hope this wasn't too vague, if anything is unclear I'll go into some more details.
Split large collection into smaller ones?
1
1.2
1
1
0
239
12,210,976
2012-08-31T07:46:00.000
0
0
0
0
0
python,windows,wxpython
0
12,216,343
0
2
0
false
0
1
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 something you can manage with wxPython. It's something you have to manage at the OS level.
1
1
0
0
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?
Block windows key wxPython
1
0
1
0
0
876
12,212,473
2012-08-31T09:24:00.000
0
0
0
0
0
python,emacs,rope
0
12,436,344
0
1
0
true
0
0
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
0
0
0
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 libraries are. I dont know how to do it though. Any pointers will be helpful
Jumping to Python library sources with epy/emacs
0
1.2
1
0
0
218
12,218,088
2012-08-31T15:08:00.000
0
1
0
0
0
c++,python,linux,perforce,vms
0
13,205,270
0
2
0
false
0
0
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 Linux Perforce client. And do "review" locally on Linux. If you've no Linux client, I'd try fetching the latest revisions off and importing raw files it into an external repository (svn, git, fossil etc.). Then again using Linux client and tools. If your ultimate goal is to do all development off VMS, then it may not really be viable -- the code may use VMS specific includes, system/RMS calls, data structs. And sync'ing the changes back and forth to VMS will get messy. From my experience, once you're familiar with the code-base, it's a lot more effective to make the code-changes directly on VMS using whatever editor is available (EDIT/TPU, EDT, LSE, emacs or vim ports etc.). As for debugging - VMS native debugger supports X-GUI as well as command-line. Check your build system for debug build, or use /NOOPT /DEBUG compile and /DEBUG link qualifiers. BTW, have a look into DECset, if installed on your VMS system.
2
1
0
0
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 prefer using python and kscope (a kde based file search/code-review GUI tool that can generate call graph) or similar tools on VMS. I do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the authorization. Would you please give me some suggestions about how to do code-review/debug/programing/compile/test by python on VMS meanwhile using kscope or similar large-scale files management tools for code-review ? Any help will really be appreciated. Thanks
How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS
0
0
1
0
0
281
12,218,088
2012-08-31T15:08:00.000
1
1
0
0
0
c++,python,linux,perforce,vms
0
12,220,702
0
2
0
false
0
0
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 is functional there. I would recommend starting off with the basics. Get a basic build system working that let's you build in release and debug. Consider starting with either MMS (an HP provided make like tool) or GNU make. You should also spend some time making sure that your VMS based Perforce client is working too. There are some quirks that may or may not have been fixed by the nice folks at Perforce. If you have more specific issues in setting up GNU make (on VMS) or dealing with the Perforce client on VMS, do ask, but I'd recommend creating separate questions for those.
2
1
0
0
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 prefer using python and kscope (a kde based file search/code-review GUI tool that can generate call graph) or similar tools on VMS. I do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the authorization. Would you please give me some suggestions about how to do code-review/debug/programing/compile/test by python on VMS meanwhile using kscope or similar large-scale files management tools for code-review ? Any help will really be appreciated. Thanks
How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS
0
0.099668
1
0
0
281
12,225,244
2012-09-01T05:42:00.000
0
0
0
1
0
python,unit-testing,nose
0
12,226,647
0
1
0
false
0
0
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 the pyc files, as simply deleting them out in the shell wasn't doing it. Good enough for now. Edit: *Apparently I didn't entirely solve it. It does seem to work for a bit, and then all of a sudden it won't anymore, and I have to restart my shell. Now I'm even more confused.
1
0
0
0
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 file references somehow, but even deleting the *.pyc files, I can never get the output of nose.run() to change until I restart the shell, or open another one, whereupon the problem starts again on the second run. I've tried both del nose and reload(nose) to no avail.
nose.run() seems to hold test files open after the first run
0
0
1
0
0
193
12,229,881
2012-09-01T17:30:00.000
0
0
0
0
0
google-app-engine,version-control,python-2.7
0
12,230,416
1
2
0
false
1
0
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.
2
1
0
0
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. So how long before changes show up? If there is a way to force these to happen I would greatly appreciate it. Thank you in advance of your assistance in this matter.
deleted version are still being serverd in appspot.com
1
0
1
0
0
155
12,229,881
2012-09-01T17:30:00.000
1
0
0
0
0
google-app-engine,version-control,python-2.7
0
18,547,441
1
2
0
false
1
0
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.
2
1
0
0
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. So how long before changes show up? If there is a way to force these to happen I would greatly appreciate it. Thank you in advance of your assistance in this matter.
deleted version are still being serverd in appspot.com
1
0.099668
1
0
0
155
12,234,623
2012-09-02T08:57:00.000
0
0
0
0
0
python,user-interface,wxpython,cross-platform
0
12,235,213
0
1
0
true
0
1
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 (Windows) or whatever native toolkit on your platform, as it is normally more updated to the latest API than wxPython.
1
0
0
0
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.), but they are individual. Is there a way I can "mix" those GUI libraries into a single app? How can I provide the best GUI experience in a cross-platform app? Any help or suggestions are greatly appreciated.
Multiple GUI Kits in a single Python app
0
1.2
1
0
0
294
12,273,201
2012-09-05T00:55:00.000
2
0
1
0
0
python,regex
0
12,273,291
0
2
0
false
0
0
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.
1
0
0
0
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 be replaced by C or T how can we find if the string matches the sequence by substituting valid values for n and k Is there any regular expression ?
string matching with substitution using PYTHON
0
0.197375
1
0
0
118
12,277,864
2012-09-05T09:02:00.000
1
0
1
0
0
python,csv
0
12,277,912
0
3
0
false
0
0
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.
1
8
1
0
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?
python clear csv file
0
0.066568
1
0
0
41,353
12,289,700
2012-09-05T21:00:00.000
0
0
0
0
0
python,selenium
0
60,626,053
0
5
0
false
1
0
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??
2
7
0
0
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 extensively to try and find out.
Passing variables through Selenium send.keys instead of strings
0
0
1
0
1
9,992
12,289,700
2012-09-05T21:00:00.000
1
0
0
0
0
python,selenium
0
47,662,083
0
5
0
false
1
0
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.
2
7
0
0
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 extensively to try and find out.
Passing variables through Selenium send.keys instead of strings
0
0.039979
1
0
1
9,992
12,290,694
2012-09-05T22:29:00.000
0
0
0
0
0
python,scrapy,portable-python
0
20,853,931
0
1
0
false
1
0
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.
1
1
0
0
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
How do you add the scrapy framework to portable python?
1
0
1
0
0
658
12,295,834
2012-09-06T08:20:00.000
4
0
0
0
0
php,javascript,python,xml,perl
0
12,295,930
0
1
0
true
1
0
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
1
0
0
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 file using php/python/javascript/perl.
Export a website to an XML Page
0
1.2
1
0
1
2,036
12,296,563
2012-09-06T09:03:00.000
1
0
0
0
0
python,excel,win32com
0
13,086,152
0
4
0
false
0
0
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, the commands used would guide you to the corresponding commands in python that you need to use. Pythonwin You can use pythonwin to browse the underlying win32com defined objects (in your case Microsoft Excel Objects). In pythonwin (which can be found at \Lib\site-packages\pythonwin\ in your python installation), go to Tools -> COM Makepy Utility, select your required Library (in this case, Microsoft Excel 14.0 Object Library) and press Ok. Then when the process is complete, go to Tools -> COM Browser and open the required library under Registered Libraries. Note the ID no. as this would correspond to the source file. You can browse the various components of the library in the COM Browser. Source Go to \Lib\site-packages\win32com\ in your python installation folder. Run makepy.py and choose the required library. After this, the source file of the library can be found at \Lib\site-packages\win32com\gen_py . It is one of those files with the wacky name. The name corresponds to that found in Pythonwin. Open the file, and search for the commands you saw in the Excel Macro. (#2 and #3 maybe redundant, I am not sure)
1
0
0
1
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 of cells, such as font, back-color ? So maybe all I wanna know is the doc, you know how to fish is more useful than fishes.... and an example is better.
How to draw a chart with excel using python?
0
0.049958
1
1
0
2,868
12,298,811
2012-09-06T11:12:00.000
2
1
0
0
0
python,openerp
0
12,298,831
0
2
0
true
0
0
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 Run'). 3: After creating new debug configuration follow the given steps: 3.1: In "Main" tab under "Project", select the "server" project or folder (in which Openerp Server resides) from your workspace. 3.2: Write location of 'openerp-server' under "Main Module". Ex: ${workspace_loc:server/openerp-server}. 3.3: In "Arguments" tab under "Program Arguments", click on button "Variables" and new window will appear. 3.4: Then create new "Variable" by clicking on "Edit Variables" button and new window will appear. 3.5: Press on "New" button and give your addons path as value. Ex: --addons ../addons,../your_module_path 3.6: Press Ok in all the opened windows and then "Apply". 4: Now into "PyDev Package Explorer" view go to 6.1/server and right click on "openerp-server" file, Select 'Debug As --> Python Run'. 5: Now in "Console" you can see your server has been started. 6: Now open your .py file which you want to debug and set a break-point. 7: Now start your module's form from 'gtk' or 'web-client' and execution will stop when execution will reach to break-point. 8: Now enjoy by debugging your code by pressing "F5, F6, F7" and you can see value of your variables.
1
2
0
0
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???
how can i debug openerp code in to the eclipse
0
1.2
1
0
0
3,051
12,318,437
2012-09-07T12:46:00.000
9
0
1
0
0
python,python-3.x,python-2.x
0
12,318,539
0
6
0
false
0
0
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.7. Finally, if anything you are using includes full unicode support, don't sell yourself short -- go with Python3. The simplification of unicode alone is worth it.
2
9
0
0
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.
Confused about the choice between Python 2 vs Python 3
0
1
1
0
0
7,661
12,318,437
2012-09-07T12:46:00.000
1
0
1
0
0
python,python-3.x,python-2.x
0
12,318,536
0
6
0
false
0
0
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 you get. Only if you know you need to support whatever you are developing on other platforms that you don't control, it may be better to start with Python 2.
2
9
0
0
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.
Confused about the choice between Python 2 vs Python 3
0
0.033321
1
0
0
7,661
12,335,114
2012-09-08T22:53:00.000
2
1
0
1
1
python,rsync,fabric
0
12,335,299
0
2
0
true
0
0
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
1
0
0
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) passwords stored as plain-text in database. Please provide me any suggestions how should I work with it.
Putting password for fabric rsync_project() function
0
1.2
1
0
0
1,763
12,337,318
2012-09-09T07:36:00.000
-2
0
0
0
0
python,django,web-applications,django-admin
0
12,337,353
0
2
0
false
1
0
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 security you need.
2
0
0
0
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. Upload, delete static files Grouping static files (creating new folders, adding new/ existing files to it); I am not sure If it is possible. checking my models Thus, I would like to know how secure is Django-Admin interface! How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of "cracking".. is django admin can be cracked easily?)
How secure is Django Admin interface
1
-0.197375
1
0
0
2,419
12,337,318
2012-09-09T07:36:00.000
0
0
0
0
0
python,django,web-applications,django-admin
0
12,337,841
0
2
0
false
1
0
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 careful when choosing credentials. Since I don't know how secure Google and Yahoo really are, I can't compare to them.
2
0
0
0
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. Upload, delete static files Grouping static files (creating new folders, adding new/ existing files to it); I am not sure If it is possible. checking my models Thus, I would like to know how secure is Django-Admin interface! How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of "cracking".. is django admin can be cracked easily?)
How secure is Django Admin interface
1
0
1
0
0
2,419
12,341,610
2012-09-09T18:12:00.000
0
1
0
0
1
python,python-2.7,mod-wsgi
0
12,444,455
0
2
0
false
1
0
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 name of 'apxs' in Apache 2.2 distros to be 'apxs2'. This is why the mod_wsgi configure script checks for 'apxs2' as well as 'apxs'. So, do the actual make and see if that fails before assuming you have the wrong apxs.
2
0
0
0
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 I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python/Django environment up and running on my VPS.
Error when installing mod_wsgi
0
0
1
0
0
314
12,341,610
2012-09-09T18:12:00.000
2
1
0
0
1
python,python-2.7,mod-wsgi
0
12,341,622
0
2
0
false
1
0
checking for apxs... /usr/sbin/apxs ... config.status: creating Makefile It succeeded. Go on to the next step.
2
0
0
0
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 I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python/Django environment up and running on my VPS.
Error when installing mod_wsgi
0
0.197375
1
0
0
314
12,342,807
2012-09-09T20:44:00.000
1
0
0
0
0
python,pyqt4,pjsip
0
12,426,092
0
1
0
true
1
0
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.MuteUnmuteSpeakerButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteSpeaker) def MuteUnmuteMic(self): try: if self.MuteMic: self.MuteMic = False self.parent().unmute_mic() else: self.MuteMic = True self.parent().mute_mic() except: debug ("ошибка при вызове функции включение или отключение микрофона (call Window).") def MuteUnmuteSpeaker(self): try: if self.MuteSpeaker: self.MuteSpeaker = False self.parent().unmute_speaker() else: self.MuteSpeaker = True self.parent().mute_speaker() except: debug ("ошибка при вызове функции включение или отключение микрофона (call Window).") # other code ---------- # ----------------------core of the my app # ---import PJUA lib---- def mute_mic(self): #this that you need in my case my app connected to pjua "self.lib" self.lib.conf_set_rx_level(0,0) debug ("вызвана функция выключение микрофона") def unmute_mic(self): self.lib.conf_set_rx_level(0,1) debug ("вызвана функция включение микрофона") def mute_speaker(self): self.lib.conf_set_tx_level(0,0) debug ("вызвана функция выключение динамиков") def unmute_speaker(self): self.lib.conf_set_tx_level(0,1) debug ("вызвана функция включение динамиков")
1
0
0
0
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 to the specified port by making it louder or quieter. Keyword arguments: slot -- integer to identify the conference slot number. level -- Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port. """ lck = self.auto_lock() err = _pjsua.conf_set_tx_level(slot, level) self._err_check("conf_set_tx_level()", self, err) def conf_set_rx_level(self, slot, level): """Adjust the signal level to be received from the specified port (to the bridge) by making it louder or quieter. Keyword arguments: slot -- integer to identify the conference slot number. level -- Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port. """ lck = self.auto_lock() err = _pjsua.conf_set_rx_level(slot, level) self._err_check("conf_set_rx_level()", self, err) well I understand I need to send a parameter 0, but how to do? And to return back work the sound device and microphone. Maybe it """""pjsua_conf_adjust_tx_level(slot_number, 0 )"""""
pyqt4, function Mute / Un mute microphone and also speakers [PJSIP]
0
1.2
1
0
0
1,239
12,342,820
2012-09-09T20:45:00.000
2
0
0
0
0
python,django,session,cookies
0
12,343,112
0
1
0
true
1
0
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 when it is modified by Django. You can't expire data automatically, except by either the cookie itself expiring (in which case the entire set of data persists in the session store, but is no longer associated with the client) or by running a process on the server that modifies sessions programmatically. There's no way of telling from the server end when a user leaves a website or closes his browser. So the only way of managing this would be to run a cron job on your server that gets sessions that were last modified (say) two hours ago, and iterate through them deleting the data you want to remove.
1
1
0
0
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. I found ways to purge the entire session cookie every time a user leaves the website, but ideally I would like to only delete select pieces of the cookie which I explicitly set. Does anyone know how to do this?
Delete pieces of Session on browser close
0
1.2
1
0
0
1,943
12,344,187
2012-09-10T00:44:00.000
0
0
1
0
0
python,windows-7
0
12,344,713
0
5
0
false
0
0
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 even if there is an error, so you can see the error callback for reference. That will tell you where you are getting the error, and will allow you to fix the code accordingly. of course, you could always just tack on input() or time.sleep() to the end and hope that helps, but that's up to you. I recommend using an IDE like one I mentioned above.
1
0
0
0
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 help much. In older Windows I'd simply check the checkbox on apropriate tab, but how do I do it on this frelling eye candy?
How to stop python interpreter from closing on Windows 7?
0
0
1
0
0
1,943
12,344,481
2012-09-10T01:42:00.000
0
0
1
0
0
python
0
12,344,677
0
2
0
false
0
0
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 right. Second, be sure to inform the IDE of what Python interpreter are you using, as well as any particular Python path that your project might be using; all of that you can do in Project/Project Properties. Finally, you still might need to give hints sometimes to the IDE about your instances with "assert isinstance(x,SomeType)". Admittedly, is not as straightforward as using Visual Studio, but the good reasons to use Python and its very capable ecosystem, or the easy integration with C/C++ more than compensate.
1
0
0
0
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?
how do i know what parameters a python function takes with wingware IDE
0
0
1
0
0
468
12,348,291
2012-09-10T08:56:00.000
1
0
1
1
0
python,windows-7,command-line,tags,command-line-arguments
1
12,348,372
0
2
0
true
0
0
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
0
0
0
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
how do i pass multiple files as arguments in command line for python using regular expressions?
0
1.2
1
0
0
1,629
12,351,786
2012-09-10T12:30:00.000
-2
0
0
0
0
python,tkinter
0
12,351,926
0
5
0
false
0
1
The function which normally prints to stdout should instead put the text into text widget.
1
18
0
1
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 which does the task (This code is used by some other programs as well). Can someone please point me to how I can use this existing task definition and use its STDOUT result and insert it into a text widget? In the main GUI program I want to call this task definition and print its results to STDOUT. Is there a way to use this information?
How to redirect print statements to Tkinter text widget
1
-0.07983
1
0
0
23,774
12,355,416
2012-09-10T16:05:00.000
0
0
0
0
0
python,numpy,scipy,data-mining
0
12,369,285
0
2
0
false
0
0
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 access errors when querying for your data for various inconsistency reasons. Try using a NoSQL database. I personally user MongoDB and Pymongo on python to store the training examples as dicts in JSON format. (Easier for web apps this way).
2
1
0
0
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 this, but i fear it will quickly become messy as i add more features. My question: how can i best represent and persist this kind of multi dimensional data? Python specific tips would be helpful. Thank you
Multi feature recommender system representation
0
0
1
1
0
289
12,355,416
2012-09-10T16:05:00.000
0
0
0
0
0
python,numpy,scipy,data-mining
0
24,491,488
0
2
0
false
0
0
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.
2
1
0
0
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 this, but i fear it will quickly become messy as i add more features. My question: how can i best represent and persist this kind of multi dimensional data? Python specific tips would be helpful. Thank you
Multi feature recommender system representation
0
0
1
1
0
289
12,375,113
2012-09-11T17:43:00.000
2
1
0
0
1
python,gmail,gmail-imap,imaplib
1
12,375,120
0
2
0
false
0
0
IMAP server is still imap.gmail.com -- try with that?
1
1
0
0
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.gmail.companyname.com", 993), I get an error gaierror name or service not known. Does anybody know how to connect to a my company gmail with imaplib?
IMAP in Corporate Gmail
0
0.197375
1
0
1
321
12,382,229
2012-09-12T06:19:00.000
0
0
0
0
0
python,multithreading,python-2.7,exit,kill
0
12,390,276
0
1
0
true
0
0
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 terminate and the main thread will complete the join call, reaching the bottom of your main.
1
0
0
0
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 ... Is there (I am convinced there is, I just yet don't know how) a way to acomplish this? Signal handle? Thanks guys
Terminate python application waiting on semaphore
0
1.2
1
0
1
487
12,383,540
2012-09-12T07:53:00.000
3
0
0
0
0
python,django,authentication
0
12,383,605
0
6
0
false
1
0
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.
1
18
0
0
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 default Django user management. I assume I have to write a custom authentication backend for that, but the documentation confuses me as the authenticate() function seems to expect a username/password combination or a token. It is not clear to me how to authenticate using IP addresses here. What would be the proper way to implement IP address-based authentication in Django? I'd prefer to use as much existing library functions as possible for security-related code instead of writing all of it myself.
Authenticate by IP address in Django
0
0.099668
1
0
0
16,527
12,383,697
2012-09-12T08:04:00.000
11
0
0
1
0
python,cookies,tornado
0
12,385,159
0
1
0
true
1
0
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
7
0
0
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 passing an integer value: the value is considered as day, i.e. 1 means 1 day passing a float value: it works, for example setting 0.1 it means almost one hour and a half
Tornado secure cookie expiration (aka secure session cookie)
0
1.2
1
0
0
4,626
12,394,528
2012-09-12T18:54:00.000
2
0
0
0
0
python,database,python-3.x,redis
0
12,394,712
0
1
0
true
1
0
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. To that end, you should outsource blocking calls to another thread or make use of greenlets. If there is only one client, there definitely is no need to fetch a property from the DB on each value lookup. If there are multiple clients reading the data and only one client modifying the data, you have to think about which level of synchronization you need. If you need 100 % synchronization, you will have to fetch data from the DB on each value lookup. If there are multiple clients changing the data in the database you better look into a rock-solid industry standard solution rather than writing your own DB cache/mapper. Your distinction between (2) and (3) does not really make sense. If you fetch data on every lookup, there is no need to 'store' data. You see, if there can be multiple clients involved these things quickly become quite complex and it's really hard to get it right.
1
0
0
0
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 how to get data from DB for best performance: Load values for each field on instance creating and initialize fields with it. Load field value each time on field value requesting. As second one but after value load replace field property by loaded value. p.s. redis runs in localhost
Which one data load method is the best for perfomance?
0
1.2
1
0
0
96
12,414,570
2012-09-13T20:49:00.000
3
0
1
0
0
python,search-path
0
12,414,602
0
2
0
true
0
0
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
1
0
0
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.
how the python interpreter find the modules path?
0
1.2
1
0
0
1,511
12,418,822
2012-09-14T05:50:00.000
0
1
0
0
0
javascript,python,extjs,embedded
0
12,436,279
0
1
0
true
1
0
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
3
0
0
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 space and it can be uncompressed by browser very well. All I have to do is handle the headers. Now the question is how do I include the .gz file so browser understands and decompresses? Well i am aware that a .gz file contains file structure information while browser accepts only raw gzipped data. In that I would like to store the raw gzipped data. It'd some sort of caching!
Use compressed JavaScript file (not run time compression)
0
1.2
1
0
0
332
12,431,847
2012-09-14T20:55:00.000
2
0
1
1
0
python,python-3.x,python-2.7,pypy
0
12,432,095
0
2
0
false
0
0
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 variable goes out of scope as in CPython.
1
8
0
0
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 some usage examples on pypy? Google does not contain much info on pypy other than its description.
Usage of pypy compiler
0
0.197375
1
0
0
7,679
12,440,044
2012-09-15T18:39:00.000
-3
0
0
0
0
python,unit-testing,sqlalchemy,rollback
0
12,443,800
0
1
0
true
0
0
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 best choice for unit tests.
1
4
0
1
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 plan for the project is to have one database, I do not want to create a test database. I could not find in the documentation on SQL Alchemy on how to properly rollback the database changes. Does anyone know how to rollback the database transaction?
How to rollback the database in SQL Alchemy?
0
1.2
1
1
0
3,017
12,444,496
2012-09-16T04:55:00.000
0
0
0
0
0
python,django,nlp,summarization
0
55,256,456
0
2
0
false
1
0
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.
2
2
0
0
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 for me in Django/Python?
Auto Text Summarization
0
0
1
0
0
1,797
12,444,496
2012-09-16T04:55:00.000
2
0
0
0
0
python,django,nlp,summarization
0
43,989,780
0
2
0
false
1
0
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 The Usurper: spaCy The Admiral: gensim First off learn about different kinds of summarizations and what suits you best. Also, remember to make sure you have a proper preprocessing tool for the language you are targeting as this is very important for the quality of your summarizer.
2
2
0
0
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 for me in Django/Python?
Auto Text Summarization
0
0.197375
1
0
0
1,797
12,455,069
2012-09-17T07:49:00.000
0
0
1
0
0
python,speech-recognition
0
18,925,412
0
2
0
false
0
0
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-process recognizer.
1
3
0
0
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?
How to input and process audio files to convert to text via pyspeech or dragonfly
0
0
1
0
0
1,965
12,470,094
2012-09-18T03:43:00.000
0
0
0
0
0
python,sql,dna-sequence,genome
0
12,474,645
0
1
0
true
0
0
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 is tentavely close to 32 bits and could fit into 64 bits. hashing / bitfiddling might be an option
1
1
1
0
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 discrete key, since the basis of the search is to locate and isolate (but not remove) duplicates. I'm looking for an algorithm that can go through the data in a relatively short amount of time to locate these patterns and similarities, and I can work out the regex expressions for comparison, but I'm not sure how to get a faster search than O(n). Any help would be appreciated. Thanks
Fast algorithm comparing unsorted data
0
1.2
1
0
0
386
12,470,417
2012-09-18T04:33:00.000
1
0
0
0
0
python,opengl,pyglet
0
12,471,143
0
2
0
true
0
1
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: Textures are by far the best approach, but if you really don't want to use textures, you can do the following, which is the next best thing: Make a static VBO or display list of points that is maybe six times as large as it needs to be in the direction of scroll (e.g. if you're running 800x600 screen and you're scrolling horizontally, generate points on a 4800x600 grid). Draw these points twice, offset by the width and the scrolling variable. E.g., let x be your scrolling variable (it starts at 0, then is incremented until it reaches 4800 (the width of your points), and then wraps back around and restarts at 0). Each frame, draw your points with a glTranslatef(x,0,0). Then draw them again with a glTranslatef(x+4800,0,0). In this way your points will scroll past seemingly continuously. The constant (I chose six, above) doesn't really matter to the algorithm. Larger values will have fewer repeats but slower performance. You can also try doing all of the above several times with different scrolling constants to give the illusion of depth (with multiple layers). ] In the latter, there are a bunch of clever algorithms I can think of, but I'd suggest just using the raw points (point sprites if you're feeling fancy); GPUs can handle this if you put them in a static VBO or display list. If your points are small, you can probably throw a few thousand up at a time without any noticeable performance hit.
1
2
0
0
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 and moving them manually but I was hoping there was a neater alternative. EDIT: In answer to Ian Mallett I guess what I am trying to ask is if I generate a bunch of points, is there some way I can blit these onto some kind of surface or buffer and scroll this in the background. Also as for what kind of star-field all I am trying to generate at this stage all I am trying for a simple single layer for a top down game, pretty much how you would have in asteroids
Scrolling starfield with gl_points in pyglet
1
1.2
1
0
0
1,710
12,472,432
2012-09-18T07:38:00.000
1
0
0
1
0
python,xampp,osqa
0
13,022,630
0
1
0
true
0
0
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
0
0
0
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.
install OSQA using xampp on windows 7
0
1.2
1
0
0
201
12,479,206
2012-09-18T14:35:00.000
1
0
0
0
0
python,django
0
12,480,077
0
1
0
false
1
0
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 the level where he belongs, this should work. A similar approach, maybe less intuitive, is to give to each level a number (or alpha-numeric value), so that in the end a user associated to the level "state" in your example, has a level code of 23 (let's say: "ex-country": 2 and "state": 3), so that he can add sub-levels starting with the prefix 23.
1
0
0
0
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 division has access to all classrooms within it etc My question is how do I make this permissions system configurable across clients. The application should a new client to define arbitrary levels - ex country -> state -> city -> schools -> class. Any ideas on what are good approaches ?
creating a configurable permissions system in django
0
0.197375
1
0
0
167
12,487,415
2012-09-19T01:33:00.000
1
0
1
0
0
python,regex
0
12,487,430
0
1
0
true
0
0
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
1
0
0
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 example I have the pattern repeating and that is why the semi colon or *??5 - a * followed by two qnestions marks followed by a number and no semi colon as there are no repeating groups This is what i currently have .+\?\?\d+(;|)+
python regular expression repeating pattern match
0
1.2
1
0
0
3,006
12,492,337
2012-09-19T09:50:00.000
0
0
1
0
0
python
0
12,492,718
0
3
0
false
0
0
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 of that tile. Loop through the all the tiles using your coordinate system. For each tile, retrieve its neighbours. If a neighbour does not have a type you can ignore it, otherwise, determine the character of a tile based on the character of its neighbours.
2
0
0
0
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 mountains - but in one field may be the transition from water to land with one of the sides. An array will consist of a number specifying the type of tile. I want to do it in python - for learning. Some advice please.
How to write own map generator?
0
0
1
0
0
296
12,492,337
2012-09-19T09:50:00.000
0
0
1
0
0
python
0
12,492,724
0
3
0
false
0
0
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 you could then just iterate over all squares picking a random choice from the set of allowable tiles (based on it's current neighbours).
2
0
0
0
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 mountains - but in one field may be the transition from water to land with one of the sides. An array will consist of a number specifying the type of tile. I want to do it in python - for learning. Some advice please.
How to write own map generator?
0
0
1
0
0
296
12,500,623
2012-09-19T18:22:00.000
1
0
0
0
0
python,django,file-upload,django-file-upload
0
12,623,702
0
2
0
false
1
0
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 the files onto the FileServer the easiest way, is just to upload to the AppServer and then have that upload to another server. this is what most AmazonS3 implementations are like. if the two machines are on the same LAN , you can mount a volume of the FileServer onto the AppServer using NFS or something similar. Users upload to the AppServer, but the data is saved to a partition that is really on the FileServer. You could have a file upload script work on the FileServer. However, you'd need to do a few complex things: have a mechanism to authenticate the ability to upload the file. you couldn't just use an authtkt, you'd need to have something that allows one-and-only-one file upload along with some sort of identifier and privilege token. i'd probably opt for an encrypted payload that is timestamped and has the upload permission credentials + an id for the file. have a callback on successful upload from the FileServer to the AppServer, letting it know that the id in the payload has been successfully received.
1
2
0
0
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 like to make the file server simple as possible. The file server just serve files. Ideally, transfer costs between the app server and the file server are zero. Could somebody tell me how to do this?
Django: How to upload directly files submitted by a user to another server?
0
0.099668
1
0
0
1,077
12,511,801
2012-09-20T11:37:00.000
2
0
1
0
0
python
0
12,511,861
0
5
0
false
0
0
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'=2 } D2 = { 'c':3, 'b':3} Then, D3 will be: D3= { 'a':1, 'b':3, 'c':3 }
1
19
0
0
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?
Merging of two dictionaries
0
0.07983
1
0
0
3,838
12,522,844
2012-09-21T00:38:00.000
0
1
0
0
0
python-3.x
0
12,522,892
0
3
0
false
0
0
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.
1
3
0
0
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 the character set used by tempfile is defined as: characters = "abcdefghijklmnopqrstuvwxyz0123456789_" then I end with some files with names like "_6456_" and asciidoc interprets the "_" as formatting and inserts some html that breaks the report. I need to either find a way to "escape" the filenames in asciidoc or control the characters in the temporary file. My current solution is to rename the temporary file after I close it to replace the "_" with some other character (not in the list of characters used by tempfile to avoid a collision) but i have the feeling that there is a better way to do it. I will appreciate any ideas. I'm not very proficient with python yet, i think overloading _RandomNameSequence in tempfile will work, but i'm not sure how to do it. regards.
change character set for tempfile.NamedTemporaryFile
0
0
1
0
0
491
12,532,631
2012-09-21T14:34:00.000
0
1
0
0
1
python,audio,loops,playback
0
31,437,197
0
1
0
false
1
0
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, similar to this, is to manage the latency your self. You can queue up and or mix your small sound files manually to e.g. sizes of 0.5 -1 sec. This will greatly reduce the requirement to the "realtimeness" and alow you to do some pretty cool transitions between "speeds" I do not know what sort of latency you can cope with, but if we are talking about train speeds, I guess they do not change instantaneous - hence latency of 500ms to several seconds is most likely acceptable.
1
4
0
0
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 possible python-audio-solutions, including PyAudio PyMedia pyaudiere but I'm not sure which one suits best my use-case, so I do really appreciate any propositions and experiences! PS: I did already try out gstreamer but since the 1.0 release is not there yet and I cant figure out how to get gapless playback to work with pygi, i thought there might be a better choice. I also tried pygame, but it seems like it's limited to 8 audio channels??
Python Audio library for fast, gapless looping of many short audio tracks
0
0
1
0
0
1,335
12,542,111
2012-09-22T08:22:00.000
1
0
1
0
0
python
0
12,543,014
0
4
0
false
0
0
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 class - ShowMeTheMoney - is defined inside class1_file.py, and the file structure is: /project /classes /__init__.py /class1_file.py /class2_file.py /class1_imp_.py (BTW, the file and class names must be different; the program will fail if the class and the file names are the same.)     You can implement it in the class1_imp_.py using: # class1_imp_.py import classes.class1_file as any_name class1_obj = any_name.ShowMeTheMoney() #continue the remaining processes Hope this helps.
1
7
0
0
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?
Separating class definition and implementation in python
0
0.049958
1
0
0
3,065
12,545,418
2012-09-22T16:07:00.000
3
0
0
0
0
python,django,apache,webserver,openshift
0
12,546,511
0
1
0
false
1
0
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 dashboard. Do not use dynamic routing. Just layout and maintain the proper directory structure using the databoard. Optionally, keep the directory structure and file metadata in some database server for faster searches and manipulation. This should result in a very low overhead static file server.
1
0
0
0
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 static files To setup API kind of thing (end point: JSON objects) so that I can use this project to serve my web apps! As openshift uses Apache!, I am thinking to dynamically edit htaccess and serve the files.. but not sure whether it would be possible or not Or, I can use django's urls.py to serve the files but I don't think djano is actually made for. Any ideas and suggestion?
A web application to serve static files
1
0.53705
1
0
0
402
12,553,197
2012-09-23T14:36:00.000
0
0
0
0
1
python,perl,language-agnostic
1
12,553,211
0
2
0
false
1
0
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?
1
1
0
0
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 escaped, this results in records containing too many fields, which cause the database to throw an exception and stop loading. I know what the record should look like (text, integer, float fields). Does anyone have suggestions on how to fix the overlong records? I code in per but I am happy with suggestions in python, javascript, plain english.
Messed up records - separator inside field content
0
0
1
1
0
111
12,569,076
2012-09-24T16:24:00.000
5
0
1
0
0
python
0
14,501,078
0
1
0
false
0
0
there is a python icon on the interface .click and change
1
2
0
0
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.
WingIDE -- Python 2 and Python 3
0
0.761594
1
0
0
609
12,573,915
2012-09-24T22:40:00.000
1
0
0
1
0
python,google-app-engine,caching,distributed-caching,image-caching
0
12,585,067
0
3
0
false
1
0
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 overly long expiry, users will never see an updated version. Often the solution to this is to change the url when you change the version.
1
0
0
0
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 wanted to mention it just in case. Anyway are there any recommended methods for caching images or preventing them from eating up my read and write quotas?
Options for Image Caching
1
0.066568
1
0
0
717
12,576,724
2012-09-25T05:34:00.000
4
0
1
0
0
python,unit-testing,python-3.x,arguments,software-design
0
12,576,771
0
2
0
true
0
0
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 using "streams" is that you pass it to your function and then your function reads from it -- effectively changing it's state. Depending on your program, recovering that state could be messy if it's necessary. (e.g. you might need to litter you code with f.tell() and then f.seek().)
1
14
0
0
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 for the test more flexible, since I can use it in situations where I somehow already have the contents of the file in a variable Are there any disadvantages to streams? Or should I always refactor a function from a file name argument to a stream argument (assuming, of course, the file is text-only)?
file name vs file object as a function argument
0
1.2
1
0
0
3,700
12,603,678
2012-09-26T14:11:00.000
2
0
1
0
0
python,django,concurrency,webserver
0
12,604,317
0
3
0
false
0
0
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.
2
16
0
0
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?
How does a python web server overcomes GIL
0
0.132549
1
0
1
2,640
12,603,678
2012-09-26T14:11:00.000
1
0
1
0
0
python,django,concurrency,webserver
0
12,603,848
0
3
0
false
0
0
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.
2
16
0
0
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?
How does a python web server overcomes GIL
0
0.066568
1
0
1
2,640
12,613,552
2012-09-27T03:14:00.000
0
0
0
1
1
python,shell,terminal,centos
1
12,613,729
0
3
0
false
0
0
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 time you will not get such prompt/alert. To avoid this prompt/alert in batch script, you can use turn strict host check off use scp -Bqpo StrictHostKeyChecking=no but you are vulnerable to man-in-the-middle attack. you can also choose to connect to target server manually and save host public key before deploy your batch script.
1
0
0
0
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, the problem is once I have run the one-liner command (like the one shown below) scp xxx@localhost:file1.txt yyy@]192.168.104.XXX:file2.txt it will definitely ask for something like Are you sure you want to connect (yes/no)? Password : And if im not mistaken., once I have sent this command (assuming that I code this in python) conn.modules.os.popen("scp xxx@localhost:file1.txt yyy@]192.168.104.XXX:file2.txt") and followed by this command conn.modules.os.popen("yes") The output (and I'm quite sure that it would give me errors) would be the different comparing it to the output if I manually type it in in the terminal. Do you know how to code this in python? Or could you tell me something (a command etc.) that would solve my problem Note: I am using RPyC to connect to other remote machines and all machines are running on CentOS
How to automate the sending of files over the network using python?
0
0
1
0
1
1,825
12,623,155
2012-09-27T13:59:00.000
3
0
1
1
0
python,macports,homebrew
0
12,623,496
0
1
0
true
0
0
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
1
0
0
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 how to set Python to use the libraries installed via Homebrew, I suppose change the path effectively?
Python libraries after removing MacPorts and installing homebrew
0
1.2
1
0
0
215
12,627,401
2012-09-27T17:59:00.000
0
1
1
0
0
python,symbols,decompiling
0
15,160,831
0
2
0
false
0
0
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 I look at the datasheet to find this fact. What you are looking for might not have a good answer because the Python interpreter is not a full fledged version. What I did was to use the same local variable names as many as possible. Also I deleted doc strings for functions (those count too) and replace with #comments. In the end, I want to say that this module is good for small applications. The python interpreter does not support threads or interrupts so your program must be a super loop. When your application gets bigger, each iteration will take longer. Eventually, you might want to switch to a faster platform.
1
2
0
0
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 would like to know how to get the number of symbols being generated, size in RAM of each variable, memory usage (stack and heap usage). I need something similar to a map file that gets generated with gcc after the linking process which shows me each constant / variable, symbol, its address and size allocated.
Counting number of symbols in Python script
0
0
1
0
0
403
12,631,577
2012-09-27T23:32:00.000
3
1
0
1
0
python,embedded
0
12,632,227
0
3
0
false
0
0
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. For example, you can probably throw out a big chunk of the parser and compiler and just deal with nothing but bytecode. The problem is that the only way to do that is to hack the interpreter source. (And it's not the most beautiful code in the world, so you're going to have to dedicate a good amount of time to learning your way around.) And you'll have to know what features you can actually hack out. The only other real alternative would be to write a smaller interpreter for a Python-like language—e.g., by picking up the tinypy project. But from your comments, it doesn't sound as if "Python-like" is sufficient for you unless it's very close. Well, I suppose there's one more alternative: Hack up a different, nicer Python implementation than CPython. The problem is that Jython and IronPython aren't native code (although maybe you can use a JVM->native compiler, or possibly cram enough of Jython into a J2ME JVM?), and PyPy really isn't ready for prime time on embedded systems. (Can you wait a couple years?) So, you're probably stuck with CPython.
1
17
0
0
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 for me. Now the questions: Are there possibilities to shrink the Python executable? Maybe to disable the interactive mode (starting Python programms on the command line). I looked for the configure options and tried some of them but it doesn't produce any change for my executable. I compile it with optimized options from gcc and it's already stripped.
Optimizing the size of embedded Python interpreter
1
0.197375
1
0
0
8,769
12,636,812
2012-09-28T09:00:00.000
0
0
0
0
0
python,django,dynatree
0
12,659,689
0
3
0
false
1
0
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()
3
1
0
0
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 will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..
Moving nodes from one tree to another with Dynatree
0
0
1
0
0
908
12,636,812
2012-09-28T09:00:00.000
1
0
0
0
0
python,django,dynatree
0
19,162,943
0
3
0
false
1
0
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 source node from the Source Tree var tmplNode = $("#dvAllLetterTemplates").dynatree("getTree").selectKey(arrKeys[i], false); if (tmplNode != null) { //Make a copy of the source node var ndCopy = tmplNode.toDict(false, null); //Add it to the parent node catNode.addChild(ndCopy); //Remove the source node from the source tree (to prevent duplicate copies tmplNode.remove(); //Refresh both trees $("#dvUserLetterTemplates").dynatree("getTree").redraw(); $("#dvAllLetterTemplates").dynatree("getTree").redraw(); } }
3
1
0
0
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 will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..
Moving nodes from one tree to another with Dynatree
0
0.066568
1
0
0
908
12,636,812
2012-09-28T09:00:00.000
2
0
0
0
0
python,django,dynatree
0
15,516,606
0
3
0
true
1
0
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.
3
1
0
0
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 will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..
Moving nodes from one tree to another with Dynatree
0
1.2
1
0
0
908
12,658,427
2012-09-30T03:39:00.000
3
0
0
0
0
python,django,installation
0
12,659,723
0
5
0
false
1
0
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 supported. Theoretically you can install Python and run Django from anywhere you have shell access and sufficient permissions, but you won't be able to actually serve your Django site as part of your shared hosting (i.e., on port 80 and responding to your selected hostname) because you don't have access to the webserver configuration. You will need either a VPS (GoDaddy offers them but it's not their core business; Linode and Rackspace are other options), or a shared host that specifically supports Django (e.g. Dreamhost), or an application host (Heroku or Google App Engine). I recommend Heroku personally, especially if you are not confident in setting up and maintaining your own webserver.
1
32
0
1
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?
Installing a django site on GoDaddy
0
0.119427
1
0
0
61,875
12,659,719
2012-09-30T08:08:00.000
4
0
0
0
0
python,windows,winapi,python-2.7,pywin32
0
12,659,846
0
1
0
true
0
1
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
1
0
0
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 are to be copied and also the path of Target window where paste is to be done.So I want to know what actually happens when someone presses Ctrl+C key in windows explorer
Windows:What actually happens when Ctrl+C is pressed in windows explorer
0
1.2
1
0
0
339
12,660,516
2012-09-30T10:24:00.000
2
0
0
0
1
pyramid,pickle,python-3.2
0
12,673,353
0
1
0
true
1
0
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
3
0
0
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 standard waitress server. Symptoms I was having some efficiency issues so used system monitor to try to see what was up and found that while pyramid is doing its processing and suchlike for the view I described my ram usage rose steadily. As the html form was displayed in my browser the ram usage leveled off but didn't fall. Reloading the view caused the ram usage to grow steadily from where it left off. If I keep doing this all my ram is used up and everything grinds to a halt. If I kill the server then the ram usage drops back down immediately. Question What's going on? It's obvious that memory isn't being released between view renderings, but why is this happening? And how can I make it stop? I even tried calling del on stuff before returning from the view and nothing changed.
Pyramid app not releasing memory between views
0
1.2
1
0
0
223
12,698,212
2012-10-02T20:57:00.000
1
0
0
1
0
python,eclipse,celery
0
19,998,790
0
5
0
false
1
0
I create a management command to test task.. find it easier than running it from shell..
1
29
0
0
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 "Debug As->Python Run" and specifying "celeryd -l info" as the argument. This starts MainThread, Mediator and three more threads visible from the Eclipse debugger. After that I return back to the PyDev view and start the main application by Right Click on the project and choosing Run As/PyDev:Django My issues is that once the task is submitted by the mytask.delay() it doesn't stop on the breakpoint. I put some traces withing the tasks code so I can see that it was executed in one of the worker threads. So, how to make the Eclipse debugger to stop on the breakpoint placed withing the task when it executed in the Celery workers thread?
How to debug Celery/Django tasks running locally in Eclipse
0
0.039979
1
0
0
23,443
12,699,132
2012-10-02T22:11:00.000
1
0
1
0
0
python
0
12,699,266
0
5
0
false
0
0
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.
1
1
0
0
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?
Finding the different combinations
0
0.039979
1
0
0
217
12,703,241
2012-10-03T06:48:00.000
1
0
1
0
0
python,file
0
12,703,403
0
3
0
false
0
0
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 will be different. i don't know how if garbage collector works in python the same as in java, but if it does, all the objects that are not pointed by any reference will be deleted from memory. not "immediately" but when garbage collector will run, and this is unpredictable. it may be now, and it may be in next few seconds.
1
1
0
0
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?
Open(file) - Does it stay open?
0
0.066568
1
0
0
472
12,707,239
2012-10-03T11:08:00.000
2
1
0
0
0
python,protocols,irc
0
12,721,513
0
1
0
true
0
0
Are you looking for /notice ? (see irchelp.org/irchelp/misc/ccosmos.html#Heading227)
1
0
0
0
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 in the docs. I don't need the full function, just the command keyword to invoke the action from the server (eg PRIVMSG). Thanks folks.
IRC msg to send to server to send a "whisper" message to a user in channel
0
1.2
1
0
1
2,449
12,711,511
2012-10-03T15:14:00.000
1
0
0
1
0
python,embed
0
12,862,310
0
1
0
true
0
0
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 continue. it seems to be working fine.
1
1
0
0
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 (pause) the calls bail out so the app event loop would continue. When the necessary data is present, i would like to restore the execution of the script, it is like the python call returns at that point. i'm running single threaded python. any ideas how can i do this, or something similar, where i'll have the app event loop run before python call exits?
suspend embedded python script execution
0
1.2
1
0
0
164
12,737,993
2012-10-05T00:39:00.000
0
0
1
0
0
python,image-processing
0
57,430,322
0
3
0
false
0
0
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 Components Labeling Object. 4) Once you have your objects identified, you can run the Marching squares algorithm over each object. MS consist in divide your image in n squares and then evaluating the value of all the vertex for a given square. MS will find the the border by analyzing each square and finding those in which the value of at least one of the vertex of a given square is 0 whereas the other vertex of such square are 1 --> The border/contour is contained in such square.
1
3
0
0
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 example, a doughnut with outer circle and inner circle, or a face with face outline and inner contour of organs. I know there is something called marching square, but not sure how to do it in python? Thank you.
Follow image contour using marching square in Python
0
0
1
0
0
3,955