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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Tornado or Django works with CGI? | 3,244,176 | 5 | 2 | 1,611 | 0 | python,django,cgi,webserver,tornado | Main feature of Tornado is that it is high performance web-server written in Python, for creating web applications using Python programming language.
Running Tornado as CGI application negates the very reason it exists, because running CGI scripts is expensive in terms of performance, and most probably there is no way to run Tornado as CGI script. | 0 | 1 | 0 | 0 | 2010-03-29T10:02:00.000 | 2 | 0.462117 | false | 2,537,065 | 0 | 0 | 1 | 1 | Tornado is a webserver + framework like Django but for real-time features.
On my server I don't have a python module or wsgi module so I thought
CGI.
Is there a way to get Tornado ( or Django ) works by using CGI folder ?
If yes, Could you explain me how do I do that ? |
How to check if a user exists in a GNU/Linux OS using Python? | 2,540,756 | 0 | 21 | 15,746 | 0 | python,unix | I would parse /etc/passwd for the username in question. Users may not necessarily have homedir's. | 0 | 1 | 0 | 0 | 2010-03-29T18:54:00.000 | 5 | 0 | false | 2,540,460 | 0 | 0 | 0 | 1 | What is the easiest way to check the existence of a user on a GNU/Linux OS, using Python?
Anything better than issuing ls ~login-name and checking the exit code?
And if running under Windows? |
Read/Write a file from/to network folder/share using Python? | 2,542,026 | 1 | 1 | 1,813 | 0 | python,network-shares | Mount the shares using Samba, check the free space on the share using df or os.statvfs and read/write to it like any other folder. | 0 | 1 | 1 | 0 | 2010-03-29T19:33:00.000 | 1 | 1.2 | true | 2,542,025 | 0 | 0 | 0 | 1 | How to Write/Read a file to/from a network folder/share using python? The application will run under Linux and network folder/share can be a Linux/Windows System.
Also, how to check that network folder/share has enough space before writing a file?
What things should i consider? |
How can I keep the system environments set by a bat file, which called by a python script | 2,546,238 | 3 | 4 | 375 | 0 | python,windows | Environment settings always happen in the child process and never directly affect the parent process. However you can run (in the same child process that has changed its environment, at the very end of that process) a command (env in Unix-like environment, I believe set in DOS where .bat files lived and in Windows where .cmd files are similar) that outputs the environment to its standard-output, or to a file; the parent process can read that file and apply the changes to its own environment.
In Unix, subprocess.Popen('thescript; env', shell=True, stdout=...) may suffice. In Windows, I'm not sure passing as the first argument foo.bat; set would work; if it doesn't, just create a tiny temporary "auxiliary bat" that does foo.bat then set, and run that one instead. | 0 | 1 | 0 | 0 | 2010-03-30T14:55:00.000 | 2 | 0.291313 | false | 2,546,197 | 1 | 0 | 0 | 1 | I call .bat files in Python to set system environments, and check the system environments were set properly, and then back to run python code, the system environments are changed back to original. How can I solve this problem? |
Multiple Python versions on the same machine? | 2,547,577 | 91 | 107 | 165,340 | 0 | python | I think it is totally independent. Just install them, then you have the commands e.g. /usr/bin/python2.5 and /usr/bin/python2.6. Link /usr/bin/python to the one you want to use as default.
All the libraries are in separate folders (named after the version) anyway.
If you want to compile the versions manually, this is from the readme file of the Python source code:
Installing multiple versions
On Unix and Mac systems if you intend to install multiple versions of Python
using the same installation prefix (--prefix argument to the configure
script) you must take care that your primary python executable is not
overwritten by the installation of a different version. All files and
directories installed using "make altinstall" contain the major and minor
version and can thus live side-by-side. "make install" also creates
${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend
to install multiple versions using the same prefix you must decide which
version (if any) is your "primary" version. Install that version using
"make install". Install all other versions using "make altinstall".
For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being
the primary version, you would execute "make install" in your 2.6 build
directory and "make altinstall" in the others. | 0 | 1 | 0 | 0 | 2010-03-30T18:19:00.000 | 11 | 1.2 | true | 2,547,554 | 1 | 0 | 0 | 3 | Is there official documentation on the Python website somewhere, on how to install and run multiple versions of Python on the same machine on Linux?
I can find gazillions of blog posts and answers, but I want to know if there is a "standard" official way of doing this?
Or is this all dependent on OS? |
Multiple Python versions on the same machine? | 2,547,576 | 0 | 107 | 165,340 | 0 | python | It's most strongly dependent on the package distribution system you use. For example, with MacPorts, you can install multiple Python packages and use the pyselect utility to switch the default between them with ease. At all times, you're able to call the different Python interpreters by providing the full path, and you're able to link against all the Python libraries and headers by providing the full paths for those.
So basically, whatever way you install the versions, as long as you keep your installations separate, you'll able to run them separately. | 0 | 1 | 0 | 0 | 2010-03-30T18:19:00.000 | 11 | 0 | false | 2,547,554 | 1 | 0 | 0 | 3 | Is there official documentation on the Python website somewhere, on how to install and run multiple versions of Python on the same machine on Linux?
I can find gazillions of blog posts and answers, but I want to know if there is a "standard" official way of doing this?
Or is this all dependent on OS? |
Multiple Python versions on the same machine? | 2,547,801 | 28 | 107 | 165,340 | 0 | python | On Windows they get installed to separate folders, "C:\python26" and "C:\python31", but the executables have the same "python.exe" name.
I created another "C:\python" folder that contains "python.bat" and "python3.bat" that serve as wrappers to "python26" and "python31" respectively, and added "C:\python" to the PATH environment variable.
This allows me to type python or python3 in my .bat Python wrappers to start the one I desire.
On Linux, you can use the #! trick to specify which version you want a script to use. | 0 | 1 | 0 | 0 | 2010-03-30T18:19:00.000 | 11 | 1 | false | 2,547,554 | 1 | 0 | 0 | 3 | Is there official documentation on the Python website somewhere, on how to install and run multiple versions of Python on the same machine on Linux?
I can find gazillions of blog posts and answers, but I want to know if there is a "standard" official way of doing this?
Or is this all dependent on OS? |
Simulate Network Presence in dbus | 2,559,633 | 1 | 0 | 438 | 0 | python,linux,dbus | I'm pretty sure that both Pidgin and Empathy assume you're online if you disable NM by right-clicking the Network Manager tray icon and untick Enable Networking. So you can do this when you're connecting via a non-NM mechanism. No code necessary!
(You could write an application which implements the same D-Bus interface as NetworkManager, sits on the system bus, and pretends to be online, and then when you want to use your network kill the real NetworkManager program and start your fake one, but that smells like overkill to me...) | 0 | 1 | 0 | 0 | 2010-03-31T04:37:00.000 | 2 | 1.2 | true | 2,550,523 | 0 | 0 | 0 | 2 | Is there a way using Python to simulate the presence of an active network connection using dbus? If I call getstate() on the dbus, I'm able to get the current network state. I want to set the current state to 4 (Connection Present). This is because Network Manager is not able to connect using my modem and I use other tools to connect. Pidgin, Empathy and other software are not able to detect the network. |
Simulate Network Presence in dbus | 2,550,541 | 0 | 0 | 438 | 0 | python,linux,dbus | Your options are to write something that mocks NetworkManager's D-Bus interface, or to write a module for NetworkManager that supports the tools you use. | 0 | 1 | 0 | 0 | 2010-03-31T04:37:00.000 | 2 | 0 | false | 2,550,523 | 0 | 0 | 0 | 2 | Is there a way using Python to simulate the presence of an active network connection using dbus? If I call getstate() on the dbus, I'm able to get the current network state. I want to set the current state to 4 (Connection Present). This is because Network Manager is not able to connect using my modem and I use other tools to connect. Pidgin, Empathy and other software are not able to detect the network. |
Which files to distribute using cx_Freeze? | 2,553,685 | 10 | 2 | 897 | 0 | python,distutils,cx-freeze | You need all of them. | 0 | 1 | 0 | 0 | 2010-03-31T13:07:00.000 | 1 | 1.2 | true | 2,553,110 | 0 | 0 | 0 | 1 | I'm using cx_freeze to freeze a Python script for distribution to other windows systems. I did everything as instructed and cx_freeze generated a build\exe.win32-2.6 folder in the folder containing my sources. This directory now contains a a bunch of PYD files, a library.zip file, the python DLL file and the main executable. Which of these files would I need to distribute? Any help, guys?
Thanks in advance. |
Accessing a JET (.mdb) database in Python | 2,559,686 | 2 | 12 | 8,629 | 0 | python,database,jet | Probably the most simple solution:
Download VirtualBox and install Windows and MS access in it.
Write a small Python server which use ODBC to access the database and which receives commands from a network socket.
On Linux, connect to the server in the virtual machine and access the database this way.
This gives you full access to all features. Every other solution will either limit the features you can use (for example, you won't be able to modify the data) or be pretty unsafe. | 0 | 1 | 0 | 0 | 2010-04-01T10:21:00.000 | 4 | 0.099668 | false | 2,559,659 | 1 | 0 | 0 | 1 | Is there a way to access a JET database from Python? I'm on Linux. All I found was a .mdb viewer in the repositories, but it's very faulty. Thanks |
Configuring Eclipse with wxPython | 12,983,874 | 3 | 3 | 8,700 | 0 | python,eclipse,wxpython | wxPython install by default to the following path /usr/local/lib/wxPython-2.9.4.0
When adding a path to the Interpreter libraries section in the eclipse preferences add this path:
/usr/local/lib/wxPython-2.9.4.0/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa | 1 | 1 | 0 | 0 | 2010-04-01T15:28:00.000 | 3 | 0.197375 | false | 2,561,542 | 0 | 0 | 0 | 2 | I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question.
Anyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I take to allow wxPython development from eclipse?
Thanks! |
Configuring Eclipse with wxPython | 2,562,141 | 7 | 3 | 8,700 | 0 | python,eclipse,wxpython | Vinay's answer above is correct. However, if code completion is not picking it up, you might need to add the WX directory to the Pydev's interpreter library path.
Window | Preferences | Pydev |
Interpreter - Python | Libraries
If wx is not present, New Folder and select the install directory. | 1 | 1 | 0 | 0 | 2010-04-01T15:28:00.000 | 3 | 1 | false | 2,561,542 | 0 | 0 | 0 | 2 | I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question.
Anyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I take to allow wxPython development from eclipse?
Thanks! |
Eclipse: PyDev installation difficulties | 15,892,577 | 0 | 0 | 1,097 | 0 | python,eclipse,pydev | there's an easy way to install plugin for eclipse, download the pydev package zip file (not install it via eclipse update), extract it, and put it into your eclipse/dropins/pydev folder.
this is a hidden way to install plugin. | 0 | 1 | 0 | 1 | 2010-04-02T16:48:00.000 | 1 | 0 | false | 2,567,895 | 0 | 0 | 1 | 1 | I'm having difficulty getting PyDev to work.
I had an installation of Eclipse for PHP developers (1.2.1.20090918-0703). A month ago, I installed PyDev, and everything worked great. I go to fire it up this morning, and PyDev is gone. There is no option to create a Python project, the Python language editor is missing, etc.
Eclipse for PHP does not say that PyDev is installed, so I grab it from the update URL. The version that comes down is 1.5.6. I restart after the installation, and everything works fine again. Sweet.
Then, I grab Subclipse 1.0.7. Upon restarting after that installation, PyDev is now gone. It isn't recognizing Python projects or Python files, etc. So I uninstall Subclipse. PyDev is still gone. Uninstalling and reinstalling PyDev again doesn't bring it back.
What am I doing wrong? Do I need a different version of Eclipse?
UPDATE: I downloaded a fresh copy of Eclipse for Java, did all this over again, and had PyDev working fine. Then, when I downloaded JSEclipse, PyDev again disappeared. This is super frustrating.
UPDATE 2: Another fresh copy of Eclipse. This time I downloaded Subclipse first. It worked fine. Then I downloaded JSEclipse, and Subclipse is gone. |
Implement a server that receives and processes client request(cassandra as backend), Python or C++? | 2,583,480 | 0 | 1 | 140 | 0 | c++,python,search,full-text-search | Python is unlikely to allow you to write the most efficient server possible. However, it may just be that it will be fast enough, because for most applications it is.
Therefore, one path you could take is starting with Python. It's a great language for prototyping, much better than C++ for the stage in which you're not even sure which architecture to adopt. As you finish the project, you can see if Python is efficient enough. If it isn't and there's no easy way to make it much faster (such as rewriting a small routine that takes up most of the work in C), you can rewrite it in C++ using the Python prototype as a basis. | 0 | 1 | 0 | 0 | 2010-04-06T05:47:00.000 | 3 | 1.2 | true | 2,582,892 | 0 | 0 | 0 | 1 | I am planning to build an inverted index searching system with cassandra as its storage backend. But I need some guidances to build a highly efficient searching daemon server. I know a web server written in Python called tornado, my questions are:
Is Python a good choice for developing such kind of apps?
Is Nginx(or Sphinx) a good example that I can look inside to learn its architecture to implement a highly efficient server?
Anything else I should learn to do this?
Thank you~ |
Looking for a Python IDE with good support for libraries (Twisted) | 2,586,371 | 2 | 0 | 1,587 | 0 | python,ide,import,libraries,code-completion | I've just downloaded the preview of netbeans and it seems to have done quite well so far.
It has detected inherited methods & properties. I haven't had to add a single library reference in my project, so this seems to be the most fluid so far. | 0 | 1 | 0 | 0 | 2010-04-06T15:58:00.000 | 6 | 0.066568 | false | 2,586,274 | 1 | 0 | 0 | 2 | I'm looking for a Python IDE that can help me easily locate and manage and use the libraries on my system (Ubuntu). Specifically Twisted.
Code completion is important including the symbols I import.
(I've so far had a look at PyDev as well as OpenKomodo, but while both offer code completion for default Python concepts, I wasn't able to get either to import Twisted into my project and was thus getting reference errors.)
Usual disclaimer: I don't like EMACS or vi, please, nothing regarding those. |
Looking for a Python IDE with good support for libraries (Twisted) | 2,586,619 | 2 | 0 | 1,587 | 0 | python,ide,import,libraries,code-completion | eclipse + pydev seems to work well for me.
Just remember to right-click on the project and select Properties and make sure that your libraries are on the path. Sometimes this doesn't happen for easy_installed libraries. | 0 | 1 | 0 | 0 | 2010-04-06T15:58:00.000 | 6 | 0.066568 | false | 2,586,274 | 1 | 0 | 0 | 2 | I'm looking for a Python IDE that can help me easily locate and manage and use the libraries on my system (Ubuntu). Specifically Twisted.
Code completion is important including the symbols I import.
(I've so far had a look at PyDev as well as OpenKomodo, but while both offer code completion for default Python concepts, I wasn't able to get either to import Twisted into my project and was thus getting reference errors.)
Usual disclaimer: I don't like EMACS or vi, please, nothing regarding those. |
How to use ';' (semicolon) in urls, using Google Appengine | 5,877,046 | 0 | 2 | 336 | 0 | python,google-app-engine,url | Issue816 has now been fixed, semi-colons are usable with appengine. | 0 | 1 | 0 | 0 | 2010-04-07T12:54:00.000 | 2 | 1.2 | true | 2,592,540 | 0 | 0 | 1 | 1 | Using the local dev server, I can use ';' in urls, but as soon as I try the live version hosted by Google, it looks like the ';' and everything afterward is stripped (at least according to request.path_qs).
(I would prefer not to encode them if possible, it's much less user friendly if the url cannot be constructed by copy-pasting, especially since other characters works fine, e.g. ':'). |
Is there a way to backup everything in an app-engine blobstore? | 2,594,009 | 2 | 3 | 645 | 0 | python,google-app-engine,blobstore | In Java, you would instantiate a BlobInfoFactory and use BlobInfoFactory.queryBlobInfos.
Then for each blob, you would run BlobstoreService.serve(...) with the BlobKeys returned from the BlobInfos. You still might end up with broken entity relationships - there's no way to guarantee each blob will end up with the same key it was originally loaded with. You'll have to account for this in your application. | 0 | 1 | 0 | 0 | 2010-04-07T15:31:00.000 | 1 | 0.379949 | false | 2,593,756 | 0 | 0 | 1 | 1 | bulkloader.py is very handy.
But as far as I can tell it doesn't appear to fetch items from the blobstore, so you can be left with broken entity relationships if you needed to dump/restore your application.
Does anyone know a method for completely backing up their data from app-engine including blobstore data? |
Running python batch file that has a path with SPACE character | 2,594,277 | 2 | 3 | 12,337 | 0 | python,windows,path,batch-file | Looks like you almost had it; just replace the double-slashes with single slashes.
If you're ever unsure and need a reminder of the right format. Try using the tab key to automatically complete your folder or filename. For example, at your command prompt just type:
C:\docu
then hit the tab key and it will automatically complete your folder name. From there you just type in the rest. Whenever you want to automatically complete the rest of the folder or filename, just hit the tab key. This will always produce a properly specified path that is runnable. | 0 | 1 | 0 | 0 | 2010-04-07T16:33:00.000 | 4 | 0.099668 | false | 2,594,190 | 1 | 0 | 0 | 1 | The batch file is something like this, I put the python in some directory that has SPACE character in its path.
C:\"Documents and Settings"\Administrator\Desktop\bracket\python\python
C:\\"Documents and Settings"\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py
When I run this one, I get this error.
C:\Documents and Settings\Administrator\Desktop\bracket\python\python: can't ope
n file 'C:\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\bra
ckettest.py': [Errno 2] No such file or directory
C:\Documents and Settings\Administrator\Desktop\bracket>
What might be wrong?
Wrapping the path doesn't solve this problem.
"C:\\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py"
Are the brackets ('[]') cause of the problem? On Mac, python works well with bracket character. |
deletion of folders | 2,597,538 | 0 | 0 | 120 | 0 | python,directory | you can use os.rmdir() to remove a directory. To remove a directory tree recursively, you can use shutil.rmtree. If you know that you already have empty directory nodes, you can also check out os.removedirs() | 0 | 1 | 0 | 0 | 2010-04-08T04:03:00.000 | 2 | 0 | false | 2,597,501 | 0 | 0 | 0 | 1 | how can i delete a folder using python script?and what are the return values?? |
Pre-generating GUIDs for use in python? | 2,603,967 | 6 | 2 | 1,247 | 0 | python,linux,performance,guid,uuid | Are you certain that the uuid module would in fact be too slow to handle the requests you expect in a timely manner? I would be very surprised if UUID generation accounted for a bottleneck in your application.
I would first build the application to simply use the uuid module and then if you find that this module is in fact slowing things down you should investigate a way to keep a pre-generated list of UUIDs around. | 0 | 1 | 0 | 0 | 2010-04-08T22:43:00.000 | 3 | 1 | false | 2,603,951 | 0 | 0 | 0 | 1 | I have a python program that needs to generate several guids and hand them back with some other data to a client over the network. It may be hit with a lot of requests in a short time period and I would like the latency to be as low as reasonably possible.
Ideally, rather than generating new guids on the fly as the client waits for a response, I would rather be bulk-generating a list of guids in the background that is continually replenished so that I always have pre-generated ones ready to hand out.
I am using the uuid module in python on linux. I understand that this is using the uuidd daemon to get uuids. Does uuidd already take care of pre-genreating uuids so that it always has some ready? From the documentation it appears that it does not.
Is there some setting in python or with uuidd to get it to do this automatically? Is there a more elegant approach then manually creating a background thread in my program that maintains a list of uuids? |
Why does easy_install extract some python eggs and not others? | 2,604,612 | 5 | 19 | 8,363 | 0 | python,egg | I can't explain why some eggs are zipped (the files) and some are directories, but I can offer this: if you hate zipped eggs (like I do) put this in the [easy_install] section of your ~/.pydistutils.cfg:
zip_ok = false | 0 | 1 | 0 | 1 | 2010-04-09T01:45:00.000 | 2 | 0.462117 | false | 2,604,600 | 1 | 0 | 0 | 1 | Looking in my /usr/local/lib/python.../dist-package directory, I have .egg directories and .egg files.
Why does the installer choose to extra packages to the .egg directory, yet leave other files with .egg extensions? |
How to correctly relay TCP traffic between sockets? | 2,609,442 | 1 | 4 | 3,528 | 0 | python,sockets,tcp,portforwarding | Perhaps the application you're proxying is poorly written.
For instance, if I call recv(fd, buf, 4096, 0); I'm not promised 4096 bytes. The system makes a best-effort to provide it.
If 1k isn't a multiple of your application's recv or send sizes, and the application is broken, then grouping the data sent into 1k blocks will break the app. | 0 | 1 | 1 | 0 | 2010-04-09T02:24:00.000 | 3 | 0.066568 | false | 2,604,740 | 0 | 0 | 0 | 2 | I'm trying to write some Python code that will establish an invisible relay between two TCP sockets. My current technique is to set up two threads, each one reading and subsequently writing 1kb of data at a time in a particular direction (i.e. 1 thread for A to B, 1 thread for B to A).
This works for some applications and protocols, but it isn't foolproof - sometimes particular applications will behave differently when running through this Python-based relay. Some even crash.
I think that this is because when I finish performing a read on socket A, the program running there considers its data to have already arrived at B, when in fact I - the devious man in the middle - have yet to send it to B. In a situation where B isn't ready to receive the data (whereby send() blocks for a while), we are now in a state where A believes it has successfully sent data to B, yet I am still holding the data, waiting for the send() call to execute. I think this is the cause of the difference in behaviour that I've found in some applications, while using my current relaying code. Have I missed something, or does that sound correct?
If so, my real question is: is there a way around this problem? Is it possible to only read from socket A when we know that B is ready to receive data? Or is there another technique that I can use to establish a truly 'invisible' two-way relay between [already open & established] TCP sockets? |
How to correctly relay TCP traffic between sockets? | 2,604,794 | 1 | 4 | 3,528 | 0 | python,sockets,tcp,portforwarding | I don't think that's likely to be your problem.
In general, the sending application can't tell when the receiving application actually calls recv() to read the data: the sender's send() may have completed, but the TCP implementations in the source & destination OS will be doing buffering, flow control, retransmission, etc.
Even without your relay in the middle, the only way for A to "consider its data to have already arrived at B" is to receive a response from B saying "yep, I got it". | 0 | 1 | 1 | 0 | 2010-04-09T02:24:00.000 | 3 | 0.066568 | false | 2,604,740 | 0 | 0 | 0 | 2 | I'm trying to write some Python code that will establish an invisible relay between two TCP sockets. My current technique is to set up two threads, each one reading and subsequently writing 1kb of data at a time in a particular direction (i.e. 1 thread for A to B, 1 thread for B to A).
This works for some applications and protocols, but it isn't foolproof - sometimes particular applications will behave differently when running through this Python-based relay. Some even crash.
I think that this is because when I finish performing a read on socket A, the program running there considers its data to have already arrived at B, when in fact I - the devious man in the middle - have yet to send it to B. In a situation where B isn't ready to receive the data (whereby send() blocks for a while), we are now in a state where A believes it has successfully sent data to B, yet I am still holding the data, waiting for the send() call to execute. I think this is the cause of the difference in behaviour that I've found in some applications, while using my current relaying code. Have I missed something, or does that sound correct?
If so, my real question is: is there a way around this problem? Is it possible to only read from socket A when we know that B is ready to receive data? Or is there another technique that I can use to establish a truly 'invisible' two-way relay between [already open & established] TCP sockets? |
Eclipse PyDev doesn't shut down interpreter when you click the little red button | 2,613,712 | 1 | 1 | 437 | 0 | python,eclipse,eclipse-plugin,pydev | This often happens when you're using something like cherrypy/django and the process restarts after you've changed a python file while it's running. When this happens, I think the process is different but still using the same output console and thus won't be killed when you press the red button.
I'm not sure there's a way of fixing it, except for disabling auto-restarting in the web framework etc. | 0 | 1 | 0 | 0 | 2010-04-10T14:19:00.000 | 2 | 0.099668 | false | 2,613,672 | 1 | 0 | 0 | 2 | Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch in the background, once it's launched I have to go to task manager to kill the python process. |
Eclipse PyDev doesn't shut down interpreter when you click the little red button | 2,614,018 | 1 | 1 | 437 | 0 | python,eclipse,eclipse-plugin,pydev | As far as I can tell when working with Django you need to add runserver --noreload to your program argument in Run > Run... menu | 0 | 1 | 0 | 0 | 2010-04-10T14:19:00.000 | 2 | 1.2 | true | 2,613,672 | 1 | 0 | 0 | 2 | Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch in the background, once it's launched I have to go to task manager to kill the python process. |
Installing virtualenvwrapper on Windows | 2,616,482 | 11 | 39 | 34,056 | 0 | python,windows,virtualenv,virtualenvwrapper | mkvirtualenv is a bash script so you need to run bash shell to make use of it.
mkvirtualenv is a bash function in the mkvirtualenv_bashrc script
You will need to run this from cygwin under Windows. (You can call a native python from this and not need a cygwin python) | 0 | 1 | 0 | 0 | 2010-04-11T03:42:00.000 | 6 | 1.2 | true | 2,615,968 | 1 | 0 | 0 | 2 | I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea? |
Installing virtualenvwrapper on Windows | 49,574,221 | 5 | 39 | 34,056 | 0 | python,windows,virtualenv,virtualenvwrapper | In windows we need to use virtualenv not mkvirtualenv while creating virtual environments | 0 | 1 | 0 | 0 | 2010-04-11T03:42:00.000 | 6 | 0.16514 | false | 2,615,968 | 1 | 0 | 0 | 2 | I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea? |
Python: what package contains the installation metadata? | 2,616,194 | 1 | 2 | 91 | 0 | python,installation,metadata | You want the sys module:
>>> print sys.executable
/usr/bin/python
>>> print sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
'/Library/Python/2.6/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode'] | 0 | 1 | 0 | 1 | 2010-04-11T06:01:00.000 | 2 | 0.099668 | false | 2,616,190 | 1 | 0 | 0 | 1 | e.g., how can I find out that the executable has been installed in "/usr/bin/python" and the library files in "/usr/lib/python2.6"? |
Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib? | 2,624,473 | -3 | 0 | 410 | 0 | python,osx-snow-leopard,pyobjc | You more than likely screwed with the OS's Python installation, so you'll more than likely need to reinstall your OS. | 0 | 1 | 0 | 0 | 2010-04-12T17:43:00.000 | 2 | -0.291313 | false | 2,624,100 | 1 | 0 | 0 | 1 | on OS X 10.6.3 Snow Leopard
% python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 22, in
_update()
File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 19, in _update
import _objc
ImportError: dlopen(/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so, 2): Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so
Reason: Incompatible library version: _objc.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
>>>
--
what do I need to do? |
How do I prepare myself for a summer of working on Python using Linux environment? | 2,625,082 | 5 | 4 | 674 | 0 | python,linux,shell,development-environment | As an intern you'll want to use the tools your mentor is most comfortable with. If you get stuck you'll be able to ask for advice quickly.
Learning your way around either vi, vim, or emacs to start with will help. The basic concepts used in one will transfer to the other. You'll need to be able to open and read files, search through files, edit and save files, and learn how to apply any python formatting helpers correctly.
You should also familiarize yourself with version control if you haven't already. Again any one will do, you need to focus on concepts and etiquette rather than the specific tool.
The goal of the internship (and really your entire time at university) should be used to learn concepts rather than specific tools. If you learn the concepts you'll be well placed to apply those concepts using any tool. You will also "learn how to learn" a new tool, which is really valuable. | 0 | 1 | 0 | 0 | 2010-04-12T19:58:00.000 | 10 | 1.2 | true | 2,624,968 | 1 | 0 | 0 | 3 | I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting.
I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest?
Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead?
Thanks for taking the time. |
How do I prepare myself for a summer of working on Python using Linux environment? | 2,625,078 | 2 | 4 | 674 | 0 | python,linux,shell,development-environment | Your lack of shell scripting knowledge shouldn't matter in this case, although it won't be hard to learn. I read over some shell tutorials and put them into practice. Try doing everything from the command line, including find (grep), find/replace all (sed), finding files (find), automating things using python scripts etc. Basically, don't cheat. You'll pick up a lot this way. You'll also probably end up wondering how you ever managed with Windows.
What I use depends on the project. I really like Eclipse+PyDev but that's my personal preference, I also use Vim depending on where I am/what I'm doing. Remember you can just type python from the command line and it drops you into the python environment. | 0 | 1 | 0 | 0 | 2010-04-12T19:58:00.000 | 10 | 0.039979 | false | 2,624,968 | 1 | 0 | 0 | 3 | I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting.
I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest?
Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead?
Thanks for taking the time. |
How do I prepare myself for a summer of working on Python using Linux environment? | 2,625,070 | 0 | 4 | 674 | 0 | python,linux,shell,development-environment | For a Python IDE, I recommend using either IDLE or Eclipse with PyDev.
Keep in mind you can also just use python on the linux command-line. It supports loading code from files, and if you use two command windows then one of them will be your "REPL" where you will be running python and dynamically loading code - and the other window can run your editor.
Regarding linux command line, I cannot recommend any great resources. However, you will be off to a great start if you immerse yourself in this environment and only use linux for the next 2 weeks. Just keep learning, and when you do not know how to do something, read a manpage or google it to find the answer. | 0 | 1 | 0 | 0 | 2010-04-12T19:58:00.000 | 10 | 0 | false | 2,624,968 | 1 | 0 | 0 | 3 | I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting.
I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest?
Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead?
Thanks for taking the time. |
How to get a Device Specific UID using Python in ASE on Android? | 5,914,317 | 0 | 2 | 234 | 0 | python,android,ase,android-scripting | The newer versions of ASE now include a function call to create these identifiers. | 0 | 1 | 0 | 1 | 2010-04-13T20:38:00.000 | 1 | 1.2 | true | 2,633,029 | 0 | 0 | 1 | 1 | I am working on am Android Scripting Environment (ASE) script in Python to replicate an iPhone app.
I need a device UID of some sort. My thoughts where a salted MD5 hash of the MAC address or device phone number, but I can't figure out how to access either of those using the Python APIs within ASE.
What can I do to create a UID in Python in ASE? |
Installing a Python program on Linux | 2,636,146 | 1 | 8 | 4,519 | 0 | python,linux | You could create an rpm easily using checkinstall. Search for checkinstall in google and download it. It will allow you to create an rpm and set the options. | 0 | 1 | 0 | 0 | 2010-04-14T06:57:00.000 | 4 | 0.049958 | false | 2,635,433 | 1 | 0 | 0 | 1 | I wrote a Python program. I would like to add to it an installation script that will set up everything necessary - like desktop icon, entry in the menu, home directory file, etc.
I'm working on Linux (ubuntu). When a Python program is installed, what needs to happen in general? I know that it probably depends on the nature of the program.
Can you give me some general ideas? Or, point me in the right direction? I have no idea how to look for this on Google.
Thanks |
google app engine error ,and i can't open it now.(python) | 34,367,657 | 0 | 6 | 6,342 | 0 | python,google-app-engine | Not enough points to provide a comment on the answers above hence the stand alone answer. If you delete the ini files as per the other answers the pathways to your projects in the launcher will likely also be gone. In my case however I simply moved the ini files out of the C:\Users\your username\Google directory and then after opening and closing the launcher successfully once I reinstated the ini files into the Google directory again, after which the launcher worked and the project pathways were retained. | 0 | 1 | 0 | 0 | 2010-04-15T06:03:00.000 | 5 | 0 | false | 2,643,081 | 0 | 0 | 1 | 3 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? |
google app engine error ,and i can't open it now.(python) | 31,897,510 | 3 | 6 | 6,342 | 0 | python,google-app-engine | Solution:
Note: The wrong directories are stated above.
Go to C:\Users\your username\Google directory.
Delete google_appengine_launcher.ini and google_appengine_projects.ini
Appengine should now start successfully, absent error message. | 0 | 1 | 0 | 0 | 2010-04-15T06:03:00.000 | 5 | 0.119427 | false | 2,643,081 | 0 | 0 | 1 | 3 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? |
google app engine error ,and i can't open it now.(python) | 17,596,077 | 2 | 6 | 6,342 | 0 | python,google-app-engine | yeah just like RyanW mentioned the link, Delete the .ini files viz. google_appengine_launcher.ini & google_appengine_projects.ini in the user Directory in folder named Google. | 0 | 1 | 0 | 0 | 2010-04-15T06:03:00.000 | 5 | 0.07983 | false | 2,643,081 | 0 | 0 | 1 | 3 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? |
google app engine persistent globals | 2,650,039 | 6 | 1 | 595 | 0 | python,database,google-app-engine,global | The datastore is the only place you can have guaranteed-persistent data that are also modifiable. So you can have a single large object, or several smaller ones (with a name attribute and others), depending on your desired access patterns -- but live in the datastore it must. You can use memcache for faster cache that usually persists across queries, but any memcache entry could go away any time, so you'll always need it to be backed by the datastore (in particular, any change must go to the datastore, not just to memcache). | 0 | 1 | 0 | 0 | 2010-04-16T01:21:00.000 | 1 | 1.2 | true | 2,650,014 | 0 | 0 | 1 | 1 | I'm looking for a way to keep the equivalent of persistent global variables in app engine (python). What I'm doing is creating a global kind that I initialize once (i.e. when I reset all my database objects when I'm testing). I have things in there like global counters, or the next id to assign certain kinds I create.
Is this a decent way to do this sort of thing or is there generally another approach that is used? |
MySQL to AppEngine | 2,662,880 | 0 | 0 | 1,278 | 1 | python,mysql,google-app-engine,bulk-load | If you're using Pentaho BI Server as your data source, why don't you consider using Pentaho Data Integration (ETL tool) to move the data over? At the very least PDI automate any movement of data between your data source and any AppEngine bulk loader tool (it can easily trigger any app with a shell step). | 0 | 1 | 0 | 0 | 2010-04-16T03:57:00.000 | 3 | 0 | false | 2,650,499 | 0 | 0 | 1 | 1 | I'm from Brazil and study at FATEC (college located in Brazil).
I'm trying to learn about AppEngine.
Now, I'm trying to load a large database from MySQL to AppEngine to perform some queries, but I don't know how i can do it. I did some testing with CSV files,but is there any way to perform the direct import from MySQL?
This database is from Pentaho BI Server (www.pentaho.com).
Thank you for your attention.
Regards,
Daniel Naito |
ungetc in Python | 2,878,464 | 0 | 2 | 2,250 | 0 | python,readline,readlines,ungetc | The question was initially prompted by my need to build a lexical analyzer.
getc() and ungetc() are useful at first (to get the read bugs out the way and
to build the state machine) After the state machine is done,
getc() and ungetc() become a liability as they take too long to read
directly from storage.
When the state machine was complete (debugged any IO problems,
finalized the states), I optimized the lexical analyzer.
Reading the source file in chunks (or pages) into memory and running
the state machine on each page yields the best time result.
I found that considerable time is saved if getc() and ungetc() are not used
to read from the file directly. | 0 | 1 | 0 | 0 | 2010-04-16T19:32:00.000 | 6 | 0 | false | 2,655,643 | 1 | 0 | 0 | 1 | Some file read (readlines()) functions in Python
copy the file contents to memory (as a list)
I need to process a file that's too large to
be copied in memory and as such need to use
a file pointer (to access the file one byte
at a time) -- as in C getc().
The additional requirement I have is that
I'd like to rewind the file pointer to previous
bytes like in C ungetc().
Is there a way to do this in Python?
Also, in Python, I can read one line at a
time with readline()
Is there a way to read the previous line
going backward? |
In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac) | 2,660,314 | 1 | 4 | 3,985 | 0 | python,scripting,drag-and-drop,arguments | This really is independent of python. It depends entirely on which file browser you're using and how it supports drag and drop. | 0 | 1 | 0 | 0 | 2010-04-17T22:24:00.000 | 3 | 0.066568 | false | 2,660,291 | 0 | 0 | 0 | 2 | I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.
I've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard.
Any help is much appreciated.
Thanks! |
In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac) | 2,660,293 | 1 | 4 | 3,985 | 0 | python,scripting,drag-and-drop,arguments | Usually when you drag a file onto a script/executable, the OS passes the path to that file as a command-line argument. Check sys.argv | 0 | 1 | 0 | 0 | 2010-04-17T22:24:00.000 | 3 | 0.066568 | false | 2,660,291 | 0 | 0 | 0 | 2 | I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.
I've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard.
Any help is much appreciated.
Thanks! |
How can I implement "real time" messaging on Google AppEngine? | 2,660,540 | 1 | 3 | 554 | 0 | javascript,python,google-app-engine,comet | The App Engine roadmap has Comet support, otherwise you will have some difficulty achieving this. | 0 | 1 | 0 | 0 | 2010-04-17T22:31:00.000 | 3 | 0.066568 | false | 2,660,316 | 0 | 0 | 1 | 1 | I'm creating a web application on Google AppEngine where I want the user to be notified a quickly as possible after certain events occour. The problem is similar to say a chat server in that I need something happening on one connection (someone is writing a message in a chat room) to propagate to a number of other connections (other people in that chat room gets the message). To get speedy updates from the server to the client I'm planning on using long polling with XmlHttpRequest, hoping that AppEngine won't interfere other than possibly restriing the timeout. The real problem however is efficient notification between connections on AppEngine.
Is there any support for this type of cross connection notification on AppEngine that does not involve busy-waiting? The only tools I can think of to do this at all is either using the data storage (slow) or memcache (unreliable), and none of them would let me avoid busy-waiting.
Note: I know about XMPP support on AppEngine. It's related, but I want a browser based solution, sending messages to the users by XMPP is not an option. |
Python run command line (time) | 5,870,949 | 0 | 1 | 1,310 | 0 | python,command-line,time | You can use the timeit module to time code snippets (say, a function that launches external commands using subprocess module as described in the answer above) and save the data to a csv file. You can do statistics on the csv data using a stats module or externally using Excel/ LogParser/ R etc.
Another approach is to use the hotshot profiler that does the profiling and also returns stats that you can either print using print_stats() method or save to a file by iterating over. | 0 | 1 | 0 | 0 | 2010-04-18T15:57:00.000 | 2 | 0 | false | 2,662,852 | 0 | 0 | 0 | 1 | I want to run the 'time' unix command from a Python script, to time the execution of a non Python app. I would use the os.system method.
Is there any way to save the output of this in Python? My goal is to run the app several times, save their execution times and then do some statistics on them.
Thank You |
Configuration files for C in linux | 2,667,907 | 1 | 2 | 828 | 0 | python,c,linux,gcc,lua | How much configuration do you need that it needs to be a "script file"?
I just keep a little chunk of code handy that's a ini format parser. | 0 | 1 | 0 | 1 | 2010-04-19T13:49:00.000 | 7 | 0.028564 | false | 2,667,866 | 0 | 0 | 0 | 2 | I have an executable that run time should take configuration parameters from a script file. This way I dont need to re-compile the code for every configuration change. Right now I have all the configuration values in a .h file. Everytime I change it i need to re-compile.
The platform is C, gcc under Linux.
What is the best solution for this problem? I looked up on google and so XML, phthon and Lua bindings for C. Is using a separate scripting language the best approach? If so, which one would you recommend for my need?
Addendum:
What if I would like to mirror data structures in script files? If I have an array of structures for example, if there an easy way to store and load it?
Thanks |
Configuration files for C in linux | 2,667,901 | 0 | 2 | 828 | 0 | python,c,linux,gcc,lua | You could reread the configuration file when a signal such as SIGUSR1 is received. | 0 | 1 | 0 | 1 | 2010-04-19T13:49:00.000 | 7 | 0 | false | 2,667,866 | 0 | 0 | 0 | 2 | I have an executable that run time should take configuration parameters from a script file. This way I dont need to re-compile the code for every configuration change. Right now I have all the configuration values in a .h file. Everytime I change it i need to re-compile.
The platform is C, gcc under Linux.
What is the best solution for this problem? I looked up on google and so XML, phthon and Lua bindings for C. Is using a separate scripting language the best approach? If so, which one would you recommend for my need?
Addendum:
What if I would like to mirror data structures in script files? If I have an array of structures for example, if there an easy way to store and load it?
Thanks |
limits of number of files in a single directory in unix/linux using Python | 2,671,814 | 0 | 2 | 1,814 | 0 | python,linux,unix,file-io,cluster-computing | My suggestion is to use nested directory structure (ie categorization). You can name them using timestamps, special prefixes for each application etc. This gives you a sense of order when you need to search for specific files and for easier management of your files. | 0 | 1 | 0 | 0 | 2010-04-20T00:14:00.000 | 3 | 0 | false | 2,671,743 | 0 | 0 | 0 | 1 | is it bad to output many files to the same directory in unix/linux? I run thousands of jobs on a cluster and each outputs a file, to one directory. The upper bound here is around ~50,000 files. Can IO be limited in speed in light of this? If so, does the problem go away with a nested directory structure?
Thanks. |
How can I get mounted name and (Drive letter too) on Windows using python | 2,966,131 | 0 | 1 | 3,599 | 0 | python,daemon,mount,iso | adding newtover, getting list of drives from wmi console output
[i.strip() for i in os.popen('wmic logicaldisk get Name').readlines() if i.strip()<>''][1:] | 0 | 1 | 0 | 0 | 2010-04-20T07:10:00.000 | 3 | 0 | false | 2,673,236 | 0 | 0 | 0 | 2 | I am using Daemon tool to mount an ISO image on Windows XP machine.I do mount using Daemon command (daemon.exe -mount 0,iso_path).
Above command will mount ISO image to device number. In my case I have 4 partition (C,D,E,F) and G for DVD/CD-RW. Now what happen, ISO gets mounted to drive letter 'H:' with name (as defined while creating ISO) say 'testmount'.
My queries:-
1) How can I get mount name of mounted ISO image (i.e. 'testmount').
Just another case; if there are already some mount points existing on machine and I created a new one using Daemon tool. Then If I can get latest one using script that will be great.
2) How to get drive letter where it did get mounted.
If anyone know python script or command (or even Win command ) to get these info. do let me know.
Thanks... |
How can I get mounted name and (Drive letter too) on Windows using python | 2,673,526 | 1 | 1 | 3,599 | 0 | python,daemon,mount,iso | The daemon tools exe itself has some command line parameters :
-get_count and -get_letter
But for me these do not work in the latest version (DLite).
Instead you can use the commands :
mountvol - lists all the mounted drives
dir - you can parse the output to get the volume label
What you should do is run mountvol before daemon, and after, so you can detect the new drive letter. After that use "dir" to get the volume label.
I believe you can run these commands using the os.system() call in python | 0 | 1 | 0 | 0 | 2010-04-20T07:10:00.000 | 3 | 0.066568 | false | 2,673,236 | 0 | 0 | 0 | 2 | I am using Daemon tool to mount an ISO image on Windows XP machine.I do mount using Daemon command (daemon.exe -mount 0,iso_path).
Above command will mount ISO image to device number. In my case I have 4 partition (C,D,E,F) and G for DVD/CD-RW. Now what happen, ISO gets mounted to drive letter 'H:' with name (as defined while creating ISO) say 'testmount'.
My queries:-
1) How can I get mount name of mounted ISO image (i.e. 'testmount').
Just another case; if there are already some mount points existing on machine and I created a new one using Daemon tool. Then If I can get latest one using script that will be great.
2) How to get drive letter where it did get mounted.
If anyone know python script or command (or even Win command ) to get these info. do let me know.
Thanks... |
How does Dropbox use Python on Windows and OS X? | 2,679,695 | 36 | 40 | 18,000 | 0 | python,windows,macos,dropbox | Dropbox uses a combination of wxPython and PyObjC on the Mac (less wxPython in the 0.8 series). It looks like they've built a bit of a UI abstraction layer but nothing overwhelming—i.e., they're doing their cross-platform app the right way.
They include their own Python mainly because the versions of Python included on the Mac vary by OS version (and Dropbox supports back to 10.4 IIRC); also, they've customized the Python interpreter a bit to improve threading and I/O behavior.
(I do not work for Dropbox or have any inside knowledge; all I did was read their forums and examine the filenames in site-packages.zip in the Dropbox app bundle.) | 0 | 1 | 0 | 0 | 2010-04-20T19:53:00.000 | 6 | 1.2 | true | 2,678,180 | 0 | 0 | 0 | 3 | In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me. |
How does Dropbox use Python on Windows and OS X? | 2,678,789 | 5 | 40 | 18,000 | 0 | python,windows,macos,dropbox | Indeed they do bundle their own Python 2.5.4 interpreter found at /Applications/Dropbox.app/Contents/MacOS/python. Poking around in /Applications/Dropbox.app/Contents/Resources/lib/python2.5/lib-dynload it looks to be bundled by PyObjC.
I'm no authority on this, but it seems it is exactly as you suggest in the OP:
My guess is they are using a common
library they have written then just
have to use different hooks for the
different platforms | 0 | 1 | 0 | 0 | 2010-04-20T19:53:00.000 | 6 | 0.16514 | false | 2,678,180 | 0 | 0 | 0 | 3 | In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me. |
How does Dropbox use Python on Windows and OS X? | 2,678,719 | 4 | 40 | 18,000 | 0 | python,windows,macos,dropbox | Python25.dll is probably not their application code, it is a dll containing a copy of the python interpreter which can be called from within a windows application. Those pyc files are probably there in some form on windows, but they might be in an archive or obfuscated.
Python is included in OS/X, so it would be possible for them to execute those pyc file without shipping a python, but would not be surprised if they have there own python version lurking in the app bundle.
I don't know how dropbox builds there distributions, but there are several tools to bundle python apps into executable packages. Take a look at py2exe, py2app, and or cx_freeze. | 0 | 1 | 0 | 0 | 2010-04-20T19:53:00.000 | 6 | 0.132549 | false | 2,678,180 | 0 | 0 | 0 | 3 | In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me. |
Calling another process from python/child process need to access shell | 5,010,678 | 0 | 0 | 524 | 0 | c++,python,c,unix,subprocess | The best way is probably to use a TCP connection to localhost. If you are using a *nix, you can probably do it by opening a temporary file and polling it from the host application. | 0 | 1 | 0 | 0 | 2010-04-21T13:53:00.000 | 2 | 0 | false | 2,683,491 | 0 | 0 | 0 | 1 | I'm calling a C/C++ program from python with Popen, python code should observe behavior of child process and collect some data for his own work.
Problem is that C code already uses pipes for calling some shell commands - so after my execution from python, C program cannot execute bash shell command.
Is there any way in calling from Popen to specify that, child process should execute his own pipe command in shell???
I tried with shell=True, but doesn't help! |
On App Engine, what does optimization for reads mean? | 2,694,726 | 0 | 1 | 115 | 0 | python,google-app-engine | "Optimize for reads, not writes" means that you should expect to see far more reads than writes, and so you should strive to make it as easy as possible to read your data, even if that might slow down the writes a little. Easy for the computer, that is, meaning that for example if you want to show names in all lowercase, you should lowercase them when they're written to the database rather than lowercasing them everytime you read them from the database. That's just an example but hopefully it makes things clear. | 0 | 1 | 0 | 0 | 2010-04-22T21:11:00.000 | 3 | 0 | false | 2,694,542 | 0 | 0 | 1 | 2 | In the documentation for Google App Engine, it says that when designing data models for the datastore, you should "optimize for reads, not writes". What exactly does this mean? What is more 'expensive', CPU intensive or time consuming? |
On App Engine, what does optimization for reads mean? | 2,695,382 | 0 | 1 | 115 | 0 | python,google-app-engine | agreed with @redtuna (expecting more reads than writes) and @Ilian Iliev (reads cheaper than writes & writes take more resources). another way you can optimize for reads is by using the Memcache service. since reads (usually) happen more often than writes, caching that data means that you don't even have to take a hit of a datastore access. also, items that stay active (see fetches/hits) stay in the cache longer as it employs an LRU strategy. | 0 | 1 | 0 | 0 | 2010-04-22T21:11:00.000 | 3 | 0 | false | 2,694,542 | 0 | 0 | 1 | 2 | In the documentation for Google App Engine, it says that when designing data models for the datastore, you should "optimize for reads, not writes". What exactly does this mean? What is more 'expensive', CPU intensive or time consuming? |
Installing dateutils on OS X. How can I install to a different version of Python | 2,697,945 | 1 | 5 | 8,199 | 0 | python,macos | What version of Mac OS X are you using, what is your PATH, and did you install the other version of Python using MacPython, or did you install it via MacPorts? On Mac OS X 10.6 Snow Leopard, the following
command works just fine at installing dateutils in the system's version of Python.
sudo easy_install -O2 dateutils
Note, though, that if your second installation of Python also has a copy of the setuptools installed, and if that version's easy_install utility overshadows the default in the PATH, then this will install to the other Python. | 0 | 1 | 0 | 0 | 2010-04-23T10:53:00.000 | 3 | 0.066568 | false | 2,697,920 | 1 | 0 | 0 | 1 | I am trying to install dateutils on OS X 10.6. When I run python setup.py install it installs fine but to the Python 2.6 directory. I need to use Python 2.5 which is the "default" python version. By this I mean that when I run python from the command line it loads Python 2.5.4.
Is there a way to install modules to specific versions of Python. I have not had a problem like this before as normally it installs to the version of Python I have set as default. |
Dropping Root Permissions In Python | 8,189,175 | 5 | 47 | 18,944 | 0 | python,linux,unix,permissions,root | systemd can do it for you, if you start your program through systemd, systemd can hand off the already-open listening socket to it, and it can also activate your program on first connection. and you don't even need to daemonize it.
If you are going to go with the standalone approach, you need the capability CAP_NET_BIND_SERVICE (check capabilities man page). This can be done on a program-by-program basis with the correct command line tool, or by making your application (1) be suid root (2) start up (3) listen to the port (4) drop privileges / capabilities immediately.
Remember that suid root programs come with lots of security considerations (clean and secure environment, umask, privileges, rlimits, all those things are things that your program is going to have to set up correctly). If you can use something like systemd, all the better then. | 0 | 1 | 0 | 0 | 2010-04-23T15:40:00.000 | 6 | 0.16514 | false | 2,699,907 | 0 | 0 | 0 | 1 | I'd like to have a Python program start listening on port 80, but after that execute without root permissions. Is there a way to drop root or to get port 80 without it? |
Read streaming input from subprocess.communicate() | 2,715,887 | 3 | 90 | 94,340 | 0 | python,subprocess | If you want a non-blocking approach, don't use process.communicate(). If you set the subprocess.Popen() argument stdout to PIPE, you can read from process.stdout and check if the process still runs using process.poll(). | 0 | 1 | 0 | 0 | 2010-04-26T18:23:00.000 | 7 | 0.085505 | false | 2,715,847 | 1 | 0 | 0 | 1 | I'm using Python's subprocess.communicate() to read stdout from a process that runs for about a minute.
How can I print out each line of that process's stdout in a streaming fashion, so that I can see the output as it's generated, but still block on the process terminating before continuing?
subprocess.communicate() appears to give all the output at once. |
Schedule Python Script - Windows 7 | 5,314,695 | 52 | 46 | 76,799 | 0 | python,windows,scheduled-tasks | You can use the GUI from the control panel (called "scheduled tasks") to add a task, most of it should be self-explanatory, but there are two things to watch out for:
Make sure you fill in C:\python27\python.exe as the program path, and the path to your script as the argument.
If you choose Run whether user is logged on or not I get an error: The directory name is invalid (0x87010B). Choosing Run only when user is logged on "solves" this issue.
This took me quite a bit to figure out ... | 0 | 1 | 0 | 0 | 2010-04-27T23:00:00.000 | 3 | 1 | false | 2,725,754 | 1 | 0 | 0 | 1 | I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way? |
How do I stop Python install on Mac OS X from putting things in my home directory? | 2,727,510 | 1 | 0 | 819 | 0 | python,macos,installation,configure | In general, installing Python (or anything directly from the source) when it is already available on your system or when there are package managers that will install it for you, is not a very good idea. I strongly advise you against installing Python manually... Mac OS X 10.6 Snow Leopard comes with Python 2.6 out of the box; if you want a newer version of Python 2.6, then you should install MacPorts, and use:
sudo port install python26 python_select
You can then use the python_select to toggle between the system's version and MacPort's version.
If you are determined to install manually from the source, though, the way to do it would be to run "make distclean" (or untar the code separately again), then run "./configure --help" for a full list of configuration options. It is possible that on Mac OS X, it defaults to something other than /usr/local, in which case you could force it to install in that location by invoking configure with "./configure --prefix=/usr/local". | 0 | 1 | 0 | 0 | 2010-04-28T07:11:00.000 | 3 | 0.066568 | false | 2,727,438 | 1 | 0 | 0 | 2 | I'm trying to install Python from source on my Mac. (OS X 10.6.2, Python-2.6.5.tar.bz2) I've done this before and it was easy, but for some reason, this time after ./configure, and make, the sudo make install puts things some things in my home directory instead of in /usr/local/... where I expect. The .py files are okay, but not the .so files...
RobsMac Python-2.6.5 $ sudo make install
[...]
/usr/bin/install -c -m 644 ./Lib/anydbm.py /usr/local/lib/python2.6
/usr/bin/install -c -m 644 ./Lib/ast.py /usr/local/lib/python2.6
/usr/bin/install -c -m 644 ./Lib/asynchat.py /usr/local/lib/python2.6
[...]
running build_scripts
running install_lib
creating /Users/rob/Library/Python
creating /Users/rob/Library/Python/2.6
creating /Users/rob/Library/Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_AE.so -> /Users/rob/Library/
Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_AH.so -> /Users/rob/Library/
Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_App.so -> /Users/rob/Library/
Python/2.6/site-packages
[...]
Later, this causes imports that require those .so files to fail. For
example...
RobsMac Python-2.6.5 $ python
Python 2.6.5 (r265:79063, Apr 28 2010, 13:40:18)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named zlib
Any ideas what is wrong?
thanks,
Rob |
How do I stop Python install on Mac OS X from putting things in my home directory? | 2,727,917 | 2 | 0 | 819 | 0 | python,macos,installation,configure | Doh. I've answered my own question. Recently I created a ~/.pydistutils.cfg file, for some stupid reason. I forgot to delete that file. It's contents were:
[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin
make install calls setup.py, and this file was overriding the normal setup.py behavior.
Rob | 0 | 1 | 0 | 0 | 2010-04-28T07:11:00.000 | 3 | 1.2 | true | 2,727,438 | 1 | 0 | 0 | 2 | I'm trying to install Python from source on my Mac. (OS X 10.6.2, Python-2.6.5.tar.bz2) I've done this before and it was easy, but for some reason, this time after ./configure, and make, the sudo make install puts things some things in my home directory instead of in /usr/local/... where I expect. The .py files are okay, but not the .so files...
RobsMac Python-2.6.5 $ sudo make install
[...]
/usr/bin/install -c -m 644 ./Lib/anydbm.py /usr/local/lib/python2.6
/usr/bin/install -c -m 644 ./Lib/ast.py /usr/local/lib/python2.6
/usr/bin/install -c -m 644 ./Lib/asynchat.py /usr/local/lib/python2.6
[...]
running build_scripts
running install_lib
creating /Users/rob/Library/Python
creating /Users/rob/Library/Python/2.6
creating /Users/rob/Library/Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_AE.so -> /Users/rob/Library/
Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_AH.so -> /Users/rob/Library/
Python/2.6/site-packages
copying build/lib.macosx-10.4-x86_64-2.6/_App.so -> /Users/rob/Library/
Python/2.6/site-packages
[...]
Later, this causes imports that require those .so files to fail. For
example...
RobsMac Python-2.6.5 $ python
Python 2.6.5 (r265:79063, Apr 28 2010, 13:40:18)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named zlib
Any ideas what is wrong?
thanks,
Rob |
how to create application(exe) from python script for linux | 2,728,373 | 0 | 1 | 557 | 0 | python | I think any modern Linux OS has Python installed, so you can just ditribute the .py file if it has no weird dependencies. | 0 | 1 | 0 | 0 | 2010-04-28T09:40:00.000 | 3 | 0 | false | 2,728,289 | 0 | 0 | 0 | 2 | i'm newbie for python programming, i'm having a .py file, now what shall i do so i can create an application from .py file and it can be istall and run in any linux pc, i try to packaging it but its just create .tar file where i need python to run it, is it any to do so,
thanks |
how to create application(exe) from python script for linux | 2,728,622 | 2 | 1 | 557 | 0 | python | Make sure that the main python file has #! /usr/bin/env python as the first line, then make sure it has execute permission set (should be as easy as chmod +x file_name.py). | 0 | 1 | 0 | 0 | 2010-04-28T09:40:00.000 | 3 | 0.132549 | false | 2,728,289 | 0 | 0 | 0 | 2 | i'm newbie for python programming, i'm having a .py file, now what shall i do so i can create an application from .py file and it can be istall and run in any linux pc, i try to packaging it but its just create .tar file where i need python to run it, is it any to do so,
thanks |
Having my Python package install shortcuts in Start menu | 2,734,263 | 0 | 6 | 2,198 | 0 | python,installation,setuptools | Since setuptools doesn't seem to give an easy solution to this, I've decided to give up on this idea until I release my app with py2exe/InnoSetup. | 0 | 1 | 0 | 0 | 2010-04-28T16:58:00.000 | 5 | 0 | false | 2,731,545 | 1 | 0 | 0 | 1 | I'm making a Python package that gets installed with a setup.py file using setuptools.
The package includes a GUI, and when it's installed on a Windows machine, I want the installation to make a folder in "Programs" in the start menu, and make a shortcut there to a pyw script that will start the GUI. (The pyw think works on all platforms, right?)
On Mac and Linux, I would like it to put this shortcut in whatever Mac and Linux have that is parallel to the start menu.
How do I do this? |
Is there anyway to get pdb and Mac Terminal to play nicely? | 2,745,035 | 8 | 9 | 1,601 | 0 | python,django,macos,terminal,pdb | OK - this works for me I created a ~/.pdbrc and added
import os
os.system("stty sane")
Now each time pdb is run it sets the line settings back to sane.
If I fall out to the terminal then I still have to do it manually - but it solves having to quit runserver and reset all the time. | 0 | 1 | 0 | 0 | 2010-04-29T08:34:00.000 | 3 | 1.2 | true | 2,735,828 | 0 | 0 | 1 | 2 | When debugging my django apps I use pdb for interactive debugging with pdb.set_trace().
However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset.
Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard). |
Is there anyway to get pdb and Mac Terminal to play nicely? | 2,743,003 | 1 | 9 | 1,601 | 0 | python,django,macos,terminal,pdb | The best I've found is doing a reset inside pdb like so:
import os; os.system("reset"); | 0 | 1 | 0 | 0 | 2010-04-29T08:34:00.000 | 3 | 0.066568 | false | 2,735,828 | 0 | 0 | 1 | 2 | When debugging my django apps I use pdb for interactive debugging with pdb.set_trace().
However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset.
Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset and restart it all the time. I'm told it doesn't happen on other OS's (ubuntu) so is there anyway to make it not happen on the Mac? (I'm using Snow Leopard). |
How to get debugging of an App Engine application working? | 2,735,992 | 1 | 3 | 865 | 0 | python,eclipse,debugging,google-app-engine,pydev | In fact setting a breakpoint in eclipse is very easy. You have two options:
In the grey area next to your line numbers, doubleclick or right mouseclick -> toggle breakpoint. | 0 | 1 | 0 | 0 | 2010-04-29T09:00:00.000 | 1 | 1.2 | true | 2,735,968 | 0 | 0 | 1 | 1 | I've got 10+ years in C/C++, and it appears Visual Studio has spoilt me during that time. In Visual Studio, debbuging issimple: I just add a breakpoint to a line of code, and as soon as that code is executed, my breakpoint triggers, at which point I can view a callstack, local/member variables, etc.
I'm trying to achieve this functionality under App Engine. I assume that is possible?
All the searching I've done to this point has led me to using Pydev in Eclipse. As best I can tell, I am successfully launching my simple 'hello world' program in Debug mode.
But the IDE doesn't even seem to have an option to set a breakpoint? I must be missing something.
I've googled long and hard about this, but am having no luck. Most results trace back to the same old threads that don't deal directly with my issue.
Can anyone shed some light on how you get basic debugging setup using Pydev/Eclipse with App Engine?
Alternatively, if there's an easier way to debug App Engine than using Pydev/Eclipse, I'd love to hear about it.
Thanks in advance. |
access a file in python that is created from SunGridEngine | 3,821,879 | 0 | 0 | 52 | 0 | python,sungridengine | created a sleep timer which checks every second for access..
after some time (~15s), access is granted and file is usable! | 0 | 1 | 0 | 0 | 2010-04-29T14:49:00.000 | 1 | 1.2 | true | 2,738,290 | 0 | 0 | 0 | 1 | i have a python script, that submits an job to the SGE (Sun Grid Engine).
When the job is done i want to access the output file, generated from the SGE job.
i see with "ls" in the directory that the file is already existing and the job is done, but python needs about 20-30 seconds to get access to that file...
is there a way to detect new created files faster ??
my problem is to differ between "need time to access the file" or "file is not existing"
i tried:
os.path.exist(path)
os.access(path,os.R_OK)
does not solve my problem =( |
What's the equivalence of os.fork() on Windows with Python? | 52,476,456 | 5 | 4 | 18,954 | 0 | python,fork | The answer here may not answer the question. The problem is due to fork(). From the example, you seemed want to share data between two Python scripts. Let me explain my view.
As of Python 3.8, there is no true Unix's fork() implementation in Windows platform. For the example above to work, a child process must inherit all environment and open file descriptors.
I understand that Windows now support Windows Linux Subsystem, but the last i checked it still does not fully implement fork. Cygwin does actually but it is a bit slow.
I do not know how, until now, to pass information between two Python scripts using mmap in Windows platform. Use
multiprocessing.Queue or
multiprocessing.Pipe or
multiprocessing.Manager or
multiprocessing's shared memory (Value and Array) instead.
I believe you could make each Python script to read in content of the to-be-mapped file into Array of characters. Then use your own structure to map the shared memory into a structured data as you do for the to-be-mapped file. | 0 | 1 | 0 | 0 | 2010-04-29T15:59:00.000 | 2 | 0.462117 | false | 2,738,809 | 1 | 0 | 0 | 1 | This code works well in Mac/Linux, but not in Windows.
import mmap
import os
map = mmap.mmap(-1, 13)
map.write("Hello world!")
pid = os.fork()
if pid == 0: # In a child process
print 'child'
map.seek(0)
print map.readline()
map.close()
else:
print 'parent'
What's the equivalent function of os.fork() on Windows? |
Location of global libraries for Python on Mac? | 6,278,976 | 11 | 29 | 107,907 | 0 | python,macos,configuration,python-sip | /Library/Python/2.6/site-packages/ is indeed the right place (assuming it's Mac OS 10.6 "Snow Leopard" - you didn't mention which).
As @diatoid mentioned, check your system path (and make sure you're actually using Python 2.6 by running python -V). | 0 | 1 | 0 | 0 | 2010-04-29T23:53:00.000 | 5 | 1 | false | 2,741,496 | 1 | 0 | 0 | 3 | I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig.
My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work. |
Location of global libraries for Python on Mac? | 45,022,496 | 11 | 29 | 107,907 | 0 | python,macos,configuration,python-sip | For Python 3.5, It's /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages | 0 | 1 | 0 | 0 | 2010-04-29T23:53:00.000 | 5 | 1 | false | 2,741,496 | 1 | 0 | 0 | 3 | I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig.
My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work. |
Location of global libraries for Python on Mac? | 65,916,097 | -1 | 29 | 107,907 | 0 | python,macos,configuration,python-sip | You can designate an additional locations when python starts up by setting the environmental variable PYTHONPATH.
If you add to ~/.bashrc or ~/.zscrc (depending on your default shell) something like:
PYTHONPATH=/Library/MyPyhonPackages:/Another/Location;
export PYTHONPATH
Then those locations will be added to "sys.path" whenever python starts up.
This will give you additional places to store your own packages or modules. | 0 | 1 | 0 | 0 | 2010-04-29T23:53:00.000 | 5 | -0.039979 | false | 2,741,496 | 1 | 0 | 0 | 3 | I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig.
My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work. |
A simple Python deployment problem - a whole world of pain | 2,743,196 | 2 | 20 | 5,069 | 0 | python,linux,deployment,pylons | Have a look at Buildout for reproducible deployments. | 0 | 1 | 0 | 0 | 2010-04-29T23:55:00.000 | 8 | 0.049958 | false | 2,741,507 | 0 | 0 | 1 | 2 | We have several Python 2.6 applications running on Linux. Some of them are Pylons web applications, others are simply long-running processes that we run from the command line using nohup. We're also using virtualenv, both in development and in production. What is the best way to deploy these applications to a production server?
In development we simply get the source tree into any directory, set up a virtualenv and run - easy enough. We could do the same in production and perhaps that really is the most practical solution, but it just feels a bit wrong to run svn update in production. We've also tried fab, but it just never works first time. For every application something else goes wrong. It strikes me that the whole process is just too hard, given that what we're trying to achieve is fundamentally very simple. Here's what we want from a deployment process.
We should be able to run one simple command to deploy an updated version of an application. (If the initial deployment involves a bit of extra complexity that's fine.)
When we run this command it should copy certain files, either out of a Subversion repository or out of a local working copy, to a specified "environment" on the server, which probably means a different virtualenv. We have both staging and production version of the applications on the same server, so they need to somehow be kept separate. If it installs into site-packages, that's fine too, as long as it works.
We have some configuration files on the server that should be preserved (ie. not overwritten or deleted by the deployment process).
Some of these applications import modules from other applications, so they need to be able to reference each other as packages somehow. This is the part we've had the most trouble with! I don't care whether it works via relative imports, site-packages or whatever, as long as it works reliably in both development and production.
Ideally the deployment process should automatically install external packages that our applications depend on (eg. psycopg2).
That's really it! How hard can it be? |
A simple Python deployment problem - a whole world of pain | 2,805,604 | 0 | 20 | 5,069 | 0 | python,linux,deployment,pylons | I would use rsync to synchronize outwards from your production "prime" server to the others, and from your "beta test" platform, to your production "prime" server.
rsync has the benefit of copying only those files which changed, and copying only parts of files that changed partially, and verifying the integrity and identical content at the end on all machines. An update that gets part way through and is interrupted can easily be continued later, making your deployment more robust.
Subversion or Mercurial would not be a bad idea in this case either. Mercurial has the
advantage of allowing you to "pull" or "push" instead of just updating from one central source. You might find interesting cases where a decentralized model (mercurial) works better. | 0 | 1 | 0 | 0 | 2010-04-29T23:55:00.000 | 8 | 0 | false | 2,741,507 | 0 | 0 | 1 | 2 | We have several Python 2.6 applications running on Linux. Some of them are Pylons web applications, others are simply long-running processes that we run from the command line using nohup. We're also using virtualenv, both in development and in production. What is the best way to deploy these applications to a production server?
In development we simply get the source tree into any directory, set up a virtualenv and run - easy enough. We could do the same in production and perhaps that really is the most practical solution, but it just feels a bit wrong to run svn update in production. We've also tried fab, but it just never works first time. For every application something else goes wrong. It strikes me that the whole process is just too hard, given that what we're trying to achieve is fundamentally very simple. Here's what we want from a deployment process.
We should be able to run one simple command to deploy an updated version of an application. (If the initial deployment involves a bit of extra complexity that's fine.)
When we run this command it should copy certain files, either out of a Subversion repository or out of a local working copy, to a specified "environment" on the server, which probably means a different virtualenv. We have both staging and production version of the applications on the same server, so they need to somehow be kept separate. If it installs into site-packages, that's fine too, as long as it works.
We have some configuration files on the server that should be preserved (ie. not overwritten or deleted by the deployment process).
Some of these applications import modules from other applications, so they need to be able to reference each other as packages somehow. This is the part we've had the most trouble with! I don't care whether it works via relative imports, site-packages or whatever, as long as it works reliably in both development and production.
Ideally the deployment process should automatically install external packages that our applications depend on (eg. psycopg2).
That's really it! How hard can it be? |
virtualenv yolk problem | 2,744,571 | 18 | 11 | 2,679 | 0 | python,virtualenv,yolk | Activating a virtualenv works by changing your shell PATH so the virtualenv's bin/ directory is first. This is all it does. This means that when you run "python" it runs the virtualenv's copy of the Python binary instead of your global system python.
If you have yolk installed globally, however, the only "yolk" binary on your PATH is /usr/local/bin/yolk or some such; activating the virtualenv doesn't change this (because there's no "yolk" script in your virtualenv bin/ dir). And the /usr/local/bin/yolk script naturally has your system Python interpreter in its shebang line.
This is why installing yolk into the virtualenv fixes the problem; because it adds a yolk script in your virtualenv bin/ dir that has the virtualenv's python in its shebang line.
If you don't want to install yolk in each virtualenv, you could also just copy the yolk script-wrapper from /usr/local/bin or wherever it is into your virtualenv's bin dir, and manually change the shebang line to point to your virtualenv's python. This won't work with a --no-site-packages virtualenv, though, because the script wrapper then won't be able to find the actual yolk packages it needs to import! If you want to use yolk within a --no-site-packages virtualenv, really your only choice is to install it there. | 0 | 1 | 0 | 0 | 2010-04-30T07:37:00.000 | 2 | 1.2 | true | 2,742,980 | 1 | 0 | 0 | 2 | yolk -l gives me information that I've got 114 packages installed on my Ubuntu 10.04. After creating new virtualenv directory using
virtualenv virt_env/virt1 --no-site-packages --clear
I switched to that, my prompt changed and then yolk -l gives me again the same 114 packages.
What is going on there? |
virtualenv yolk problem | 3,081,902 | 0 | 11 | 2,679 | 0 | python,virtualenv,yolk | If the problem isnt relating to your path (I suppose it is) delete your lib and scripts folder in your project directory to clear out the virtualenv settings. Recreate the virtual env using the command line you posted. Activate the virtualenv and then install yolk. | 0 | 1 | 0 | 0 | 2010-04-30T07:37:00.000 | 2 | 0 | false | 2,742,980 | 1 | 0 | 0 | 2 | yolk -l gives me information that I've got 114 packages installed on my Ubuntu 10.04. After creating new virtualenv directory using
virtualenv virt_env/virt1 --no-site-packages --clear
I switched to that, my prompt changed and then yolk -l gives me again the same 114 packages.
What is going on there? |
MUD (game) design concept question about timed events | 2,748,104 | 4 | 4 | 1,814 | 0 | python,mud | MUDs actions are usually performed on 'ticks' rather than immediately - this allows for limited affect of latency and for monster's commands to be inserted in the queue and processed fairly.
Personally, I don't like this approach, but pretty much 99% of MUDs use it. You need to design a robust command queue & event queue which can handle both AI and user commands. You can then add "virtual latency" to AI commands which may be predefined or an average of all users latency, or whatever you like. | 0 | 1 | 0 | 0 | 2010-04-30T22:37:00.000 | 7 | 0.113791 | false | 2,748,084 | 0 | 0 | 0 | 5 | I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive? |
MUD (game) design concept question about timed events | 2,749,799 | 3 | 4 | 1,814 | 0 | python,mud | AI's are clients.
They're "part of the server" only in the most distant view. They're actually outside the main game engine. They're specialized clients with no human being.
An AI client has the same interface with the server that a human's client would. | 0 | 1 | 0 | 0 | 2010-04-30T22:37:00.000 | 7 | 0.085505 | false | 2,748,084 | 0 | 0 | 0 | 5 | I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive? |
MUD (game) design concept question about timed events | 4,190,774 | 2 | 4 | 1,814 | 0 | python,mud | You could use threads to handle specific types of Mobs, and put all the instances into an array of some sort. Then, the thread simply goes through the list repeatedly applying logic. DelayTimeStart and Delay could be attributes of the parent Mob class, and when the thread goes through the loop, it can put off processing any instances of the Mob in which there is time remaining in the delay. | 0 | 1 | 0 | 0 | 2010-04-30T22:37:00.000 | 7 | 0.057081 | false | 2,748,084 | 0 | 0 | 0 | 5 | I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive? |
MUD (game) design concept question about timed events | 4,879,667 | 0 | 4 | 1,814 | 0 | python,mud | A basic approach would be to have a data structure representing the evil monster's instance of its spell, with a cooldown timer on it. When the power is used, the cooldown is set (presumably to a number of seconds defined by the master definition of the spell); an attempt to use it again will fail just like with the player ability. This can be integrated with an event queue by having the queue check cooldown, and if it hasn't expired, to wait for it to expire, or abort the action, or reschedule the action, as appropriate. | 0 | 1 | 0 | 0 | 2010-04-30T22:37:00.000 | 7 | 0 | false | 2,748,084 | 0 | 0 | 0 | 5 | I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive? |
MUD (game) design concept question about timed events | 21,559,958 | 0 | 4 | 1,814 | 0 | python,mud | I'll provide you an answer from an LPMud/LDMud point of view.
Every player in the MUD is an instance of player.c. Player.c inherits from living.c. Things that are living have a heartbeat. The heartbeat function is processed once every 2 seconds for every living object on the mud (or anything that has a heartbeat() function). Timing events is not typically done based on seconds, but instead based on the number of heartbeats that have elapsed through counters within the object.
The wonderful news that applies to your question is that monsters also inherit from living.c. This means that if you had actions that can only be performed periodically this can all be managed within the heartbeat based on the number of ticks that have occurred. | 0 | 1 | 0 | 0 | 2010-04-30T22:37:00.000 | 7 | 0 | false | 2,748,084 | 0 | 0 | 0 | 5 | I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive? |
Google App Engine Python Unit Tests | 4,059,206 | 1 | 17 | 5,767 | 0 | python,unit-testing,google-app-engine | Since, gae is based on webhooks it can be easy to set your own testing framework for all relevant urls in your app.yaml. You can test it on sample dataset on development server ( start devel server with --datastore_path option ) and assert writes to database or webhook responses. | 0 | 1 | 0 | 1 | 2010-05-01T17:32:00.000 | 4 | 0.049958 | false | 2,750,911 | 0 | 0 | 1 | 1 | I'd like to write some Python unit tests for my Google App Engine. How can I set that up? Does someone happen to have some sample code which shows how to write a simple test? |
Validity of GUI design patterns under linux | 2,751,881 | 2 | 0 | 894 | 0 | python,ruby,linux,design-patterns,mvvm | Given how you explain your application in a comment, while fully endorsing Qt, I would also recommend you consider the many advantages that could come your way from making your application a web app.
Since you say it's a client-server app, it needs (at least) local network connectivity at least, so the first objection typically raised against web apps is nullified.
The first huge advantage is that you wouldn't be choosing one client platform vs another -- just support modern cross-platform browsers like Firefox or Google's Chrome, and your customers will be able to pick whatever client platform(s) they prefer (if you also carefully check your app on Safari, which has much rendering logic in common with Chrome via the Webkit framework, your web app will then be usable on iPad too).
The second big win is that your app won't require any "installation" on the client(s) -- it will always be ready.
Modern Javascript frameworks (such as jQuery, Dojo, Closure, ...) allow heavy interactivity if you need it, support GUI building with UI widgets &c, and incidentally take care of most cross-browser differences on your behalf. On the server side, with either Ruby or Python (or other languages yet), you can even find frameworks that smoothly integrate with the client-side Javascript resources.
Oh, and, the computational resources needed to run the application (such as RAM, CPU power, disk space, ...) are cheaper "in bulk" on a server, or small group of servers, and thus shared among those clients which are active at a given time, than spread out over many clients (including many who won't happen to be active at any givem time;-).
Really, in my opinion, there is little left today to recommend local GUI apps when you're developing anew anyway, save possibly the need to run when cut off from all connectivity (and, even there, with HTML5 and the like, browsers are making great strides towards empowering such apps). | 0 | 1 | 0 | 0 | 2010-05-01T21:11:00.000 | 5 | 0.07983 | false | 2,751,548 | 0 | 0 | 1 | 3 | I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world.
The application is a classic client server with detailed forms for each business entity.
It will be taking user input, do some validation checks, a few calculations, and save them to database.
It will also have lists summarizing entities, and searches among these entities.
A click to one item of these lists will open the detailled forms.
If i use python or ruby, what should i use for GUI ?
And what pattern : is MVC, MVVM or MVP any good ?
Or is there anything better ?
Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time. |
Validity of GUI design patterns under linux | 2,751,596 | 1 | 0 | 894 | 0 | python,ruby,linux,design-patterns,mvvm | The two main UI toolkits in Linux these days are Qt and GTK+. Qt is widely used by the KDE desktop, while GTK+ is widely used by Gnome. But a Qt app will run in Gnome and vise-versa. Both toolkits have bindings to a massive amount of languages. | 0 | 1 | 0 | 0 | 2010-05-01T21:11:00.000 | 5 | 0.039979 | false | 2,751,548 | 0 | 0 | 1 | 3 | I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world.
The application is a classic client server with detailed forms for each business entity.
It will be taking user input, do some validation checks, a few calculations, and save them to database.
It will also have lists summarizing entities, and searches among these entities.
A click to one item of these lists will open the detailled forms.
If i use python or ruby, what should i use for GUI ?
And what pattern : is MVC, MVVM or MVP any good ?
Or is there anything better ?
Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time. |
Validity of GUI design patterns under linux | 2,753,393 | 0 | 0 | 894 | 0 | python,ruby,linux,design-patterns,mvvm | Design (or architectural) patterns have nothing to do with the target programming language or operating system. Ook at you problem, if you can see you requirements which will be fulfilled by some solution provided by a pattern and the consequences will be good, jsut use the pattern. If you aks MVC, MVP, MVVM etc. look at those patterns and problems they solve and if it is what you need for you application, use them. | 0 | 1 | 0 | 0 | 2010-05-01T21:11:00.000 | 5 | 0 | false | 2,751,548 | 0 | 0 | 1 | 3 | I am investigating a switch from windows to linux and i struggle to find samples of design patterns applied in this world.
The application is a classic client server with detailed forms for each business entity.
It will be taking user input, do some validation checks, a few calculations, and save them to database.
It will also have lists summarizing entities, and searches among these entities.
A click to one item of these lists will open the detailled forms.
If i use python or ruby, what should i use for GUI ?
And what pattern : is MVC, MVVM or MVP any good ?
Or is there anything better ?
Note : I have never done web developpement, and i would like to avoid to have to learn both linux and web developpement at the same time. |
Appengine (python) returns empty for valid queries | 2,752,566 | 0 | 2 | 161 | 0 | python,google-app-engine | When this has happened to me it's because I've been using a TextField, which cannot be queried (but confusingly just gets ignored). Try switching to StringField. | 0 | 1 | 0 | 0 | 2010-05-02T00:10:00.000 | 1 | 0 | false | 2,752,008 | 0 | 0 | 1 | 1 | EDIT: Figured it out. For whatever reason the field in the index was called strWord instead of wordStr. I didn't notice because of the similarities. The file was auto generated, so I must have called the field that in a previous development version.
I've got an app with around half a million 'records', each of which only stores three fields. I'd like to look up records by a string field with a query, but I'm running into problems. If I visit the console page, manually view a record and save it (without making changes) it shows up in a query:
SELECT * FROM wordEntry WHERE wordStr = 'SomeString'
If I don't do this, I get 'no results'. Does appengine need time to update? If so, how much?
(I was also having trouble batch deleting and modifying data, but I was able to break the problem up into smaller chunks.) |
symlink files newer than X age, then later remove symlink once file ages? | 2,752,934 | 2 | 2 | 465 | 0 | python,linux,bash,unix,scripting | Use incron to create the symlink, then find -L in cron to break it. | 0 | 1 | 0 | 0 | 2010-05-02T08:56:00.000 | 2 | 0.197375 | false | 2,752,915 | 0 | 0 | 0 | 1 | i have a large number of files/folders coming in each day that are being sorted automatically to a wide variety of folders. I'm looking for a way to automatically find these files/folders and create symlinks to them all within an "incoming" folder. Searching for file age should be sufficient for finding the files, however searching for age and owner would be ideal. Then once the files/folders being linked to reach a certain age, say 5 days, remove the symlinks to them automatically from the "incoming" folder. Is this possible to do with a simple shell or python script that can be run with cron? Thanks! |
Google App Engine - Document Editor Creation/Tap Into Google Docs? | 2,758,807 | 2 | 1 | 655 | 0 | python,ajax,google-app-engine,tinymce,text-editor | It sounds to me like you want to use the Google Docs editor like a widget within your application. To the best of my knowledge you can't do this. | 0 | 1 | 0 | 0 | 2010-05-02T21:27:00.000 | 2 | 0.197375 | false | 2,755,069 | 0 | 0 | 1 | 1 | What is the best way to create a custom document editor in GAE? I'm making a website meant for a School Robotics Club (With support for any other organization - DRY).
We currently use Google services for online collaboration, I'm wondering if there is a way to tap into Google Docs and allow users to edit a Google Document without using Google Accounts or the Google Docs [EDIT]interface website[/EDIT].
If that is not possible (I've researched and I don't think it is), what is the best way to make a document editor? I want it completely on the website I'm creating, so I'm assuming just some javascript editor like TinyMCE + Ajax + Datastore. Is their anything that replicates Google Doc's/Microsoft Offices's/OpenOffice.org's feature set as far as fonts, spacing, alignment, justification, etc.? |
setfsuid() and python 2.5.4 | 2,758,136 | 2 | 0 | 454 | 0 | python,operating-system | The ability to change the FSUID is limited to either root or non-root processes with the CAP_SETFCAP capability. These days it's usually considered bad practice to run a webserver with root permissions so, most likely, you'll need to set the capability on the file server (see man capabilities for details). Please note that doing this could severly affect your overall system's security. I'd recommend considering spawning a small backend process that runs as root and converses with your WSGI app via a local UNIX socket prior to mucking with the security of a high-profile target like Apache. | 0 | 1 | 0 | 0 | 2010-05-03T12:33:00.000 | 1 | 0.379949 | false | 2,757,991 | 0 | 0 | 0 | 1 | I'm trying to use setfsuid() with python 2.5.4 and RHEL 5.4.
Since it's not included in the os module, I wrapped it in a C module of my own and installed it as a python extension module using distutils.
However when I try to use it I don't get the expected result.
setfsuid() returns value indicating success (changing from a superuser), but I can't access files to which only the newly set user should have user access (using open()), indicating that fsuid was not truely changed.
I tried to verify setfsuid() worked, by running it consecutively twice with the same user input
The result was as if nothing had changed, and on every call the returned value was of old user id different from the new one. I also called getpid() from the module, and from the python script, both returned the same id. so this is not the problem.
Just in case it's significant, I should note that I'm doing all of this from within an Apache daemon process (WSGI).
Anyone can provide an explanation to that?
Thank you |
how to kill (or avoid) zombie processes with subprocess module | 12,956,839 | 16 | 53 | 62,258 | 0 | python,subprocess | If you delete the subprocess object, using del to force garbage collection, that will cause the subprocess object to be deleted and then the defunct processes will go away without terminating your interpreter. You can try this out in the python command line interface first. | 0 | 1 | 0 | 0 | 2010-05-03T19:29:00.000 | 9 | 1 | false | 2,760,652 | 1 | 0 | 0 | 4 | When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process.
Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait(). |
how to kill (or avoid) zombie processes with subprocess module | 6,236,440 | 5 | 53 | 62,258 | 0 | python,subprocess | The python runtime takes responsibility for getting rid of zombie process once their process objects have been garbage collected. If you see the zombie lying around it means you have kept a process object and not called wait, poll or terminate on it. | 0 | 1 | 0 | 0 | 2010-05-03T19:29:00.000 | 9 | 0.110656 | false | 2,760,652 | 1 | 0 | 0 | 4 | When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process.
Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait(). |
how to kill (or avoid) zombie processes with subprocess module | 40,458,489 | 0 | 53 | 62,258 | 0 | python,subprocess | Recently, I came across this zombie problem due to my python script. The actual problem was mainly due to killing of the subprocess and the parent process doesn't know that the child is dead. So what I did was, just adding popen.communicate() after the kill signal of child process so that the parent process comes to know that the child is dead, then the kernel updates the pid of the childprocess since the child is no more and so there is no zombies formed now.
PS:poll is also an option here since it checks and conveys about the child status to the parent. Often in subprocess it is better if u use check_output or call if u need not communicate with the stdout and stdin. | 0 | 1 | 0 | 0 | 2010-05-03T19:29:00.000 | 9 | 0 | false | 2,760,652 | 1 | 0 | 0 | 4 | When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process.
Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait(). |
how to kill (or avoid) zombie processes with subprocess module | 64,438,478 | 1 | 53 | 62,258 | 0 | python,subprocess | Like this:
s = Popen(args)
s.terminate()
time.sleep(0.5)
s.poll()
it works
zombie processes will disappear | 0 | 1 | 0 | 0 | 2010-05-03T19:29:00.000 | 9 | 0.022219 | false | 2,760,652 | 1 | 0 | 0 | 4 | When I kick off a python script from within another python script using the subprocess module, a zombie process is created when the subprocess "completes". I am unable to kill this subprocess unless I kill my parent python process.
Is there a way to kill the subprocess without killing the parent? I know I can do this by using wait(), but I need to run my script with no_wait(). |
I am using Python on Windows. How do I delete my script after it is run? | 2,763,663 | 3 | 1 | 608 | 0 | python,windows,scripting | I think the easiest solution is make an external .bat file that executes your exe file and deletes it when finished. | 0 | 1 | 0 | 0 | 2010-05-04T07:26:00.000 | 1 | 1.2 | true | 2,763,541 | 1 | 0 | 0 | 1 | I have written a Python script and compiled it into a MS Windows EXE file. I can modify the code, but how do I make it remove itself after running? |
When deploying python, what web server options do we have? is the process inefficient at all? | 2,767,055 | 6 | 1 | 232 | 0 | python,webserver | You can still use CGI if you want, but the normal approach these days is using WSGI on the Python side, e.g. through mod_wsgi on Apache or via bridges to FastCGI on other web servers. At least with mod_wsgi, I know of no inefficiencies with this approach.
BTW, your description of CGI ("create a new thread for each process") is inaccurate: what it does is create a new process for each query's service (and that process typically needs to open a database connection, import all needed modules, etc etc, which is what may make it slow even on platforms where forking a process, per se, is pretty fast, such as all Unix variants). | 0 | 1 | 0 | 1 | 2010-05-04T16:16:00.000 | 3 | 1 | false | 2,767,013 | 1 | 0 | 0 | 1 | I think in the past python scripts would run off CGI, which would create a new thread for each process.
I am a newbie so I'm not really sure, what options do we have?
Is the web server pipeline that python works under any more/less effecient than say php? |
appscript on OSX 10.6.3 / Python 2.6.1 | 9,352,639 | 0 | 2 | 660 | 0 | python,macos,setuptools,sourceforge-appscript | I don't think the solution proposed is sufficient in many cases, as (for example) I already have the tools in /usr/bin and get the same error.
The problem is that gcc is being invoked with an -arch ppc flag, which generally is not supported any longer.
You need to (a)
set ARCHFLAGS in the shell environment so that is it
something like '-arch i386 -arch x86_64'
or for (b) for a permanent fix:
edit
/System/Library/Frameworks/Python.framework/Versions/Current/lib/python*/distutils/sysconfig.py
to change
archflags = '-arch i386 -arch ppc -arch x86_64'
or be
archflags = '-arch i386 -arch x86_64' | 0 | 1 | 0 | 0 | 2010-05-05T00:48:00.000 | 2 | 0 | false | 2,769,910 | 0 | 0 | 0 | 2 | I am having some trouble getting appscript installed on OS/X 10.6.3 / Python 2.6.1. When I issue
sudo easy_install appscript
I get "unable to execute gcc-4.2: No such file or directory". Even when I do export CC=/Developer/usr/bin/gcc-4.2 (a valid gcc-4.2 executable), easy_install barks.
What could be the issue?
Disclaimer: OS/X newbie at the helm... |
appscript on OSX 10.6.3 / Python 2.6.1 | 2,770,010 | 4 | 2 | 660 | 0 | python,macos,setuptools,sourceforge-appscript | Rerun the Xcode installer and check "UNIX Development" - it will put compilers in /usr/bin in addition to /Developer. | 0 | 1 | 0 | 0 | 2010-05-05T00:48:00.000 | 2 | 1.2 | true | 2,769,910 | 0 | 0 | 0 | 2 | I am having some trouble getting appscript installed on OS/X 10.6.3 / Python 2.6.1. When I issue
sudo easy_install appscript
I get "unable to execute gcc-4.2: No such file or directory". Even when I do export CC=/Developer/usr/bin/gcc-4.2 (a valid gcc-4.2 executable), easy_install barks.
What could be the issue?
Disclaimer: OS/X newbie at the helm... |
Using MySQL in Pydev Eclipse | 23,798,598 | 0 | 2 | 6,768 | 1 | python,mysql,eclipse,pydev,mysql-python | If the connector works in the IDLE but not in PyDev. Open Eclipse preferences, open PyDev directory and go to interpreter screen. Remove the interpreter and add it again from the location on your computer (Usually C drive). Close and reload Eclipse and now it should work. | 0 | 1 | 0 | 0 | 2010-05-05T16:36:00.000 | 3 | 0 | false | 2,775,095 | 0 | 0 | 0 | 2 | I am trying to access a MySQL database with python through Pydev Eclipse. I have installed the necessary files to access MysQL from python and I can access the database only when I write code in Python IDLE environment and run it from command prompt. However I am not able to run my applications from Pydev.
when I use this "import MysqlDB" i get an error, but in IDLE no errors and my code runs very smoothly.
Does anyone know were the problem is?
Thanks |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.