Title
stringlengths 15
150
| A_Id
int64 2.98k
72.4M
| Users Score
int64 -17
470
| Q_Score
int64 0
5.69k
| ViewCount
int64 18
4.06M
| Database and SQL
int64 0
1
| Tags
stringlengths 6
105
| Answer
stringlengths 11
6.38k
| GUI and Desktop Applications
int64 0
1
| System Administration and DevOps
int64 1
1
| Networking and APIs
int64 0
1
| Other
int64 0
1
| CreationDate
stringlengths 23
23
| AnswerCount
int64 1
64
| Score
float64 -1
1.2
| is_accepted
bool 2
classes | Q_Id
int64 1.85k
44.1M
| Python Basics and Environment
int64 0
1
| Data Science and Machine Learning
int64 0
1
| Web Development
int64 0
1
| Available Count
int64 1
17
| Question
stringlengths 41
29k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ruby/python learning reference for Windows user
| 6,472,767
| 0
| 0
| 287
| 0
|
python,ruby,windows,windows-7
|
Practical Programming: An Introduction to Computer Science Using Python, I have read this but it might be too easy for people with some programming experience already
| 0
| 1
| 0
| 0
|
2011-06-24T19:13:00.000
| 4
| 0
| false
| 6,472,661
| 1
| 0
| 0
| 1
|
I am interested in learning python and ruby, but I use Windows 7. Most online articles I have seen out there are not really helpful to me since they are all explaining about python and ruby in UNIX environment.
I'd like to know if there are any good articles/books about Ruby/python programming languages that are more friendly to windows users that may be useful.
Thanks in advance. any recommendations would be appreciated.
|
Python eggs - sometimes inflated, sometimes not
| 6,488,633
| 0
| 1
| 133
| 0
|
python,egg
|
A package can specify itself using the zip_safe flag inside its setup.py file if it should be unarchived or not. In addition most installers like 'easy_install' provide options to control the unpacking explicitly (e.g. easy_install --zip-ok ...)...so it may depend on how the packages are installed under Fedora oder CentOS.
| 0
| 1
| 0
| 1
|
2011-06-26T20:39:00.000
| 1
| 1.2
| true
| 6,486,598
| 0
| 0
| 0
| 1
|
I'm running fedora 32 bit on one machine and have installed several eggs using easy_install.
I've installed the same eggs using easy_install on a 64-bit centos 5 machine. The site-packages directories are different - on my fedora machine, some of the eggs have been inflated so there are directories ending .egg-info as well as the main code directories. On Centos there are no .egg-info directories. Why is this?
Thanks
|
python reverse proxy spawning via cgi
| 6,531,642
| 2
| 1
| 488
| 0
|
python
|
You don't need to spawn another process, that would complicate things a lot. Here's how I would do it based on something similar in my current project :
Create a WSGI application, which can live behind a web server.
Create a request handler (or "view") that is accessible from any URL mapping as long as the user doesn't have a session ID cookie.
In the request handler, the user can choose the target application and with it, the hostname, port number, etc. This request handler creates a connection to the target application, for example using httplib and assigns a session ID to it. It sets the session ID cookie and redirects the user back to the same page.
Now when your user hits the application, you can use the already open http connection to redirect the query. Note that WSGI supports passing back an open file-like object as response, including those provided by httplib, for increased performance.
| 0
| 1
| 0
| 1
|
2011-06-27T05:10:00.000
| 1
| 0.379949
| false
| 6,488,806
| 0
| 0
| 1
| 1
|
I need to write a cgi page which will act like a reverse proxy between the user and another page (mbean). The issue is that each mbean uses different port and I do not know ahead of time which port user will want to hit.
Therefore want I need to do is following:
A) Give user a page which will allow him to choose which application he wants to hit
B) spawn a reverse proxy base on information above (which gives me port, server, etc..)
C) the user connects to the remote mbean page via the reverse proxy and therefore never "leaves" the original page.
The reason for C is that user does not have direct access to any of the internal apps only has access to initial port 80.
I looked at twisted and it appears to me like it can do the job. What I don't know is how to spawn twisted process from within cgi so that it can establish the connection and keep further connection within the reverse proxy framework.
BTW I am not married to twisted, if there is another tool that would do the job better, I am all ears. I can't do things like mod_proxy (for instance) since the wide range of ports would make configuration rather silly (at around 1000 different proxy settings).
|
How can I create a buffer which Python would not free?
| 6,497,052
| 3
| 2
| 1,077
| 0
|
python,c,buffer,ctypes,free
|
Try the following in the given order:
Try by all means to manage your memory in Python, for example using create_string_buffer(). If you can control the behaviour of the C function, modify it to not free() the buffer.
If the library function you call frees the buffer after using it, there must be some library function that allocates the buffer (or the library is broken).
Of course you could call malloc() via ctypes, but this would break all good practices on memory management. Use it as a last resort. Almost certainly, this will introduce hard to find bugs at some later time.
| 0
| 1
| 0
| 0
|
2011-06-27T18:02:00.000
| 1
| 1.2
| true
| 6,496,981
| 0
| 0
| 0
| 1
|
I need to call a function in a C library from python, which would free() the parameter.
So I tried create_string_buffer(), but it seems like that this buffer would be freed by Python later, and this would make the buffer be freed twice.
I read on the web that Python would refcount the buffers, and free them when there is no reference. So how can I create a buffer which python would not care about it afterwards? Thanks.
example:
I load the dll with: lib = cdll.LoadLibrary("libxxx.so") and then call the function with: path = create_string_buffer(topdir) and lib.load(path). However, the load function in the libxxx.so would free its argument. And later "path" would be freed by Python, so it is freed twice
|
Checking status of Task Queue in Google App Engine
| 9,361,730
| 2
| 9
| 4,031
| 0
|
python,google-app-engine,queue,task,task-queue
|
You can use memcache. Use a unique key specific to this task group. Set a count when you kick off your tasks, and have each task atomically decrement it. When the value is 0, your tasks are complete. The task that finds this value to be 0 can call your callback.
| 0
| 1
| 0
| 0
|
2011-06-28T02:16:00.000
| 3
| 0.132549
| false
| 6,500,878
| 0
| 0
| 1
| 1
|
I'm putting several tasks into a task queue and would like to know when the specific tasks are done. I haven't found anything in the API about call backs, or checking the status of a task, so I thought I'd see what other people do, or if there's a work around (or official) way to check. I don't care about individual tasks, if it helps, I'm putting 6 different tasks in, and want to know when all 6 are complete.
Thanks!
|
Upgrading Python to 2.7 on OSX
| 48,994,064
| 0
| 14
| 60,074
| 0
|
python,macos
|
python 2.7 is bundled with OS X Mountain Lion (10.8) and onwards, so it is likely that most Macs running today (2018) will have python 2.7 without any further effort.
| 0
| 1
| 0
| 0
|
2011-06-29T05:37:00.000
| 5
| 0
| false
| 6,516,179
| 1
| 0
| 0
| 1
|
How can I upgrade Python from 2.6 to 2.7 on osx ?
|
How can one identify children of a child process?
| 6,524,149
| 0
| 1
| 369
| 0
|
c++,python,postgresql,process,cross-platform
|
The C++ standard does not know of multiprocess systems. There is, therefore, no API for interacting with processes. (After all, how would the standard mandate a multiprocess system on an 8 bit microcontroller?)
Moreover, some platforms (e.g. the Win32 Subsystem on Windows NT) do not keep track of process parent child relationships. (NT does under the hood but you'd have to call undocumented APIs to get at the information)
I'm fairly certain POSIX does define APIs like this, but I have not used them myself.
| 0
| 1
| 0
| 0
|
2011-06-29T16:18:00.000
| 2
| 0
| false
| 6,523,883
| 0
| 0
| 0
| 1
|
I have a long-running Python program that starts and stops a Postgres server as part of its operation. I stop the server by using subprocess to spawn pg_ctl -m fast. As a fall-back, I check the return code and, if it failed, I then run pg_ctl -m immediate.
The problem is that sometimes both fail. I haven't been able to reproduce this myself, but it happens with some frequency for users of my program. I log stdout/stderr from the pg_ctl calls, but don't get any useful info there. As far as I can tell, either the master process or its children have stopped responding to SIGQUIT, and the only way to terminate them is with SIGKILL, which pg_ctl does not use.
I've basically exhausted ideas on the Postgres side. I'm using Postgres 8.3, so I'm sure upgrading to a more recent version would resolve this, but unfortunately that is not an option for me. The only solution I can come up with is to kill the children manually. But I don't know how to distinguish between the children spawned by my pg_ctl start and other postgres processes that might be running on the machine.
Is there a way to identify a process as a child of another process that I spawned? A cross-platform method of doing this from Python would be ideal, but I'm willing to write a C extension if there exist APIs on Windows/Linux/UNIX to do this.
|
Installing dependencies for Python program
| 6,524,127
| 1
| 1
| 1,635
| 0
|
python,installation
|
You specify all dependent packages in the 'install_requires' option within your setup.py - that's it.
If this is not sufficient or good enough (for whatever reason): look into zc.buildout giving your more options installing and configuring external dependencies.
| 0
| 1
| 0
| 1
|
2011-06-29T16:33:00.000
| 3
| 0.066568
| false
| 6,524,104
| 1
| 0
| 0
| 1
|
I have created a Python-based GUI application which has certain dependencies such as the "request" and "psycopg2" modules among others.
I want to create a setup script that will install all such dependencies when run, so that a user can run the GUI application without having any missing package errors.
I did try looking up the distutils module, but am not able to fully understand its usage.
|
Python, sigaction(2) available?
| 6,534,882
| 7
| 4
| 2,124
| 0
|
python,linux,posix,signals
|
There is a standard module called, unsurprisingly, signal. This seems to carry out the functionality of sigaction(2). However I'm guessing that what you really need is the siginfo_t struct, which gives the PID of the source of the signal, which is not part of the module at the moment (possibly because it is not implemented on all UNIXs).
The only alternative I can suggest is to use ctypes.
| 0
| 1
| 0
| 1
|
2011-06-30T08:43:00.000
| 1
| 1.2
| true
| 6,532,213
| 0
| 0
| 0
| 1
|
Is there an equivalent to the POSIX sigaction available through Python? I realize python has traditional support for signals, but I need sigaction.
I'm trying to identify the pid of a process that is the source of a signal being issued. From what I can see from the documentation, there isn't a way to do this.
I'm only concerned with functionality on Linux.
|
Python's Fabric to use rsync locally, is it possible?
| 6,605,088
| 4
| 1
| 1,806
| 0
|
python,fabric
|
you can just local() out and use rsync any way you want to.
| 0
| 1
| 0
| 1
|
2011-06-30T15:04:00.000
| 1
| 1.2
| true
| 6,536,862
| 0
| 0
| 0
| 1
|
Currently Fabric's 'rsync_projecct' requires a user and a host parameter to be specified. I'having a lot of issues copying user@127.0.0.1 because it is still asking me for the password for rsync. I've spent hours on this and am wondering if there is just a way to use the rsync [src] [dest] without having to specify a [user] and [host]? Or do you guys recommend something better?
The reason I like rsync over anything else is because I already have the rsync files/folders/excludes setup for that specific command.
Then again, I could just write my own rsync command right?
Thanks.
|
Distributing Real-Time Market Data Using ZeroMQ / NFS?
| 6,550,992
| 1
| 1
| 1,280
| 0
|
python,linux,zeromq
|
I'm pretty sure sending with ZeroMQ will be substantially quicker than saving and loading files.
There are other ways to send information over the network, such as raw sockets (lower level), AMQP implementations like RabbitMQ (more structured/complicated), HTTP requests/replies, and so on. ZeroMQ is a pretty good option, but it probably depends on your situation.
You could also look at frameworks for distributed computing, such as that in IPython.
| 0
| 1
| 0
| 0
|
2011-07-01T14:44:00.000
| 3
| 0.066568
| false
| 6,549,488
| 0
| 1
| 0
| 3
|
Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to the other 50 machines?
I am looking for a solution that would work on linux, using python as the programming language. Some ideas that I had are:
(1) Send it to the other machines using python's ZeroMQ module
(2) Save the data to a shared folder and have the 50 machines read it using NFS
Any other ideas?
|
Distributing Real-Time Market Data Using ZeroMQ / NFS?
| 6,552,072
| 1
| 1
| 1,280
| 0
|
python,linux,zeromq
|
I would go with zeromq with pub/sub sockets..
in your 2 option, your "clients" will have to refresh in order to get your file modifications.. like polling.. if you have some write error, you will have to handle this by hand, which won't be easy as well..
zeromq is simple, reliable and powerful.. i think that perfectly fit your case..
| 0
| 1
| 0
| 0
|
2011-07-01T14:44:00.000
| 3
| 1.2
| true
| 6,549,488
| 0
| 1
| 0
| 3
|
Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to the other 50 machines?
I am looking for a solution that would work on linux, using python as the programming language. Some ideas that I had are:
(1) Send it to the other machines using python's ZeroMQ module
(2) Save the data to a shared folder and have the 50 machines read it using NFS
Any other ideas?
|
Distributing Real-Time Market Data Using ZeroMQ / NFS?
| 6,643,883
| 0
| 1
| 1,280
| 0
|
python,linux,zeromq
|
Definatly do NOT use the file system. ZeroMQ is a great solution wiht bindings in Py. I have some examples here: www.coastrd.com. Contact me if you need more help.
| 0
| 1
| 0
| 0
|
2011-07-01T14:44:00.000
| 3
| 0
| false
| 6,549,488
| 0
| 1
| 0
| 3
|
Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to the other 50 machines?
I am looking for a solution that would work on linux, using python as the programming language. Some ideas that I had are:
(1) Send it to the other machines using python's ZeroMQ module
(2) Save the data to a shared folder and have the 50 machines read it using NFS
Any other ideas?
|
how to kill process and child processes from python?
| 6,549,740
| 35
| 27
| 63,568
| 0
|
python
|
When you pass a negative PID to kill, it actually sends the signal to the process group by that (absolute) number. You do the equivalent with os.killpg() in Python.
| 0
| 1
| 0
| 0
|
2011-07-01T15:00:00.000
| 7
| 1.2
| true
| 6,549,669
| 0
| 0
| 0
| 1
|
for example from bash:
kill -9 -PID
os.kill(pid, signal.SIGKILL) kill only parent process.
|
How do you see the entire command history in interactive Python?
| 54,629,284
| 10
| 195
| 137,835
| 0
|
python,macos
|
In IPython %history -g should give you the entire command history. The default configuration also saves your history into a file named .python_history in your user directory.
| 0
| 1
| 0
| 0
|
2011-07-02T18:15:00.000
| 10
| 1
| false
| 6,558,765
| 1
| 0
| 0
| 2
|
I'm working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow keys. But is there an option like the --history option in bash shell, which shows you all the commands you've entered so far?
|
How do you see the entire command history in interactive Python?
| 39,063,906
| 62
| 195
| 137,835
| 0
|
python,macos
|
With python 3 interpreter the history is written to
~/.python_history
| 0
| 1
| 0
| 0
|
2011-07-02T18:15:00.000
| 10
| 1
| false
| 6,558,765
| 1
| 0
| 0
| 2
|
I'm working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow keys. But is there an option like the --history option in bash shell, which shows you all the commands you've entered so far?
|
Attachments in mails sent via App Engine not readable on every mail client/ device
| 6,602,467
| 1
| 2
| 391
| 0
|
python,google-app-engine,blackberry,attachment,vcf-vcard
|
Obviously as I mentioned on my comment above:
- it has nothing to do with Google App Engine
- some devices are just not able to read vcards in format 3.0
But I haven't found a good parser/ converter so far (from vcard 3.0 to vcard 2.1 in python) so if anyone knows one, please let me know. Otherwise, I'll have to build it myself...
| 0
| 1
| 0
| 0
|
2011-07-03T21:41:00.000
| 2
| 1.2
| true
| 6,565,728
| 0
| 0
| 1
| 1
|
I'm using App Engine with Python. My application basically sends vcards (.vcf) by email when users request it.
Indeed, files with .vcf extension are supported by App Engine. I use the mail API to send them as attachment. Before, I stored them as db.Blob().
Problem:
Most of the time, Blackberry users cannot read the vcards sent as attachments by my application. At the bottom of the mail, it displays: "application/X-rimdeviceAddress Book:" and when you click on the file, it says: "This type of attachment cannot be opened on your device".
Exception:
A blackberry that receives a vcard serialized from a Blackberry can open it.
Fortunately, it perfectly works on the iPhone and (most of the time) on Android phones.
As vcards serialized from a Blackberry can be correctly opened by Blackberry users, I guess I'm doing something wrong during the storage and/ or the mail dispatch. Or maybe, the MIME type is not correctly set by App Engine methods...
Can someone give a few leads to investigate this pretty annoying problem (I was expecting a pretty big user base on Blackberry phones...)?
|
How to periodically check for the current date from within a program?
| 6,571,157
| 1
| 3
| 328
| 0
|
python,perl,date,calendar
|
Did you think about scheduling the invoke of your script?
For me, the best approach is this:
1.Have two options to run the script:
run_script
run_script --update
2.Schedule the update run in some task scheduler (for example Cron) to be executed daily.
3.When you would want to check the image for current day, simply run the script without update option.
If you would like me to extend any part of these, simply ask about it.
| 0
| 1
| 0
| 0
|
2011-07-04T11:33:00.000
| 2
| 0.099668
| false
| 6,570,892
| 1
| 0
| 0
| 1
|
I would like to write a tiny calendar-like application for someone as a birthday present (to be run on Ubuntu). All it should do is display a separate picture each day, so whenever it's invoked it should check the date and select the appropriate picture from the collection I would provide, but also, in case it just keeps running, it should switch to the next picture when the next day begins.
The date-checking on invocation isn't the problem; my question pertains to the second case: how can I have the program notice the beginning of the next day? My clumsy approach would be to make it check the current date at regular intervals and let it change the displayed picture once there was a change in date, but that strikes me as very roundabout and not particularly elegant.
In case any of you have got some idea of how I could accomplish this, please don't hesitate to reply. I would aim to write the application in either Perl or Python, so suggestions concerning those two languages would be most welcome, but any other suggestions would be appreciated as well.
Thanks a lot for your time!
|
multiprocessing import modules on mac
| 6,580,433
| 1
| 2
| 848
| 0
|
python,macos,multiprocessing
|
The problem is that multiprocessing uses os.fork on unix. So the sub-process becomes a copy of the main process. Dont know what's going on with Fedora, but it shouldn't work on linux either.
There doesn't seem to be any easy way to get around it.
| 0
| 1
| 0
| 0
|
2011-07-04T15:52:00.000
| 2
| 1.2
| true
| 6,573,646
| 1
| 0
| 0
| 1
|
modules exists inside new processes before import, using python-multiprocessing on osx.
Here's an example:
import multiprocessing
import sys
import os
print 'importing module'
def main():
import uuid
print 'setting var'
uuid.some_variable = True
def process(name):
print 'uuid module loaded:', 'uuid' in sys.modules
print 'process pid', os.getpid()
import uuid
var = uuid.some_variable
print 'var exists on mac', var
if __name__ == '__main__':
print 'main pid', os.getpid()
main()
p = multiprocessing.Process(target=process, args=('test',))
p.start()
p.join()
output on windows/linux is what I would expect. The script import twice, uuid.some_variable does not exists, and uuid is not loaded before import:
importing module
main pid 4352
setting var
importing module
uuid module loaded: False
process pid 4988
AttributeError: 'module' object has no attribute 'some_variable'
However on osx, the script will only import once, uuid is loaded before import, and uuid.some_variable exists in the new process:
importing module
main pid 4399
setting var
uuid module loaded: True
process pid 4400
var exists on mac True
Somehow, the uuid module from the main process gets into the sub-process, without importing it.
Am I missing something, is this a bug, or does mac have a good reason to do this?
How did the module even get into the subprocess?
|
Is it ok to spawn threads in a wsgi-application?
| 6,587,335
| 13
| 14
| 3,562
| 0
|
python,django,multithreading,wsgi,flask
|
WSGI does not specify the lifetime of an application process (as WSGI application is a Python callable object). You can run it in a way that is completely independent of the web server, in which case, only you control the lifetime.
There is also nothing in the WSGI that would prohibit you from spawning threads, or processes, or doing whatever the hell you want.
| 0
| 1
| 0
| 0
|
2011-07-05T07:53:00.000
| 2
| 1
| false
| 6,579,467
| 0
| 0
| 1
| 1
|
To achieve something similar to google app engines 'deferred calls' (i.e., the request is handled, and afterwards the deferred task is handled), i experimented a little and came up with the solution to spawn a thread in which my deferred call is handled.
I am now trying to determine if this is an acceptable way.
Is it possible (according to the WSGI specification) that the process is terminated by the webserver after the actual request is handled, but before all threads run out?
(if there's a better way, that would be also fine)
|
Is it possible to fetch a google profile nickname and use in app engine apps?
| 6,590,472
| 0
| 0
| 246
| 0
|
python,google-app-engine,login
|
No - the User API only provides the user's email address, an app-specific unique ID, and their nickname (Which, as you observe, is derived from the email address).
| 0
| 1
| 0
| 0
|
2011-07-05T16:51:00.000
| 2
| 0
| false
| 6,586,106
| 0
| 0
| 1
| 1
|
Currently the method nickname() in the Users class seem to return either the initial way you entered your username when you signed up for gmail (IE. "UseRnAme" if thats how you chose to type it, rather then "username" as it would show up when you log in on a google service) or the entire email if you signed up for a google account with another email provider.
Google profiles have a field called Nickname though, is it possible to use that inside an app engine app in any way?
|
How to build and run emesene on OS X using Git
| 6,587,062
| 2
| 0
| 73
| 0
|
python,git
|
Have you tried running python setup.py install in the emesene directory?
| 0
| 1
| 0
| 1
|
2011-07-05T17:53:00.000
| 1
| 1.2
| true
| 6,586,793
| 1
| 0
| 0
| 1
|
Anyone knows how to build and run emesene - the chat client in Python - on OS X once you get the code from GitHub?
I have searched online and I cannot find a source that is working. I did find some documents on sidhosting website. But that did not work for me completely. Hence I need help here.
Thanks
Sumod
|
Get the directory of a Shortcut calling a Python Script
| 6,589,637
| 1
| 5
| 1,900
| 0
|
python,directory
|
In general you cannot obtain this information. You should use argv to switch behaviour of your script.
| 0
| 1
| 0
| 0
|
2011-07-05T22:19:00.000
| 3
| 0.066568
| false
| 6,589,499
| 1
| 0
| 0
| 2
|
How does one acquire the directory of the Windows Shortcut calling a python script. I'd like to have multiple shortcuts in various places pointing to one script that I could edit if I wanted, but where the directory from which the script is called is accessible. Is this possible?
This script would likely then be compiled with py2exe or something, so if it is something that isn't possibly until THAT stage, I could go with that. Thanks!
|
Get the directory of a Shortcut calling a Python Script
| 6,589,628
| 5
| 5
| 1,900
| 0
|
python,directory
|
The easiest solution is to just use a batch script instead of a shortcut.
All it needs is python C:\path\to\script\script.py, and the script will have the correct CWD.
The default when creating a shortcut on windows is for the Start in: property to be set to the folder the linked file resides in.
The script has no knowledge of the fact that it was called from a shortcut, let alone where that shortcut resides.
You can change the Start in: property of the shortcut to the path of the folder the shortcut resides in.
Then you can use os.getcwd() to get that path.
Unfortunately setting Start in: to . doesn't work.
| 0
| 1
| 0
| 0
|
2011-07-05T22:19:00.000
| 3
| 1.2
| true
| 6,589,499
| 1
| 0
| 0
| 2
|
How does one acquire the directory of the Windows Shortcut calling a python script. I'd like to have multiple shortcuts in various places pointing to one script that I could edit if I wanted, but where the directory from which the script is called is accessible. Is this possible?
This script would likely then be compiled with py2exe or something, so if it is something that isn't possibly until THAT stage, I could go with that. Thanks!
|
Mpdboot: Deprecation Warning
| 6,590,376
| 0
| 0
| 2,152
| 0
|
python,mpi,mpich,mpiexec
|
Is mpdboot compatible with such a version of python? That's downright ancient, I didn't know there was even any distribution left that still shipped 2.3. Have you tried with 2.7?
| 0
| 1
| 0
| 1
|
2011-07-06T00:24:00.000
| 2
| 0
| false
| 6,590,343
| 0
| 0
| 0
| 1
|
I am trying to use the mpdboot command to start 4 processors on which to run my MPI program. I created a mpd.hosts file with 4 nodes (75, 77, 79 and 80). Each of them run python 2.3.4. I also modified the bashrc and cshrc files to ensure that the variables contain the path to the directory of the compiler libraries. I also set up the mpd.conf file and checked that it has rw (600) permissions.
I have copied below the output screen when I run mpdboot
[n@heart]$ mpdboot -n 4 -r ssh
:38: Deprecation Warning: The popen2 module is deprecated. Use the subprocess module.
n@75's password:xxx
n@77's password:xxx
n@79's password:xxx
n@80's password:xxx
mpdboot_heart.int(err_exit 526): mpd failed to start correctly on heart.int
reason: 0: invalid port from mpd /opt/intel/mpi/2.0/bin/mpd.py:85: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Killed
PART 2:
I also logged into one of the nodes and tried running mpdboot. Here is the output by doing that
[n@79 ~]$ mpdboot -n 4 -r ssh
n@75's password:xxx
n@77's password:xxx
n@79's password:xxx
n@80's password:xxx
mpdboot_79_0 (mpdboot 499): problem has been detected during mpd(boot) startup at 1 75; output:
Permission denied, please try again.
n@75's password: Permission denied, please try again.
n@77's password: mpdboot_79_0 (mpdboot 515): problem has been detected during mpd(boot) startup at 2 77; output:
Permission denied, please try again.
Permission denied (publickey,gssapi-with-mic,password).
n@77's password: Permission denied, please try again.
Permission denied (publickey,gssapi-with-mic,password).
How should I proceed on this matter?
|
Detecting graceful shut downs of sockets in python
| 6,602,114
| 0
| 2
| 481
| 0
|
python,sockets,serversocket
|
It turns out that all I needed to do was to set the socket timeout to something lower, like 1 minute, the recv call will throw and exception after 1 minute.
| 0
| 1
| 1
| 0
|
2011-07-06T00:33:00.000
| 2
| 1.2
| true
| 6,590,400
| 0
| 0
| 0
| 2
|
I'm trying to determine if a server socket was shut down gracefully or not in python.
The program received files and if some error occurs during the send the file should be removed.
I know your first suggestion will be to let the client send either the length of the file or some terminating data to let the server know that the file transfer is complete.
Sadly, I cannot change the client, it just dumps the file over raw tcp and there is nothing I can do about it. So please, no "but if you could change it" or "your protocol is flawed", I did not write the protocol and I will have to deal with it.
The script should work on both OSX and linux so epoll is out.
Any suggestions?
I can add that I don't care what error occurs, just that any error did.
|
Detecting graceful shut downs of sockets in python
| 6,590,500
| 1
| 2
| 481
| 0
|
python,sockets,serversocket
|
If the other end has finished sending data, they should shutdown (2) the socket for writing. Then in your multiplexing loop you would be able to check if the socket has been shutdown for writing or has just be closed (writing & reading) by the remote end. This is a graceful shutdown and you can use select/poll/kqueue or whatever.
If the client doesn't do that, doesn't send terminating character and doesn't send the lenght or a checksum it looks hard.
You should drop more detail about the protocol, does the client opens a TCP socket for the sole purpose of sending a file ? Does it close the socket if the transfer is complete ?
In the worst case scenario you would have to check the integrity of the file, if you know its format you can try to check it during run time or have a cron tab do the cleaning. If you cannot, well it will be hard to find a solution. Good luck...
| 0
| 1
| 1
| 0
|
2011-07-06T00:33:00.000
| 2
| 0.099668
| false
| 6,590,400
| 0
| 0
| 0
| 2
|
I'm trying to determine if a server socket was shut down gracefully or not in python.
The program received files and if some error occurs during the send the file should be removed.
I know your first suggestion will be to let the client send either the length of the file or some terminating data to let the server know that the file transfer is complete.
Sadly, I cannot change the client, it just dumps the file over raw tcp and there is nothing I can do about it. So please, no "but if you could change it" or "your protocol is flawed", I did not write the protocol and I will have to deal with it.
The script should work on both OSX and linux so epoll is out.
Any suggestions?
I can add that I don't care what error occurs, just that any error did.
|
How do you specify the shebang line of a command script created by setuptools
| 6,599,711
| 1
| 4
| 4,584
| 0
|
python,packaging,setuptools
|
Run the script with /opt/bin/python script.py, or
edit the first line to read #!/opt/bin/python, or
put /opt/bin in your path before /usr/bin.
| 0
| 1
| 0
| 0
|
2011-07-06T16:18:00.000
| 3
| 0.066568
| false
| 6,599,686
| 1
| 0
| 0
| 1
|
I have created a package that I will be distributing throughout the company that replaces a legacy bash script with the same name. It is referenced many places so it needs to execute like the current script does. This has worked fine until I encountered some servers that do not have a current version of Python as the default Python (aka CentOS).
Is there a way to specify in the setup.py what shebang line is created at the top of the script file? i.e. I need #!/opt/bin/python rather than #!/usr/bin/env python.
|
Calling python script from batch file opens second console
| 6,602,895
| 0
| 2
| 2,124
| 0
|
python,batch-file,command-prompt
|
Have you tried changing the extension of the python script to .pyw, or just invoke it with pythonw.exe?
| 0
| 1
| 0
| 0
|
2011-07-06T20:12:00.000
| 3
| 0
| false
| 6,602,341
| 1
| 0
| 0
| 3
|
I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?
Thanks.
|
Calling python script from batch file opens second console
| 6,603,729
| 0
| 2
| 2,124
| 0
|
python,batch-file,command-prompt
|
It could be that the .py filetype is associated to pythonw.exe, therefore causing it to open in a new process. Find any .py file, right click it, select properties, and check to see under "Opens with:" what the default interpreter is.
| 0
| 1
| 0
| 0
|
2011-07-06T20:12:00.000
| 3
| 0
| false
| 6,602,341
| 1
| 0
| 0
| 3
|
I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?
Thanks.
|
Calling python script from batch file opens second console
| 6,612,528
| 0
| 2
| 2,124
| 0
|
python,batch-file,command-prompt
|
Ok, so I decided to reinstall python. If I uninstall and reinstall (I was using the windows installer) in the default location, it seems to have no effect. I cleaned out the registry and reinstalled. Still no different. However, if I install python in a different location (other than the default) it seems to run fine. Something is obviously corrupt somewhere, but I don't know where. So I am going to just reinstall all of my other modules in a different location and go from there.
Thank you all for your responses.
| 0
| 1
| 0
| 0
|
2011-07-06T20:12:00.000
| 3
| 0
| false
| 6,602,341
| 1
| 0
| 0
| 3
|
I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?
Thanks.
|
How to recognise a particular user in a long multi-user internet chat log?
| 6,602,759
| 0
| 3
| 196
| 0
|
python,nlp,machine-learning,nltk,opennlp
|
One possible solution would be to take the Naive Bayes Classifier 'spam filter' idea and see which words different nicks tend to use. Classify messages according to which user uses words 'most like' the ones sent from an unknown user. The downfall of this would be that if they were using new words you hadn't seen before (which is very likely), then you'd need to understand higher-level context information.
| 0
| 1
| 0
| 0
|
2011-07-06T20:39:00.000
| 2
| 0
| false
| 6,602,664
| 0
| 0
| 0
| 1
|
Here is an online programming contest we are planning to have.
What could be possible approaches to solving the same?
From a random IRC (Internet Relay Chat) log, a small percentage of the user nicknames will be randomly deleted. The participant’s code must be able to fill in the missing user nicks. In other words, this event requires you to come up with an intelligent program that can figure out “who could have said what”.
It may be assumed that all communication will be in modern English, with or without punctuation.
For example -
Original Chat:
...
<user1>: Hey!
<user2>: Hello! Where are you from, user1?
<user3>: Can anybody help me out with Gnome installation?
<user1>: India. user3, do you have the X Windows System installed?
<user2>: Cool. What is Gnome, user3?
<user3>: I don’t know. How do I check?
<user3>: Its a desktop environment, user2.
<user2>: Oh yeah! Just googled.
<user1>: Type “startx” on the command line. Login as root and type “apt-get install gnome”.
<user3>: Thanks!
<user5>: I’m root, obey me!
<user2>: Huh?!
<user3>: user2, you better start using Linux!
...
The following only will be given to the participant.
Chat log with some nicks deleted:
..
: Hey!
: Hello! Where are you from, user1?
: Can anybody help me out with Gnome installation?
: India. user3, do you have the X Windows System installed?
: Cool. What is Gnome, user3?
<%%%>: I don’t know. How do I check?
<%%%>: Its a desktop environment, user2.
: Oh yeah! Just googled.
: Type “startx” on the command line. Login as root and type “apt-get install gnome”.
: Thanks!
<%%%>: I’m root, obey me!
<%%%>: Huh?!
: user2, you better start using Linux!
...
The participant’s code will have the task of replacing "<%%%>s" with the appropriate user nicks. In ambiguous cases, like the random comment by in the above example (which could have been said by any other user too!), the code should indicate the same.
|
FFmpeg VS PyFFmpeg performance wise?
| 6,603,847
| 5
| 0
| 774
| 0
|
python,ffmpeg,video-encoding
|
Considering that pyFFmpeg is just a wrapper over the libraries, I'd say you shouldn't have any negligible performance difference between the 2, since they use the same libraries at the core.
| 0
| 1
| 0
| 1
|
2011-07-06T22:28:00.000
| 1
| 1.2
| true
| 6,603,810
| 0
| 0
| 0
| 1
|
Lets say for batch processing of over 10000 videos, is there any thing to be gained from using FFmpeg rather than the pyFFmpeg?
|
virtualenv command not found after installed with MacPorts
| 6,619,321
| 1
| 6
| 10,031
| 0
|
python,virtualenv,macports
|
You need to make sure virtualenv is in your PATH, although it should be if it was installed correctly.
| 0
| 1
| 0
| 0
|
2011-07-08T02:21:00.000
| 5
| 1.2
| true
| 6,619,307
| 1
| 0
| 0
| 2
|
I have python 2.7 installed via mac ports on a mac. I installed virtualenv via macports (py27-virtualenv @1.6.1_0 (active). When issue the command: virtualenv demo_venv --no-site-packages, I get this error: -bash: virtualenv:command not found. It's not picking virtualenv up @ all, so do I need to symlink it to my python27 location?
|
virtualenv command not found after installed with MacPorts
| 7,164,666
| 4
| 6
| 10,031
| 0
|
python,virtualenv,macports
|
The command is virtualenv-2.7, not just virtualenv.
If you look at the package contents, you can see that no executable named virtualenv is installed.
| 0
| 1
| 0
| 0
|
2011-07-08T02:21:00.000
| 5
| 0.158649
| false
| 6,619,307
| 1
| 0
| 0
| 2
|
I have python 2.7 installed via mac ports on a mac. I installed virtualenv via macports (py27-virtualenv @1.6.1_0 (active). When issue the command: virtualenv demo_venv --no-site-packages, I get this error: -bash: virtualenv:command not found. It's not picking virtualenv up @ all, so do I need to symlink it to my python27 location?
|
Python-memcache connection timeout
| 6,674,214
| 0
| 1
| 1,372
| 0
|
python,timeout,memcached
|
After adjusting time out, also adjust number of retries per server before purging it from the pool.
| 0
| 1
| 0
| 0
|
2011-07-08T07:12:00.000
| 1
| 0
| false
| 6,621,127
| 0
| 0
| 0
| 1
|
How do I reduce the connection timeout for python-memcache?
When a machine in my cluster goes down, the healthy machines hang for too long trying to connect to it.
Is settimeout the only way?
|
Using python to write a daemon instead of C++
| 6,622,182
| 1
| 0
| 453
| 0
|
python,linux,daemon
|
Use the right tool for the right job. If you want a process that keeps on running for a long time you will want a proof of some of it's correctness (not a complete one, but at least something). This proof is given to you by the compiler or interpreter accepting the language. It depends a lot on the language, what kind of things are proven about your program. For python you get a proof of syntactic correctness, that is all. If you use C++ existence of all methods and some type soundness will also be proven. This is much better for long running processes, such as daemon. There are languages, where you can use the compiler to prove even more, but this is often not as simple.
Don't worry too much about the memory leaks. As has been pointed out in the comments, if you use modern C++ memory leaks or memory corruption are not an issue anymore and speed will be much higher, than if a garbage collector is present. Use C++ or C++0x but not C/C++, and all will be fine.
| 0
| 1
| 0
| 1
|
2011-07-08T07:48:00.000
| 1
| 1.2
| true
| 6,621,501
| 0
| 0
| 0
| 1
|
I am about to start into a daemon project with a friend, he will do the design and I will do the coding
I am confused between Python and C++
I know C++, but I need to learn Python if I will go with it
The daemon I am about to write will be more than 1 daemon actually, each one is responsible for a function, such as accepting SSL connections from network, stream audio and video, sending files and data and more network operations, I like going with C++ but I am afraid from the time I'll lose fixing the memory leaks that will occur (for sure), but also I am afraid from Python because I don't know it and I don't know if it can do the job for me or not
Any suggestions?
|
Call Python from .NET
| 6,624,517
| 3
| 18
| 29,199
| 0
|
c#,python,.net,python.net
|
It works, but I don't really like this solution, I'd like to improve it to a better one.
No, AFAIK there isn't a better solution, especially if IronPython is a no-no for you. So you could still keep this as a temporary workaround while waiting for the script to be migrated to .NET or until you find that someone already wrote a library on .NET that provides you with similar functionality.
| 0
| 1
| 0
| 0
|
2011-07-08T12:35:00.000
| 6
| 1.2
| true
| 6,624,503
| 1
| 0
| 0
| 1
|
I have some code written in Python which can not be transferred to a .NET language. I need to call one of these functions from my .NET WinForms application.
Now, I do it by starting the Python script as a separate process and pass parameters to it as command line arguments. It works, but I don't really like this solution. I'd like to improve it to a better one.
Is there any better way to call a function of a .py script from a .NET application? What is the best way to do it?
Note: IronPython is NOT an option for this Python script
|
python 3.2 installed, but MAC didn't recognize it
| 14,525,211
| 0
| 3
| 6,871
| 0
|
python
|
trying to fix wing myself, but if you want to just execute it via commandline...
in terminal:
python3.2 ./filename.py
enjoy
| 0
| 1
| 0
| 0
|
2011-07-08T17:38:00.000
| 4
| 0
| false
| 6,628,225
| 0
| 0
| 0
| 4
|
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
|
python 3.2 installed, but MAC didn't recognize it
| 6,628,247
| 1
| 3
| 6,871
| 0
|
python
|
Is python3.2 in your PATH? Try typing "python3.2" at the command line and see if that works. Where is python3.2 located? It's probably /usr/bin/python3.2 Try using that in WingIDE and see if that works.
| 0
| 1
| 0
| 0
|
2011-07-08T17:38:00.000
| 4
| 0.049958
| false
| 6,628,225
| 0
| 0
| 0
| 4
|
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
|
python 3.2 installed, but MAC didn't recognize it
| 6,631,758
| 0
| 3
| 6,871
| 0
|
python
|
This may depend on the version of OSX you are running. I did a custom install of python 2.7 on my machine running 10.6.7 and had to modify ~/.bash_profile with the following line:
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
You may want to check the directory /Library/Frameworks/Python.framework/Versions and see what the full path is to your 3.2 install. You could then modify the PATH variable in your ~/.bash_profile like this:
PATH="/Library/Frameworks/Python.framework/Versions/YOUR_VERSION_NUM/bin:${PATH}"
| 0
| 1
| 0
| 0
|
2011-07-08T17:38:00.000
| 4
| 0
| false
| 6,628,225
| 0
| 0
| 0
| 4
|
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
|
python 3.2 installed, but MAC didn't recognize it
| 36,561,053
| 0
| 3
| 6,871
| 0
|
python
|
The reason is because the "python" shortcut doesn't exist in "/Library/Frameworks/Python.framework/Versions/3.4/bin", which is the newly created binary location.
Create a soft link to "python" as a work around.
"ln -s python python3.4".
Also, make sure that your .bash_profile has an entry for /Library/Frameworks/Python.framework/Versions/3.4/bin directory.
Verify with "Python -V"
| 0
| 1
| 0
| 0
|
2011-07-08T17:38:00.000
| 4
| 0
| false
| 6,628,225
| 0
| 0
| 0
| 4
|
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
|
Running a Disco map-reduce job on data stored in Discodex
| 6,628,861
| 0
| 1
| 567
| 0
|
python,mapreduce,disco
|
Never mind, it appears that what I'm doing isn't really meant to be done. It might be possible, but it would be far better to merely use semantic DDFS tags to refer to blobs of data.
The correct use case for Discodex is to store indexes constructed by a Disco map-reduce program that does not need be the input of another map-reduce program.
| 0
| 1
| 0
| 0
|
2011-07-08T18:05:00.000
| 2
| 1.2
| true
| 6,628,506
| 0
| 0
| 0
| 1
|
I have a large amount of static data that needs to offer random access. Since, I'm using Disco to digest it, I'm using the very impressive looking Discodex (key, value) store on top of the Disco Distributed File System. However, Disco's documentation is rather sparse, so I can't figure out how to use my Discodex indices as an input into a Disco job.
Is this even possible? If so, how do I do this?
Alternatively, I am thinking about this incorrectly? Would it be better to just store that data as a text file on DDFS?
|
How to download python from command-line?
| 6,630,925
| 0
| 30
| 127,053
| 0
|
python,linux,command-line,download
|
Well if you are getting into a linux machine you can use the package manager of that linux distro.
If you are using Ubuntu just use apt-get search python, check the list and do apt-get install python2.7 (not sure if python2.7 or python-2.7, check the list)
You could use yum in fedora and do the same.
if you want to install it on your windows machine i dont know any package manager, i would download the wget for windows, donwload the package from python.org and install it
| 0
| 1
| 0
| 0
|
2011-07-08T21:46:00.000
| 3
| 0
| false
| 6,630,873
| 0
| 0
| 0
| 1
|
I'm on windows, but I'm using a putty shell to connect to a linux machine, and want to install python 2.7. Can't figure out how to do it. How can I download python from command line?
|
Constantly running python script, calling functions via terminal
| 6,646,280
| 0
| 0
| 883
| 0
|
python,networking
|
Stick your server stuff in another thread (investigate the threading module) and use the main thread for interaction with the user via raw_input/input.
| 0
| 1
| 0
| 0
|
2011-07-11T04:12:00.000
| 5
| 0
| false
| 6,645,680
| 0
| 0
| 0
| 1
|
quick question that I'm never even sure is possible :3
I have a python script, a network script that connects to a server and remains connected until I either disconnect or it kicks me (which it normally shouldn't), which is constantly receiving data and doing other tasks.
I was curious if it's at all possible while the script is running, to trigger functions from within the script? Say while the script was running, if I had the urge to send some sort of data to the server, I could type it up and send it to the function that handles this?
Wasn't quite sure if it was possible or not, as I've never had to attempt or even seen it done. If it helps, I'm on Ubuntu linux running the script from the terminal.
|
Problem in calling Python script from PHP
| 6,645,831
| 1
| 1
| 584
| 0
|
php,python
|
When you test the python script on the command line, you're running as root. Chances are you're not running the webserver as root (which is a good thing), and the webserver's user does not have appropriate permissions to create and/or write to that file.
| 0
| 1
| 0
| 1
|
2011-07-11T04:37:00.000
| 1
| 1.2
| true
| 6,645,801
| 0
| 0
| 0
| 1
|
This is my python script which creates a "test.txt" file when executed. when I execute using terminal (Ubuntu 11.04) root@gml-VirtualBox:/var/www/HMS# python test.py. It creates the "test.txt" in the /var/www/HMS directory as I expected.
test.py:
#!/usr/bin/env python
def init():
filename = "test.txt"
file = open(filename, 'w')
file.write("This is the new content of test.txt :-)")
file.close()
print "done"
def main():
init()
if __name__ == '__main__':
main()
But when I try to call this test.py using PHP, It's not creating the 'test.txt' output file.
index.php:
$tmp = exec("python test.py");
echo "temp: $tmp";
Both test.py & index.php are in the same directory(/var/www/HMS/). But when I modified the test.py like this:
#!/usr/bin/env python
def init():
print "done"
def main():
init()
if __name__ == '__main__':
main()
It prints temp: done in the browser, which is what I expected.
I don't know why my previous python code didn't work as expected.
|
Memory leak when running python in Mac OS Terminal
| 6,646,346
| 5
| 2
| 2,149
| 0
|
python,macos,memory-leaks,terminal
|
It's not Python that is leaking memory. Look closer. On my machine, the Python process remains at a quiet, stable 3.5 MB of memory.
The memory usage increment you see is most likely due to the Terminal not ever discarding output. You can alter this behavior going to Preferences, Settings, and setting the maximum line number to something else than "Unlimited".
| 0
| 1
| 0
| 0
|
2011-07-11T06:00:00.000
| 2
| 0.462117
| false
| 6,646,331
| 1
| 0
| 0
| 2
|
I just ran a python program in the Mac OS Terminal, and there is unusual memory leak.
The program is simple like this:
for i in xrange(1000000000, 2000000000, 10):
i2 = i * i
print i, i2, str(i2)[::2]
if str(i2)[::2] == '1234567890':
break
When the program is running, it consumes more and more memory till it use up all my memory.
When I terminate the program, my Terminal.app still consumes a lot of memory, so I guess it's a bug in Terminal.app?
Does anyone have similar experience?
|
Memory leak when running python in Mac OS Terminal
| 6,646,350
| 14
| 2
| 2,149
| 0
|
python,macos,memory-leaks,terminal
|
This isn't a bug; it's actually a feature. Terminal.app, like many other terminal emulators, saves recent output in a buffer so that you can scroll back (with page up or the scroll bar). You can limit how large this is by going to Terminal -> Preferences -> Settings and setting the scrollback limit to something other than Unlimited.
| 0
| 1
| 0
| 0
|
2011-07-11T06:00:00.000
| 2
| 1.2
| true
| 6,646,331
| 1
| 0
| 0
| 2
|
I just ran a python program in the Mac OS Terminal, and there is unusual memory leak.
The program is simple like this:
for i in xrange(1000000000, 2000000000, 10):
i2 = i * i
print i, i2, str(i2)[::2]
if str(i2)[::2] == '1234567890':
break
When the program is running, it consumes more and more memory till it use up all my memory.
When I terminate the program, my Terminal.app still consumes a lot of memory, so I guess it's a bug in Terminal.app?
Does anyone have similar experience?
|
ctypes lib in python
| 28,210,864
| 1
| 0
| 533
| 0
|
python,ctypes
|
In fact,you can't create an instance of OpcServer Object if you use the moudle ctypes.Because C is not Object-Oriented language.If you use C++ to make a .dll file,you should make a C interface,in program such as extern "C",if you return an object in this .dll file,python' function can't recieve this object.If I'm not mistaken.If you really want to return an object in the dll file,maybe you can use boost.python to develop the dll file.
| 0
| 1
| 0
| 0
|
2011-07-12T14:51:00.000
| 2
| 0.099668
| false
| 6,666,162
| 1
| 0
| 0
| 1
|
I want to use OpcDaNet.dll in python, I use for that ctypes, but to be able to use the functions I'm intersted in, I have to create an instance of OpcServer Object, how can I do that with Ctypes?
thanks for your answres
|
Putting "Ctrl-A" in Python shell script
| 6,668,584
| 1
| 1
| 3,779
| 0
|
python,shell,gnu-screen
|
No. You won't be able to control screen program with a python program/script running within it.
| 0
| 1
| 0
| 0
|
2011-07-12T17:40:00.000
| 5
| 0.039979
| false
| 6,668,568
| 1
| 0
| 0
| 1
|
I'm trying to write a shell script in Python to automate a process, but one of the commands I have to use is Ctrl+A (I'm using screen). Is there a way to code this into the script?
|
Standardized python binary location?
| 6,674,591
| 1
| 3
| 3,172
| 0
|
python
|
On Mac OS X, do not modify anything in /usr (including /usr/bin) other than /usr/local, nor anything in /System/Library. Those directory spaces are managed by Apple as part of OS X. You risk breaking your system if you change or delete the wrong thing there. The best way to manage different versions is to modify your shell PATH environment variable; then you can use /usr/bin/env if needed. You can also use shell aliases or just use absolute paths. The Python installers from python.org have an option to automatically modify your shell initialization files appropriately.
| 0
| 1
| 0
| 0
|
2011-07-13T05:19:00.000
| 2
| 0.099668
| false
| 6,674,401
| 1
| 0
| 0
| 1
|
On a native Mac OS X install, I see Python binary at /usr/bin at version 2.6
Recently I installed Python 2.7.2 from the official binaries and it installed it at /usr/local/bin
What path of the Python interpreter should I give in my #! which will be standardized across all platforms?
I am assuming it could be /usr/bin so that I may have to symlink /usr/bin/python to /usr/local/bin/python but I just wanted to sure before I do this
|
Using MacPython with MacPorts
| 6,677,366
| 1
| 0
| 132
| 0
|
python,macports
|
I think MacPorts is not aware of MacPython, and therefore your best bet would be to install python 2.7 from the ports. That way you'll be able to select python 2.7 as default.
Another advantage of using python from MacPorts is that if you install ports that require python, MacPorts won't have to install python 2.7 a second time.
| 0
| 1
| 0
| 0
|
2011-07-13T09:25:00.000
| 1
| 1.2
| true
| 6,676,772
| 1
| 0
| 0
| 1
|
I've installed MacPython 2.7 from python.org. How to set it as default in MacPorts?
PS: #port select offers variants: '
none(active)
python2.5-apple
python2.6-apple
|
Problem running PyDev-developed apps in terminal
| 6,681,756
| 2
| 2
| 408
| 0
|
python,eclipse,terminal,pydev
|
The key here is that PyDev and Eclipse manage a custom Python Path when you're launching within Eclipse. You can modify your environment variables to contain a more complete PYTHONPATH value that contains the locations where you're importing from, or you can use sys.path.append() to add directories to the path at run time so that the imports can be resolved.
| 0
| 1
| 0
| 1
|
2011-07-13T15:45:00.000
| 1
| 1.2
| true
| 6,681,690
| 0
| 0
| 1
| 1
|
Im having some import problems with an application I developed in python with Eclipse/PyDev.
Running the app from within Eclipse is no problem but when I try running it through the linux terminal the imports (which are imported from other folders (packages in Eclipse)) are broken and I get an ImportError: No module named xxx..
From previous experiences developing Java-apps in Eclipse I always solved this through exporting the project to a runnable jar-file but this isn't an option with Python.
Is there a way of circumventing this? I'd rather not put all my .py-files in a single folder since I very much like the package-system (guess Java has damaged me). Can I change the import statement to make it work in both Eclipse and the terminal or do I have to abandon PyDev if I want this to work in the terminal?
Thanks for any help!
Slim
|
How many line of code are in a program? (I know this is kind of vauge and depends but...)
| 6,683,277
| 5
| 0
| 1,253
| 0
|
java,php,javascript,c++,python
|
Code length depends completely on the type of the application you want to design. It also depends on the language of choice. A program written in c will likely be significantly longer than say code in python.
It's never to late to learn!
| 0
| 1
| 0
| 0
|
2011-07-13T17:47:00.000
| 4
| 0.244919
| false
| 6,683,248
| 0
| 0
| 0
| 3
|
It seems when I try to research all I can find are how many lines are in Linux, call of duty, windows and other things that are massive applications with millions of lines of code.
Does anyone have examples of code size of applications that don't take teams and teams of people?
P.S.
I'm 24 yrs old and just starting to learn I feel like I got a really late start but I'm tired of sales and love technology so I'm just looking for something to gauge by.
Thanks in advance!
|
How many line of code are in a program? (I know this is kind of vauge and depends but...)
| 6,683,282
| 0
| 0
| 1,253
| 0
|
java,php,javascript,c++,python
|
Between 1 and several million (roughly). It depends. One person can write a lot of code if given enough time.
| 0
| 1
| 0
| 0
|
2011-07-13T17:47:00.000
| 4
| 0
| false
| 6,683,248
| 0
| 0
| 0
| 3
|
It seems when I try to research all I can find are how many lines are in Linux, call of duty, windows and other things that are massive applications with millions of lines of code.
Does anyone have examples of code size of applications that don't take teams and teams of people?
P.S.
I'm 24 yrs old and just starting to learn I feel like I got a really late start but I'm tired of sales and love technology so I'm just looking for something to gauge by.
Thanks in advance!
|
How many line of code are in a program? (I know this is kind of vauge and depends but...)
| 6,683,278
| 0
| 0
| 1,253
| 0
|
java,php,javascript,c++,python
|
No, there is no way to gauge or give this type of information. Frankly, it depends.
| 0
| 1
| 0
| 0
|
2011-07-13T17:47:00.000
| 4
| 0
| false
| 6,683,248
| 0
| 0
| 0
| 3
|
It seems when I try to research all I can find are how many lines are in Linux, call of duty, windows and other things that are massive applications with millions of lines of code.
Does anyone have examples of code size of applications that don't take teams and teams of people?
P.S.
I'm 24 yrs old and just starting to learn I feel like I got a really late start but I'm tired of sales and love technology so I'm just looking for something to gauge by.
Thanks in advance!
|
WindowsError: [Error 5] Access is denied
| 6,688,913
| 0
| 7
| 11,222
| 0
|
python
|
Funnily enough, it means that access is denied. You don't have permission to kill the process. This could be due to your account level (a "guest" sort of account or an account restricted by group policy) or it could be due to UAC (admin on your own machine but not running as admin—not sure if Windows 7 allows non-elevated process killing, though I would have thought it would).
| 0
| 1
| 0
| 0
|
2011-07-14T05:26:00.000
| 3
| 0
| false
| 6,688,815
| 0
| 0
| 0
| 1
|
I've been trying to kill a process but all my options give me a Windows Access Denied Error.
I open the process(a python script) through test= subprocess.Popen([sys.executable, "testsc.py"]) and I want to kill that process.
So far, I've tried os.kill(pid, signal.SIGILL) , os.kill(pid, 9), test.Terminate() and simply test.kill(). All of these give me the error.
I am using Python 2.7.1.4 on a Windows 7 x86 machine. I would appreciate the help! Thanks!
|
How to allow only selected user login in gae+python application?
| 6,697,664
| 2
| 3
| 755
| 0
|
python,google-app-engine,google-cloud-datastore
|
You basically need to do it in two steps:
Do what systempuntoout's answer said to only allow logged-in users to see your site.
On each of your routes (URL handlers), the first step should be to get their user object and check if they are on a list you're keeping of users allowed to see your app. For a first run, you could just have the list be a global variable, but this isn't very flexible (it makes you redeploy your app every time you want to update the list), so for a second run you should refactor it to perhaps read from the Datastore to see if a user is in the allowed list or not.
| 0
| 1
| 0
| 0
|
2011-07-14T14:17:00.000
| 2
| 1.2
| true
| 6,694,662
| 0
| 0
| 1
| 1
|
I want to upload my application on google app engine
and want to use this by only selected user
so want to know how it possible.
want to use users gmail account.
|
Easy Deploying of Python and application in one Bundle , For Linux
| 6,705,461
| 0
| 4
| 6,739
| 0
|
python,linux,deployment,portability,portable-applications
|
I want to deploy them in all one module including current python version i am using (Most OS Still ship with Python 2.5,6 i am using 2.7 and 2.7 specific features.) .
May be VirtualEnv is what you need for this?
| 0
| 1
| 0
| 0
|
2011-07-15T09:39:00.000
| 4
| 0
| false
| 6,705,193
| 0
| 0
| 0
| 2
|
I Develop Fairly large python application on server side , with all database connect , files extraction , parsing , command line calls.
It becomes a nightmare for deploying as i used many third party modules outside of standard python lib. And i lost track of them . Especially Differnt Linux OS uses different version of them so it is no longer good to install them using OS's package manager.
I want to deploy them in all one bundle including current python version i am using (Most OS Still ship with Python 2.5,6 i am using 2.7 and 2.7 specific features.) .
Further more , i have to teach the client to how to deploy , so they can test out in other servers. But they are not linux experts . I have to make it easy , in one script or by doing copy and paste.
There is Portablepython for Windows But there's nothing for Linux. And i had never used python Packaging as i usually work on server that i only host.
Please enlighten me of avaliable packaging and deployment options for python , that includes all the installed python modules and python itself.
|
Easy Deploying of Python and application in one Bundle , For Linux
| 6,705,387
| -4
| 4
| 6,739
| 0
|
python,linux,deployment,portability,portable-applications
|
There's no reason for Super Simple Server Side Setup.
Don't waste time on that.
How many server installations will happen? Not many.
Sys admins expect a certain level of complexity in server-based applications.
You have a list of 3rd party packages; they follow that list and do the installs.
Then -- after they've done all the installs -- they install and configure your package.
That's what many sys admins who work on servers expect. They expect dependencies and they expect a multi-step install.
| 0
| 1
| 0
| 0
|
2011-07-15T09:39:00.000
| 4
| -1
| false
| 6,705,193
| 0
| 0
| 0
| 2
|
I Develop Fairly large python application on server side , with all database connect , files extraction , parsing , command line calls.
It becomes a nightmare for deploying as i used many third party modules outside of standard python lib. And i lost track of them . Especially Differnt Linux OS uses different version of them so it is no longer good to install them using OS's package manager.
I want to deploy them in all one bundle including current python version i am using (Most OS Still ship with Python 2.5,6 i am using 2.7 and 2.7 specific features.) .
Further more , i have to teach the client to how to deploy , so they can test out in other servers. But they are not linux experts . I have to make it easy , in one script or by doing copy and paste.
There is Portablepython for Windows But there's nothing for Linux. And i had never used python Packaging as i usually work on server that i only host.
Please enlighten me of avaliable packaging and deployment options for python , that includes all the installed python modules and python itself.
|
Python - capturing subprocess exceptions
| 6,709,401
| 0
| 1
| 3,223
| 0
|
python
|
No. All you get is
whatever comes over the pipe returned from popen
the exit code of the child process when you pclose the process.
| 0
| 1
| 0
| 0
|
2011-07-15T15:19:00.000
| 2
| 1.2
| true
| 6,709,310
| 1
| 0
| 0
| 1
|
I'm using os.popen(cmd) to connect to a database with isql. This is in Unix, Python version 2.3.4. I'm trying to implement error handling, and I'm wondering if there's
an efficient way to capture errors/exceptions raised by called subprocesses such as this, without dealing with stderr, etc.
Thanks,
Dan
|
how to copy python modules into python lib directory
| 6,711,450
| 2
| 1
| 1,248
| 0
|
python,linux,module,copy
|
Make it a proper Python package on top of setuptools and register your command-line frontends using the 'console_scripts' entry-point.
| 0
| 1
| 0
| 1
|
2011-07-15T18:08:00.000
| 1
| 0.379949
| false
| 6,711,365
| 0
| 0
| 0
| 1
|
I have some python modules to copy into my Linux computer.
I found out that I need to copy them into one of the directory that python searches or else show a new path for it.
1. when I tried to copy files into /usr/bin/..../python2.6 .. its not allowing me.
how do I make it.
2. Also do tell me how do I add a new search path ?
please guide me in detail. I have very less knowledge in linux
Also please tell me how do I get over this kind of problems myself. Is there any small book or a kind of to learn?
|
Eclipse pydev project PYTHONPATH with macports python 2.6
| 6,712,886
| 2
| 1
| 932
| 0
|
python,eclipse,macos
|
Go to Window > Preferences > PyDev > Interpreter - Python. You should have an interpreter set up. If not, click New and browse to it.
Under Libraries, click New Folder and browse to the directory you want to include. Click Apply, let it build, and try again.
Edit: That is if you want to run the scripts THROUGH Eclipse.
If you want to run them from, say, the command line, you'll need to add the path to your PYTHONPATH environment variable.
| 0
| 1
| 0
| 1
|
2011-07-15T20:31:00.000
| 1
| 1.2
| true
| 6,712,824
| 1
| 0
| 0
| 1
|
I'm using Pydev with Eclipse on Mac. My python interpeter is macports python 2.6.
Right now the python package i'm working on is in my eclipse workspace, but the only way I can get my scripts to run is if I first install it into the macports 2.6 python site_packages folder. This means each time I make a code change I have to uninstall it, and then re-install it for my python interpreter to pick up the change.
How to I tell eclipse to tell python that {workspace}/mypythonporject should be part of the python path environment?
|
What should an installation of Python 2.5 look like on Windows XP?
| 6,726,646
| 0
| 1
| 128
| 0
|
python,windows-xp
|
Do you have any other application using Python?
It's also possible that applications install python for themself.
An example could be a game, which uses Python for the AI.
As far as i know, Panda3d installs its "own" Python...
| 0
| 1
| 0
| 0
|
2011-07-17T19:09:00.000
| 2
| 0
| false
| 6,726,101
| 1
| 0
| 0
| 1
|
I installed Python a while ago from the official python-2.5.4.msi, but I can't remember what else I might have done. On my disk, I have C:\Program Files\Python 2.5.4 and I also have C:\Python25. These directory contents look almost identical. The Program Files folder contains about 39 MB, the Python25 folder contains about 25 MB. Where did these come from?
In my start menu I have a Python 2.5 folder with a IDLE (Python GUI) shortcut and a few other things.
These two disk locations are really confusing me. I'm trying to install modules and it's getting messed up. When I ran ez_setup.py to install easy_install, it went into the Python25 directory, but Python seems to be searching for modules in the Program Files location. Or some awful mess like that. What did I do wrong?
|
How to INTERACT between a program on the server and the user via a web page REAL-TIME
| 6,737,020
| 0
| 1
| 233
| 0
|
python,ajax,cgi,subprocess,pipe
|
This sounds a lot like a homework question, but even with this list, you have a lot of work ahead of you for a dubious reward, so here we go.
Your C++ program should listen on a socket
Your python program needs to listen on a web socket, and also have a connection open to the C++ program through the C++ socket.
I'd suggest something like web.py for your web framework
Your web.py program is going to accept XMLHTTP Requests at a URL
your web page is going to submit requests through that XMLHTTP request, and send results back into the web page.
An easy way to do this on the frontend is to you jquery ajax commands; they will hit your web.py URL, which will validate the input, call a function to send it off to the C++ socket, get a response and send it back as a response to your jquery request.
Good luck.
| 0
| 1
| 1
| 0
|
2011-07-18T16:30:00.000
| 2
| 0
| false
| 6,736,152
| 0
| 0
| 0
| 1
|
Let me start with an example:
There is a c++ program which can be run on my server, the program is named "Guess the Number" which means every time it runs,
first it will generate an integer between 1 and 100 randomly.
then i need the user to guess a number and pass it to me though a web page, form or something.
now i want pass the number to the program and then the program will tell me whether it's bigger or smaller.
then i put the information on the web page to let the user know and then make his next guess.
i am able to write the program. and i know how pass the first argument and give back the information, but don't know how to interact in the next steps. i.e.
How to pass the arguments to the program REAL-TIME and get the output?
to make this more clearly:
i use subprocess in python to run the program with the first argument and get the output.
the c++ program use std inputs and outputs, like while (!check(x)) scanf("%d",&x);, and in check(int x), i use if (x>rand_num) printf("too big\n"); to output.
|
How to get kernel version by using kernel name (not current kernel)
| 6,746,830
| 0
| 1
| 4,768
| 0
|
python,linux,kernel,gentoo
|
Another possibility would be to try some different commands till you find one that returns sensible results. "rpm -qa kernel" should work for RedHat and some others while "dpkg --list | grep linux-image" should do the trick for ubuntu. Probably not much better than searching the filesystem directly and you have to parse the result anyhow.
| 0
| 1
| 0
| 0
|
2011-07-19T11:46:00.000
| 4
| 0
| false
| 6,746,614
| 1
| 0
| 0
| 1
|
Simply I want to clean older kernel's modules. It's "uname -r" but I need to get such information for all kernels with Python (I already know their names and can clean kernel files, initramfs and System.map). if that is possible ...
Thank you.
|
Top 5 Folders Consuming The Most Space?
| 6,748,862
| 0
| 1
| 475
| 0
|
python
|
You could just check the properties of each folder and look for the total size of the files in it. In Ubuntu, just right click on the folder, click properties and check the contents size. Not a python solution, but much easier (not everything needs a script to find the answer). The biggest folders will likely be the ones at the top of the tree.
| 0
| 1
| 0
| 1
|
2011-07-19T14:26:00.000
| 4
| 0
| false
| 6,748,791
| 0
| 0
| 0
| 1
|
My hard drive is full.
What is the easiest way to find out the TOP 5 FOLDERS that consume the most disk space?
A python solution would be greatly appreciated. I use Ubuntu Linux.
|
Asynchronous WSGI with Twisted
| 6,761,019
| 5
| 8
| 3,732
| 0
|
python,asynchronous,twisted,wsgi
|
Why do you want to use WSGI and do asynchronous things? The benefit of WSGI is that you can deploy your application on any WSGI container. If you start using Twisted APIs to do asynchronous things, then you can only deploy your application in Twisted's WSGI container.
You should probably just use Twisted Web without WSGI for your asynchronous code.
| 0
| 1
| 0
| 0
|
2011-07-20T08:34:00.000
| 2
| 1.2
| true
| 6,759,115
| 0
| 0
| 1
| 2
|
I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase).
The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html) states:
Like any other WSGI container, you can't do anything asynchronous in your WSGI applications, even though this is a Twisted WSGI container.
Does this have to be true? Is there some less-than-hacky way of doing twisted.web style asynchronous web request handling in WSGI - perhaps as part of another free software project? Supposing there isn't, my plan is to have WSGI threads do their asynchronous work in the reactor thread and block by polling until the data is available. It's not pretty.
If there's a reasonably uncomplicated way of asynchronously handling WSGI requests in twisted I'd love to hear it.
|
Asynchronous WSGI with Twisted
| 7,313,910
| 5
| 8
| 3,732
| 0
|
python,asynchronous,twisted,wsgi
|
In principle, WSGI is not intrinsically incompatible with asynchronous program design; in fact, PEP 333 goes to some considerable length to specify how servers, applications and middleware must behave to support that kind of thing.
At the heart of this is returning an iterator to the container. Every time an asynchronous wsgi app_iter is invoked, it would check on all of its pending asyncronous tasks (database connections, etcetera) and if any of them have data, the app_iter yields some data; otherwise it yields an empty string. To support this, a wsgi container would need to keep track of all of the in-flight requests, and iterate each of them in turn to get more data, in addition to servicing any other deferred work that it is responsible for.
In principle, very few wsgi apps or frameworks actually do this. almost invariably, wsgi frameworks block for all sorts of reasons; reading files from disk or loading data from a database for any reason at all (Most ORM's make this a tough problem to prevent.) Twisted's wsgi container operates under the assumption that since some wsgi apps block, that perhaps any wsgi app may block, and therefore always runs them in a thread.
There are two things you can do; either explore twisted's own web framework, which is fairly solid; or consider creating a wsgi wrapper for twisted outside of twisted's own container. Making sure the wsgi app is actually asyncronous is certainly a precondition of the latter, but wsgi itself is pretty simple, a thin wrapper over http, and so it should be easy enough.
| 0
| 1
| 0
| 0
|
2011-07-20T08:34:00.000
| 2
| 0.462117
| false
| 6,759,115
| 0
| 0
| 1
| 2
|
I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase).
The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html) states:
Like any other WSGI container, you can't do anything asynchronous in your WSGI applications, even though this is a Twisted WSGI container.
Does this have to be true? Is there some less-than-hacky way of doing twisted.web style asynchronous web request handling in WSGI - perhaps as part of another free software project? Supposing there isn't, my plan is to have WSGI threads do their asynchronous work in the reactor thread and block by polling until the data is available. It's not pretty.
If there's a reasonably uncomplicated way of asynchronously handling WSGI requests in twisted I'd love to hear it.
|
how to create a downloadable csv file in appengine
| 6,766,276
| 6
| 2
| 1,482
| 0
|
python,google-app-engine,csv
|
Pass a StringIO object as the first parameter to csv.writer; then set the content-type and content-disposition on the response appropriately (probably "text/csv" and "attachment", respectively) and send the StringIO as the content.
| 0
| 1
| 0
| 0
|
2011-07-20T17:49:00.000
| 2
| 1
| false
| 6,766,199
| 0
| 0
| 1
| 1
|
I use python Appengine. I'm trying to create a link on a webpage, which a user can click to download a csv file. How can I do this?
I've looked at csv module, but it seems to want to open a file on the server, but appengine doesn't allow that.
I've looked at remote_api, but it seems that its only for uploading or downloading using app config, and from account owner's terminal.
Any help thanks.
|
Find where python is installed (if it isn't default dir)
| 60,735,048
| 2
| 207
| 480,351
| 0
|
python
|
First search for PYTHON IDLE from search bar
Open the IDLE and use below commands.
import sys
print(sys.path)
It will give you the path where the python.exe is installed. For eg:
C:\Users\\...\python.exe
Add the same path to system environment variable.
| 0
| 1
| 0
| 0
|
2011-07-20T19:19:00.000
| 11
| 0.036348
| false
| 6,767,283
| 1
| 0
| 0
| 3
|
Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here?
|
Find where python is installed (if it isn't default dir)
| 57,471,464
| 1
| 207
| 480,351
| 0
|
python
|
On windows search python,then right click and click on "Open file location".That's how I did
| 0
| 1
| 0
| 0
|
2011-07-20T19:19:00.000
| 11
| 0.01818
| false
| 6,767,283
| 1
| 0
| 0
| 3
|
Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here?
|
Find where python is installed (if it isn't default dir)
| 44,020,984
| 43
| 207
| 480,351
| 0
|
python
|
For Windows CMD run: where python
For Windows PowerShell run: Get-Command python
| 0
| 1
| 0
| 0
|
2011-07-20T19:19:00.000
| 11
| 1
| false
| 6,767,283
| 1
| 0
| 0
| 3
|
Python is on my machine, I just don't know where, if I type python in terminal it will open Python 2.6.4, this isn't in it's default directory, there surely is a way of finding it's install location from here?
|
How to avoid packet loss on server application restart?
| 6,770,063
| 3
| 2
| 335
| 0
|
python,linux,web-services,tcp,network-programming
|
To avoid this, have multiple application servers behind a load balancer. Before bringing one down, ensure the load balancer is not sending it new clients. Bring it down, traffic will go to the other applications servers, and when it comes back up traffic will begin getting sent to it again.
If you have only one application server, simply 'buffering' network traffic is a poor solution. When the server comes back up, it has none of the TCP state information anymore and the old incoming connections have nowhere to go anyway.
| 0
| 1
| 0
| 0
|
2011-07-20T22:41:00.000
| 1
| 0.53705
| false
| 6,769,405
| 0
| 0
| 1
| 1
|
A typical situation with a server/web application is that the application needs to be shut down and restarted to implement an upgrade.
What are the possible/common schemes (and available software) to avoid losing data that clients sent to the server during the short time the application was gone?
An example scheme that could work is: For a simple web server where the client connects to port 80, rather than the client connecting directly to the web server application, there could be a simple application in between that listens to port 80 and seamlessly forwards/returns data to/from the "Actual" web server application (on some other port). When the web server needs to be shut down and restarted, the relay app could detect this and buffer all incoming data until the webserver comes back to life. This way there is always an application listening to port 80 and data is never lost (within buffer-size and time reason, of course). Does such a simple intermediate buffer-on-recipient-unavailable piece of software exist already?
I'm mostly interested in solutions for a single application instance and not one where there are multiple instances (in which case a clever rolling update scheme could be used), but in the interests of having a full answer set, any response would be great!
|
opening files using python / IDLE returns "no such file or directory" for pathname
| 6,783,526
| 0
| 2
| 9,743
| 0
|
python,file-io,python-idle
|
Rest assured, python has no limitation in this regard. About the only two possibilities are:
There is a hard-to-see typo in your code so you are looking for the wrong file, or
The code is correct and the file really doesn't exist because there is a hard-to-see typo in the actual file name. For example, maybe the file on disk has a leading or trailing space in the name.
| 0
| 1
| 0
| 0
|
2011-07-21T21:05:00.000
| 4
| 0
| false
| 6,782,775
| 1
| 0
| 0
| 1
|
I have WORDS_TXT = /macintosh HD/users/[username]/Desktop/[file]/words.txt/
but when run, python says "no such file or directory", however going though finder and "go to folder" that exact pathname brings me to the file I am trying to open. I am running python 3.2 on a macbook pro with Mac OS X 10.7
thank you in advance
|
Is Python on every GNU/Linux distribution?
| 6,786,717
| 0
| 6
| 5,337
| 0
|
python,linux,desktop,gnu
|
No, Python is not pre-installed neither installed on every Linux distro.
| 0
| 1
| 0
| 0
|
2011-07-22T07:03:00.000
| 2
| 0
| false
| 6,786,693
| 0
| 0
| 0
| 2
|
I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows?
|
Is Python on every GNU/Linux distribution?
| 6,786,804
| 7
| 6
| 5,337
| 0
|
python,linux,desktop,gnu
|
Well python does not come on ALL GNU/Linux distros but is present on most of the popular Linux home user distributions (Ubuntu and Fedora Core for example), possibly because most of the application of Gnome desktop environment and KDE use python 2.5+ (not python 3 yet) interpreters. Since python is almost integrated onto the system/environment from the start, linux users feel easy to program in python. But this is a subjective opinion, as java is still equally popular, if not more, on linux distributions.
Similarly, windows (vista/7) comes prepacked with .net framework, with awesome support for C#, and on Mac OSX objective-C is dominant for most os integrated apps; users just tend to program in languages they deem more "native" to the development environment they are using/targeting.
| 0
| 1
| 0
| 0
|
2011-07-22T07:03:00.000
| 2
| 1.2
| true
| 6,786,693
| 0
| 0
| 0
| 2
|
I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows?
|
Install BeautifulSoup for another Python version on Mac OS X
| 6,789,804
| 1
| 1
| 739
| 0
|
python,installation,beautifulsoup
|
Set your PYTHONPATH environmental variable to point to the installation you want to install it for, and make sure you're using that version of Python when you run python setup.py install. Something like PYTHONPATH=/usr/lib/python25 /usr/bin/python25 setup.py install.
| 0
| 1
| 0
| 0
|
2011-07-22T12:07:00.000
| 2
| 0.099668
| false
| 6,789,757
| 1
| 0
| 1
| 1
|
I have three versions of Python on my Mac: 2.6.1 (built-in), 2.5.4 (Google App Engine development), and 2.7.2 (general Python programming).
I installed BeautifulSoup with python setup.py install. However, only 2.7.2 is able to work with it.
How do I install it for 2.5.4 as well?
|
Determine if a file is on an NTFS filesystem
| 6,812,994
| 0
| 0
| 1,048
| 0
|
python,windows,ntfs
|
depending on your needs, you can use GetFileAttributes and check ntfs File Attribute Constants.
| 0
| 1
| 0
| 0
|
2011-07-24T19:25:00.000
| 3
| 0
| false
| 6,809,099
| 0
| 0
| 0
| 1
|
Is there a Windows API for determining if a certain file (path) is on an NTFS filesystem?
If this can be somehow inferred from an existing Python API, all the better.
|
python: executing "start /wait someprocess"
| 6,820,974
| 1
| 0
| 127
| 0
|
python,winapi,subprocess
|
If you want to wait for a spawned process, then use subprocess.Popen and then either wait or communicate. start is AFAIR a shell construct, not a real exec (so you'd have to use shell = True — but that still wouldn't do what you want).
| 0
| 1
| 0
| 0
|
2011-07-25T18:49:00.000
| 1
| 1.2
| true
| 6,820,856
| 1
| 0
| 0
| 1
|
I've used Python's subprocess.call() before, but how do you get it to act like the Windows START /WAIT myprogram?
I've tried subprocess.call(['start', '/wait', 'myprogram.exe']) but it can't find start and neither can I.
|
Specifying site directory outside of the script
| 6,824,421
| 0
| 0
| 50
| 0
|
python
|
The PYTHONPATH environment variable is essentially the same thing. Set it to a directory containing Python modules or packages and it will be added to sys.path at initialization.
| 0
| 1
| 0
| 0
|
2011-07-25T23:45:00.000
| 1
| 0
| false
| 6,823,783
| 1
| 0
| 0
| 1
|
Is it possible to specify site directories through python command line or environment?
Right now I'm using site.addsitedir, but I would like to make the script agnostic of the site-setting logic
|
Displaying virtualenv
| 6,847,060
| 6
| 5
| 3,584
| 0
|
python,shell,virtualenv
|
So I figured out how to do this. In the activate script the $PS1 is redefined to prepend the name of the env, in this case (foo-env). In order to prepend it with whatever you want you have to go into the activate script that you run to activate the virtualenv ([yourenv]/bin/activate]). There you change the line that that defines the new $PS1 from PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" to be whatever you want, here PS1="(F)$PS1".
| 0
| 1
| 0
| 0
|
2011-07-26T22:44:00.000
| 3
| 1
| false
| 6,837,514
| 0
| 0
| 0
| 1
|
When I am in my virtualenv and it's active, the name of the environment appears in parentheses before the normal command line prompt. It looks like: (foo-env)User:~/Development/foo-env/foo$ where foo-env is the name of the environment. I was wondering if there was a way to make it that the command line prompt displayed something like (F)User:~/Development/foo-env/foo$ as opposed to the current display with (foo-env). If this is possible how would I go about doing this?
|
automating excel with win32com on linux with wine
| 6,847,960
| 3
| 2
| 2,617
| 1
|
python,linux,excel,win32com,wine
|
You'd need a Windows version of Python, not a Linux version -- I'm saying you'd have to run Python under wine as well.
Have you tried with just a normal Windows install of Python on wine? I don't see any reason why this wouldn't work.
There is are numerous pages in a Google search that show Windows Python (32-bit) working fine.
| 0
| 1
| 0
| 0
|
2011-07-27T16:10:00.000
| 1
| 1.2
| true
| 6,847,684
| 0
| 0
| 0
| 1
|
I have a rather complex Excel 2010 file that I automate using python and win32com. For this I run windows in virtual box on an ubuntu machine.
However, that same excel file solves/runs fine on Ubuntu Maverick directly using wine 1.3. Any hope of automating Excel on wine so I can drop the VM?
Or is that just crazy talk (which I suspect).
|
How to install orbited on Mac 10.6
| 6,992,590
| 0
| 0
| 124
| 0
|
python,macos,sudo,orbited,pypm
|
Navigate to the directory of the files and then try running the command.
| 0
| 1
| 0
| 0
|
2011-07-29T10:02:00.000
| 1
| 1.2
| true
| 6,871,470
| 0
| 0
| 0
| 1
|
I have tried pypm install orbited but I still get sudo: orbited: command not found when running sudo orbited I downloaded orbited from http://pypi.python.org/pypi/orbited/0.7.10 Where do I put the files to install? Thanks
|
With python socketserver how can I pass a variable to the constructor of the handler class
| 68,489,995
| 1
| 24
| 13,253
| 0
|
python,python-2.7,socketserver
|
It seems that you can't use ForkingServer to share variables because Copy-on-Write happens when a process tries to modify a shared variable.
Change it to ThreadingServer and you'll be able to share global variables.
| 0
| 1
| 0
| 0
|
2011-07-29T15:41:00.000
| 5
| 0.039979
| false
| 6,875,599
| 0
| 0
| 0
| 1
|
I would like to pass my database connection to the EchoHandler class, however I can't figure out how to do that or access the EchoHandler class at all.
class EchoHandler(SocketServer.StreamRequestHandler):
def handle(self):
print self.client_address, 'connected'
if __name__ == '__main__':
conn = MySQLdb.connect (host = "10.0.0.5", user = "user", passwd = "pass", db = "database")
SocketServer.ForkingTCPServer.allow_reuse_address = 1
server = SocketServer.ForkingTCPServer(('10.0.0.6', 4242), EchoHandler)
print "Server listening on localhost:4242..."
try:
server.allow_reuse_address
server.serve_forever()
except KeyboardInterrupt:
print "\nbailing..."
|
PDF Thumbnailing with Google App Engine (Python)
| 6,893,852
| 1
| 4
| 568
| 0
|
python,google-app-engine,pdf
|
No. This requires a PDF renderer, and to the best of my knowledge no such thing exists in pure-Python. You'll have to use an external service to generate thumbnails.
| 0
| 1
| 0
| 0
|
2011-07-29T20:26:00.000
| 2
| 1.2
| true
| 6,878,642
| 0
| 0
| 1
| 1
|
Is it possible, using the python version of google app engine, to create a thumbnail of a PDF file?
The goal is for the user to be able to upload a PDF, and see it represented as a thumbnail on the page.
|
Data Migrations and AppEngine
| 6,892,479
| 1
| 5
| 608
| 0
|
python,ruby-on-rails-3,google-app-engine,data-migration
|
You can't change the name of an entity. It's not permitted.
If you change the name of an attribute in a model (please don't call them columns), AppEngine will ignore the old data in the old field, and return None for the new field.
| 0
| 1
| 0
| 0
|
2011-07-31T21:22:00.000
| 2
| 0.099668
| false
| 6,892,408
| 0
| 0
| 1
| 1
|
I've done a lot of development in rails, and am looking into developing projects using python & app engine.
From the demo project and what I've seen so far, I've got a question/concern about app engine projects:
How is data migration handled in app-engine? For example, if I change the name of an entity/table (ex: Texts to Documents), or change a column in an existing table (ex: age to dob) - how does it handle old data when this happens?
Thanks!
|
Which is the best Python version and IDE for me to use?
| 6,897,397
| 0
| 1
| 2,710
| 0
|
python,ide
|
I'd recommend starting with 2.7 since most libraries work with it. The differences between both are not too big, so you might even be able to switch if you want to in the future. But before you choose Python 3 and you find a library you really want to use and it's not available for Python 3 you would regret choosing.
wxPython and PyQt are pretty popular. wxPython doesnt support 3 yet...
I prefer PyCharm it's not free but it's so great and it has so many features...
One of the best code-completion i ever had for Python.
P.S.: if its really simple you mgiht even consider using tkinter.
| 0
| 1
| 0
| 0
|
2011-08-01T07:18:00.000
| 4
| 0
| false
| 6,895,269
| 1
| 0
| 0
| 1
|
Based on my project, which is the best version of Python to use? Which is the best IDE to use that runs on Linux (Ubuntu) and Windows? Here is the background for these questions:
I'm building a small application GUI that features "drill-down" views and direct manipulation on personalized calendars. Should I use Python 3, the newest version, or an older version is better at this GUI task? I've heard that some of the old GUI libraries do not support the new version yet, but not quite sure if this will matter a lot. Could you please name the libraries that might be relevant? Even better if you could suggest your preferred IDE either under Windows or Ubuntu. Many thanks.
|
App Engine Session Timeout
| 6,902,956
| 6
| 3
| 824
| 0
|
python,google-app-engine
|
This is configurable in the dashboard, under Administration -> Application Settings.
The default is 1 day, but you can set it as high as 2 weeks.
| 0
| 1
| 0
| 0
|
2011-08-01T18:26:00.000
| 1
| 1.2
| true
| 6,902,663
| 0
| 0
| 1
| 1
|
When do user sessions (Users API in Python) timeout when logging in with Google Accounts?
|
Copying files recursively with skipping some directories in Python?
| 6,904,116
| 4
| 3
| 2,031
| 0
|
python
|
If you're on Python 2.6 or higher, you can simply use shutil.copytree and its ignore argument. Since it gets passed all the files and directories, you can call your function from there, unless you want it to be called right after the file is copied.
If that is the case, the easiest thing is to copy and modify the copytree code.
| 0
| 1
| 0
| 0
|
2011-08-01T20:28:00.000
| 2
| 0.379949
| false
| 6,904,069
| 1
| 0
| 0
| 1
|
I want to copy a directory to another directory recursively. I also want to ignore some files (eg. all hidden files; everything starting with ".") and then run a function on all the other files (after copying them). This is simple to do in the shell, but I need a Python script.
I tried using shutil.copytree, which has ignore support, but I don't know how to have it do a function on each file copied. I might also need to check some other condition when copying so I can't just run the function on all the files once they are copied over. I also tried looking at os.walk but I couldn't figure it out.
|
Py2App: File Needs to Be Included, but it is Too Large
| 6,916,667
| 0
| 0
| 259
| 0
|
python,compression,py2app
|
I have more experience with Pyinstaller, but do you have to put the executable through Py2App? Might it be possible to package it with your executable in the same directory so it will be found and run? Is producing a single file very important, or could you include it in a directory with other dependencies?
| 0
| 1
| 0
| 0
|
2011-08-02T16:39:00.000
| 1
| 0
| false
| 6,915,473
| 1
| 0
| 0
| 1
|
At the moment, I'm using py2app to convert python scripts to a standalone application. However, my scripts require a 2GB unix executable. Py2App isn't able to process a file that large as an included file or resource, as it produces an error in the creation of the standalone file. Is there anyway I can include this file in my standalone app?
Any advice or suggestions would be appreciated. Thank you very much.
|
Check if file descriptor is valid
| 6,916,070
| 3
| 12
| 9,398
| 0
|
python,python-2.6,file-descriptor
|
How about trying to os.write to fd=3 once at the start (inside a try-except block), and change all subsequent behaviour based on the success of that?
This way you won't have to wrap every call in try-except. Of course, this will break down if fd=3 stops being valid in the middle of your problem (e.g. if it's a pipe that gets closed from the other end).
| 0
| 1
| 0
| 0
|
2011-08-02T17:29:00.000
| 2
| 0.291313
| false
| 6,916,033
| 1
| 0
| 0
| 1
|
How do I check to see if a given file descriptor is valid? I want to write to fd=3 if it's available; otherwise, I want to write to stdout. I'm aware that I could wrap every os.write call with try-except statement, but I would like to know ahead of time if fd=3 is writable or not.
|
How may I override the compiler (GCC) flags that setup.py uses by default?
| 60,766,834
| 4
| 67
| 35,921
| 0
|
python,gcc,setuptools,setup.py,distutils
|
I ran into this problem when I needed to fully remove a flag (-pipe) so I could compile SciPy on a low-memory system. I found that, as a hack, I could remove unwanted flags by editing /usr/lib/pythonN.N/_sysconfigdata.py to remove every instance of that flag, where N.N is your Python version. There are a lot of duplicates, and I'm not sure which are actually used by setup.py.
| 0
| 1
| 0
| 0
|
2011-08-03T14:28:00.000
| 3
| 0.26052
| false
| 6,928,110
| 0
| 0
| 0
| 1
|
I understand that setup.py uses the same CFLAGS that were used to build Python. I have a single C extension of ours that is segfaulting. I need to build it without -O2 because -O2 is optimizing out some values and code so that the core files are not sufficient to pin down the problem.
I just need to modify setup.py so that -O2 is not used.
I've read distutils documentation, in particular distutils.ccompiler and distutils.unixccompiler and see how to add flags and libs and includes, but not how to modify the default GCC flags.
Specifically, this is for a legacy product on Python 2.5.1 with a bunch of backports (Fedora 8, yes, I know...). No, I cannot change the OS or Python version and I cannot, without great problems, recompile Python. I just need to build a one off of the C extension for one customer whose environment is the only one segfaulting.
|
how to get uuid of a device using udev
| 6,930,448
| 3
| 0
| 2,348
| 0
|
python,udev
|
With pyudev, each device object provides a dictionary-like interface for its attributes. You can list them all with device.keys(), e.g. UUID is for block devices is dev['ID_FS_UUID'].
| 0
| 1
| 0
| 1
|
2011-08-03T14:59:00.000
| 2
| 0.291313
| false
| 6,928,566
| 0
| 0
| 0
| 1
|
I want get the mount node of an usb mass-storage device, like /media/its-uuid
in pyudev, class Device has some general attributes, but not uuid or mount node.
how to do it
thanks help
|
How to Identify the Python version in #! using environment variables
| 6,932,977
| 0
| 1
| 935
| 0
|
python,linux,interpreter
|
The optimal solution to this dilemma is using distutils (setup.py, which creates correct stubs for you automatically, for a number of given "console entry points") and virtualenv (handling the "isolated multiple installations" part).
| 0
| 1
| 0
| 0
|
2011-08-03T20:32:00.000
| 4
| 0
| false
| 6,932,925
| 1
| 0
| 0
| 1
|
I have a problem which is caused by our encapsulated design. Up till now lots of our scripts were written in bash and as a result the #!/bin/bash was always simple.
However now that we are rewriting our scripts in python that is a bit more difficult. We deliver a specific version of python (to avoid version differences in client installed environments from breaking our implementation). Because the specific version of python lives in a installed directory structure I need to route to it.
However I don't think the #! statement can accept environment variables from the shell that executes the file(tried and got a bad interpreter).
eg:
in foo.py I have #!$dirloc/wherepythonlives/python
In the bash shell I executed the file and got bad interpreter.
Is there a way of sneaking an environment variable into that #! line?
Or will I have to depend on an explicit path? We want to support multiple versions of our software (which may mean multiple python versions) on one environment so I was hoping to somehow keep Python's !# statement inside the directory level we install into.
|
How do I tell if the returned cursor is the last cursor in App Engine
| 6,935,512
| 5
| 10
| 4,861
| 0
|
python,google-app-engine,database-cursor
|
If you mean "has this cursor hit the end of the search results", then no, not without picking the cursor up and trying it again. If more entities are added that match the original search criteria, such that they logically land "after" the cursor (e.g., a query that sorts by an ascending timestamp), then reusing that saved cursor will let you retrieve those new entities.
| 0
| 1
| 0
| 0
|
2011-08-03T23:52:00.000
| 5
| 1.2
| true
| 6,934,681
| 0
| 0
| 1
| 1
|
I apologize if I am missing something really obvious.
I'm making successive calls to app engine using cursors. How do I tell if the I'm on the last cursor? The current way I'm doing it now is to save the last cursor and then testing to see if that cursor equals the currently returned cursor. This requires an extra call to the datastore which is probably unnecessary though.
Is there a better way to do this?
Thanks!
|
Using Django with app engine and eclipse
| 6,940,884
| 0
| 3
| 1,025
| 0
|
python,django,eclipse,google-app-engine,pydev
|
As @MatToufotu suggested you start with the django integration document in the appengine documentation. I would say you should stick with eclipse and pydev, as django-nonrel project created are nothing but pure django project with support for appengine, pydev can handle both of them with ease........
| 0
| 1
| 0
| 0
|
2011-08-04T11:03:00.000
| 2
| 0
| false
| 6,940,257
| 0
| 0
| 1
| 1
|
We are new to the python world and would like to get started a s soon a possible and develop a little web app for app engine. We are using Eclipse + Google plugin + Pydev.
We also would like to start using Django framework and we have two questions:
1. We are looking for a good tutorial which will put us on the right track with Django + app engine?
2. We are looking for a dev tool, apperently Eclipse with Pydev support either Django project or App engine project but not together, is there any other IDE which can solve this problem?
|
3D Rendering in Google App Engine
| 6,978,267
| 3
| 2
| 527
| 0
|
java,python,google-app-engine,3d
|
App Engine doesn't currently support C modules on the Python runtime. As a result, any rendering code would have to be written entirely in Python, and would be very, very slow. You couldn't take advantage of a GPU, either, since the runtime doesn't supply one.
Your best option, if you care at all about efficiency, is to call out to a server that does the rendering for you.
| 0
| 1
| 0
| 0
|
2011-08-04T12:37:00.000
| 1
| 1.2
| true
| 6,941,528
| 0
| 0
| 1
| 1
|
Is it possible to render any kind of 3D images in Google App Engine (with Backends)?
I'm looking for a Python solution, but I will learn Java if needed.
|
How to make a universal Python application
| 7,062,499
| 6
| 3
| 860
| 0
|
python
|
I have built several cross platform applications (Windows / OS X) with wxPython. Practically all of the code translates flawlessly across the two platforms. To put into context, I usually develop the applications on Mac OS side, and if I spend let's say one week hammering out an application, I spend something like a few hours to get it running nicely in Windows.
Usually those hours consist of:
Tweaking minor wxPython visuals (font sizes, colors)
Making nice things like embedded icons
Keyboard shortcuts (CMD vs CTRL)
Main menu
Like you correctly point out, if you want identical main menus you have some work ahead of you on OS X side. I myself have never really bothered, I am fine with having some additional OS X default main menu bits and pieces.
The main menu thing aside though, considering how little tweaking you have to do, I'd say wxPython is the way to go. Together with px2exe on Windows side and py2app on OS X side it packs quite the punch.
| 0
| 1
| 0
| 0
|
2011-08-04T14:50:00.000
| 5
| 1
| false
| 6,943,593
| 1
| 0
| 0
| 3
|
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
|
How to make a universal Python application
| 7,902,377
| 0
| 3
| 860
| 0
|
python
|
I'm currently developing an app on my Ubuntu Linux machine. I real life it runs on a windows xp machine with touchpad.
I'm using wxPython as the gui toolkit. In the past I've used .net predominantly but I wanted cross platform.
It really runs without any checks about which os it is running on. (save one check where i read a textfile and i have some trouble with the line endings)
| 0
| 1
| 0
| 0
|
2011-08-04T14:50:00.000
| 5
| 0
| false
| 6,943,593
| 1
| 0
| 0
| 3
|
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.