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
Getting logging.debug() to work on Google App Engine/Python
17,550,812
8
25
7,359
0
python,debugging,google-app-engine
In case someone is using the Windows Google Application Launcher. The argument for debug can be set under Edit > Application Settings In the Extra Command Line Flags, add --log_level=debug
0
1
0
0
2010-06-06T03:01:00.000
4
1
false
2,982,959
0
0
1
2
I'm just getting started on building a Python app for Google App Engine. In the localhost environment (on a Mac) I'm trying to send debug info to the GoogleAppEngineLauncher Log Console via logging.debug(), but it isn't showing up. However, anything sent through, say, logging.info() or logging.error() does show up. I've tried a logging.basicConfig(level=logging.DEBUG) before the logging.debug(), but to no avail. What am I missing?
Getting logging.debug() to work on Google App Engine/Python
27,547,085
1
25
7,359
0
python,debugging,google-app-engine
On a Mac: 1) click Edit > Application Settings 2) then copy and paste the following line into the "Extra Flags:" field --log_level=debug 3) click Update your debug logs will now show up in the Log Console
0
1
0
0
2010-06-06T03:01:00.000
4
0.049958
false
2,982,959
0
0
1
2
I'm just getting started on building a Python app for Google App Engine. In the localhost environment (on a Mac) I'm trying to send debug info to the GoogleAppEngineLauncher Log Console via logging.debug(), but it isn't showing up. However, anything sent through, say, logging.info() or logging.error() does show up. I've tried a logging.basicConfig(level=logging.DEBUG) before the logging.debug(), but to no avail. What am I missing?
Which os is better for development : Debian or Ubuntu?
2,985,450
4
10
20,812
0
java,python,ubuntu,debian,operating-system
Both use Debian packages and Ubuntu is based on Debian but is more user friendly. Everything yo can do on one you can do on the other. I'd recommend Ubuntu if your new to linux on a Desktop. Though when it comes to servers I'd recommend Debian as it has less stuff "taken out" basically.
0
1
0
1
2010-06-06T18:44:00.000
6
0.132549
false
2,985,426
0
0
0
5
Are there any real differences between them? I want to program in java and python. And of corse be a normal user: internet, etc Which one will give me less headaches/more satisfaction ? And which is better for a server machine ? Thank you
Which os is better for development : Debian or Ubuntu?
2,985,456
1
10
20,812
0
java,python,ubuntu,debian,operating-system
In Ubuntu it is a bit easier to install packages for Java development, but it doesn't really matter that much. Remember that Ubuntu is based on Debian, so it works the same. Ubuntu just adds more user-friendly GUI's.
0
1
0
1
2010-06-06T18:44:00.000
6
0.033321
false
2,985,426
0
0
0
5
Are there any real differences between them? I want to program in java and python. And of corse be a normal user: internet, etc Which one will give me less headaches/more satisfaction ? And which is better for a server machine ? Thank you
Which os is better for development : Debian or Ubuntu?
2,985,463
2
10
20,812
0
java,python,ubuntu,debian,operating-system
Ubuntu is the more user-friendly of the two (I think Ubuntu is actually one of the most newbie-friendly Linux distros), so if you are new to Linux, Ubuntu is the way to go. Otherwise, the packages are mostly the same except for branding, so it's pretty much your choice.
0
1
0
1
2010-06-06T18:44:00.000
6
0.066568
false
2,985,426
0
0
0
5
Are there any real differences between them? I want to program in java and python. And of corse be a normal user: internet, etc Which one will give me less headaches/more satisfaction ? And which is better for a server machine ? Thank you
Which os is better for development : Debian or Ubuntu?
2,985,472
1
10
20,812
0
java,python,ubuntu,debian,operating-system
Neither is better. They both support the same tools and libraries. They are both linux. Anything and everything you can do on one you can do on the other.
0
1
0
1
2010-06-06T18:44:00.000
6
0.033321
false
2,985,426
0
0
0
5
Are there any real differences between them? I want to program in java and python. And of corse be a normal user: internet, etc Which one will give me less headaches/more satisfaction ? And which is better for a server machine ? Thank you
Which os is better for development : Debian or Ubuntu?
2,985,442
2
10
20,812
0
java,python,ubuntu,debian,operating-system
java and python would most likely run the same on both. With Ubuntu you get additional space of support and active community, and perhaps larger user base. So if and when you face a particular problem, chances are with Ubuntu, the solution will appear faster. (although, whatever works on this should work on the other as well in theory)
0
1
0
1
2010-06-06T18:44:00.000
6
0.066568
false
2,985,426
0
0
0
5
Are there any real differences between them? I want to program in java and python. And of corse be a normal user: internet, etc Which one will give me less headaches/more satisfaction ? And which is better for a server machine ? Thank you
Best practice for installing python modules from an arbitrary VCS repository
2,986,445
1
5
1,655
0
python,version-control,module,easy-install
Packages installed by easy_install tend to come from snapshots of the developer's version control, generally made when the developer releases an official version. You're therefore going to have to choose between convenient automatic downloads via easy_install and up-to-the-minute code updates via version control. If you pick the latter, you can build and install most packages seen in the python package index directly from a version control checkout by running python setup.py install. If you don't like the default installation directory, you can install to a custom location instead, and export a PYTHONPATH environment variable whose value is the path of the installed package's parent folder.
0
1
0
1
2010-06-06T23:32:00.000
4
0.049958
false
2,986,357
1
0
0
1
I'm newish to the python ecosystem, and have a question about module editing. I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wonderful world, but the model breaks down when I want to edit the newly installed module for two reasons: The egg files may be stored in a folder or archive somewhere crazy on the file system. Using an egg seems to preclude using the version control system of the originating project, just as using a debian package precludes development from an originating VCS repository. What is the best practice for installing modules from an arbitrary VCS repository? I want to be able to continue to import foomodule in other scripts. And if I modify the module's source code, will I need to perform any additional commands?
what should i do after openid (or twitter ,facebook) user login my site ,on gae
2,988,807
1
0
264
0
python,google-app-engine,openid,integration
I understand your question. You wish to be able to maintain a list of users that have signed up with your service, and also want to record users using OpenID to authenticate. In order to solve this I would do either of the following: Create a new user in your users table for each new user logged in under OpenID, and store their OpenID in this table to allow you to join the two. Move your site to OpenID and change all references to your current users to OpenID users. I'd probably go with Option 1 if you already have this app in production. Note: More experienced Open ID users will probably correct me!
0
1
0
0
2010-06-07T02:24:00.000
1
0.197375
false
2,986,766
0
0
1
1
how to integration local user and openid(or facebook twitter) user , did you know some framework have already done this , updated my mean is : how to deal with 'local user' and 'openid user', and how to mix them in one model . please give me a framework that realize 'local user' and 'openid user'
How to obtain ports that a process in listening on?
42,511,544
0
23
21,117
0
python,linux,sockets,port
One thing that wasn't mentioned. Most port applications in python take a command line argument. You can parse /proc/pid/cmdline and parse out the port number. This avoids the large overhead of using ss or netstat on servers with a ton of connections.
0
1
0
1
2010-06-07T05:04:00.000
5
0
false
2,987,168
0
0
0
3
How do I get the ports that a process is listening on using python? The pid of the process is known.
How to obtain ports that a process in listening on?
2,987,231
1
23
21,117
0
python,linux,sockets,port
You can use netstat -lnp, last column will contain pid and process name. In Python you can parse output of this command.
0
1
0
1
2010-06-07T05:04:00.000
5
0.039979
false
2,987,168
0
0
0
3
How do I get the ports that a process is listening on using python? The pid of the process is known.
How to obtain ports that a process in listening on?
2,987,379
4
23
21,117
0
python,linux,sockets,port
If you don't want to parse the output of a program like netstat or lsof, you can grovel through the /proc filesystem and try to find documentation on the files within. /proc/<pid>/net/tcp might be especially interesting to you. Of course, the format of those files might change between kernel releases, so parsing command output is generally considered more reliable.
0
1
0
1
2010-06-07T05:04:00.000
5
0.158649
false
2,987,168
0
0
0
3
How do I get the ports that a process is listening on using python? The pid of the process is known.
File copy completion?
2,989,433
1
0
995
0
python,file-io
In Linux, you can open a file while another process is writing to it without Python throwing an OSError, so in general, you cannot know for sure whether the other side has finished writing into that file. You can try some hacks, though: You can check the file size regularly to see whether it increased since the last check. If it hasn't increased in, say, five seconds, you might be safe to assume that the copy has finished. I'm saying might since this is not true in all circumstances. If the other process that is writing the file is blocked for whatever reason, it might temporarily stop writing to the file and resume it later. So this is not 100% fool-proof, but might work for local file copies if the system is never under a heavy load that would stall the writing process. You can check the output of fuser (this is a shell command), which will list the process IDs for all the files that are holding a file handle to a given file name. If this list includes any process other than yours, you can assume that the copying process hasn't finished yet. However, you will have to make sure that fuser is installed on the target system in order to make it work.
0
1
0
0
2010-06-07T12:23:00.000
2
0.099668
false
2,989,388
0
0
0
1
In Linux, how can we know if a file has completed copying before reading it? In Windows, an OSError is raised.
Python-based password tracker (or dictionary)
2,992,104
0
1
313
0
python,encryption,passwords
On first i think you can change passwords on md5 of this passwords.. it will give more safety.
0
1
0
0
2010-06-07T18:22:00.000
4
0
false
2,992,057
0
0
0
1
Where we work we need to remember about 10 long passwords which need to change every so often. I would like to create a utility which can potentially save these passwords in an encrypted file so that we can keep track of them. I can think of some sort of dictionary passwd = {'host1':'pass1', 'host2':'pass2'}, etc, but I don't know what to do about encryption (absolutely zero experience in the topic). So, my question is really two questions: Is there a Linux-based utility which lets you do that? If you were to program it in Python, how would you go about it? A perk of approach two, would be for the software to update the ssh public keys after the password has been changed (you know the pain of updating ~15 tokens once you change your password). As it can be expected, I have zero control over the actual network configuration and the management of scp keys. I can only hope to provide a simple utility to me an my very few coworkers so that, if we need to, we can retrieve a password on demand. Cheers.
Display constantly updating information in-place in command-line window using python?
2,993,839
3
1
638
0
python,command-line
Outputting \b will move the output cursor left 1 cell, and outputting \r will return it to column 0. Make sure to flush the output often though.
0
1
0
0
2010-06-07T23:09:00.000
2
1.2
true
2,993,805
1
0
0
1
I am essentially building a timer. I have a python script that monitors for an event and then prints out the seconds that have elapsed since that event. Instead of an ugly stream of numbers printed to the command line, I would like to display only the current elapsed time "in-place"-- so that only one number is visible at any given time. Is there a simple way to do this? If possible I'd like to use built-in python modules. I'm on Windows, so simpler the better. (E.g. no X11).
OS-independent Inter-program communication between Python and C
60,171,476
0
6
3,514
0
python,c,networking,network-protocols,inter-process-communicat
if both applications running on same computer, use socket and serialize your objects to jsun. otherwise, use web service and jsun or xml. You can find jsun and xml parser in both languages.
0
1
0
0
2010-06-08T22:36:00.000
6
0
false
3,001,827
0
0
0
2
I have very little idea what I'm doing here, I've never done anything like this before, but a friend and I are writing competing chess programs and they need to be able to communicate to each other. He'll be writing mainly in C, the bulk of mine will be in Python, and I can see a few options: Alternately write to a temp file, or successive temp files. As the communication won't be in any way bulky this could work, but seems like an ugly work-around to me, the programs will have to keep checking for change/new files, it just seems ugly. Find some way of manipulating pipes i.e. mine.py| ./his . This seems like a bit of a dead end. Use sockets. But I don't know what I'd be doing, so could someone give me a pointer to some reading material? I'm not sure if there are OS-independent, language independent methods. Would there have to be some kind of supervisor server program to administrate? Use some kind of HTML protocol, which seems like overkill. I don't mind the programs having to run on the same machine. What do people recommend, and where can I start reading?
OS-independent Inter-program communication between Python and C
3,099,077
0
6
3,514
0
python,c,networking,network-protocols,inter-process-communicat
Sockets with a client/server model... Basically, you and your friend are creating different implementations of the client. The local client shows a visual representation of the game and stores the state of the pieces (position, killed/not-killed) and the rules about what the pieces can/can't do (which moves can be made with which pieces and whether the board's state is in check). The remote server stores state about the players (whose turn it is, points earned, whether the game is won or not), and a listing of moves that have occurred. When you make a move, your client validates the move against the rules of the game, then sends a message to the server that says, I've made this move, your turn. The other client sees that a turn has been made, pulls the last move from the server, calculates whether where the movement took place, validates the move against the game rules, and replays the action locally. After that's all done, it's now allows the user to make the next move (or not if the game is over). The most important part of client/server gaming communication is, send as little data to and store as little state as possible on the server. That way you can play it locally, or across the world with little or no latency. As long as your client is running under the same set of rules as your opponent's client everything should work. If you want to ensure that no one can cheat by hacking their version of the client, you can make the position and rule calculations all be done on the server and just make the clients nothing but simple playback mechanisms. The reason why sockets are the best communication medium are: the limitations on cross process communication are almost as difficult as cross node communication networking is widely supported on all systems there's little or no barrier-of-entry to using this remotely if you choose the networking is robust, flexible, and proven That's part of the reason why many major systems like Databases uses sockets as a networking as-well-as local communication medium.
0
1
0
0
2010-06-08T22:36:00.000
6
0
false
3,001,827
0
0
0
2
I have very little idea what I'm doing here, I've never done anything like this before, but a friend and I are writing competing chess programs and they need to be able to communicate to each other. He'll be writing mainly in C, the bulk of mine will be in Python, and I can see a few options: Alternately write to a temp file, or successive temp files. As the communication won't be in any way bulky this could work, but seems like an ugly work-around to me, the programs will have to keep checking for change/new files, it just seems ugly. Find some way of manipulating pipes i.e. mine.py| ./his . This seems like a bit of a dead end. Use sockets. But I don't know what I'd be doing, so could someone give me a pointer to some reading material? I'm not sure if there are OS-independent, language independent methods. Would there have to be some kind of supervisor server program to administrate? Use some kind of HTML protocol, which seems like overkill. I don't mind the programs having to run on the same machine. What do people recommend, and where can I start reading?
Fetching a random record from the Google App Engine Datastore?
3,003,170
23
21
5,002
0
python,google-app-engine,google-cloud-datastore
Assign each entity a random number and store it in the entity. Then query for ten records whose random number is greater than (or less than) some other random number. This isn't totally random, however, since entities with nearby random numbers will tend to show up together. If you want to beat this, do ten queries based around ten random numbers, but this will be less efficient.
0
1
0
0
2010-06-09T03:55:00.000
2
1.2
true
3,002,999
0
0
1
1
I have a datastore with around 1,000,000 entities in a model. I want to fetch 10 random entities from this. I am not sure how to do this? can someone help?
How to detect non-graceful disconnect of Twisted on Linux?
3,011,987
1
4
1,538
0
python,networking,twisted
Seconding what Jean-Paul said, if you need more fine grained TCP connection management, just use reactor.CallLater. We have exactly that implementation on a Twisted/wxPython trading platform, and it works a treat. You might also want to tweak the behaviour of the ReconnectingClientFactory in order to achieve the results I understand your looking for.
0
1
0
0
2010-06-09T06:12:00.000
2
0.099668
false
3,003,450
0
0
0
1
I wrote a server based on Twisted, and I encountered a problem, some of the clients are disconnected not gracefully. For example, the user pulls out the network cable. For a while, the client on Windows is disconnected (the connectionLost is called, and it is also written in Twisted). And on the Linux server side, my connectionLost of twisted is never triggered. Even it try to writes data to client when the connection is lost. Why Twisted can't detect those non-graceful disconnection (even write data to client) on Linux? How to makes Twisted detect non-graceful disconnections? Because the feature Twisted can't detect non-graceful, I have lots of zombie user on my server. ---- Update ---- I thought it might be the feature of socket of unix-like os, so, what is the behavior of socket on unix-like for handling situation like this? Thanks. Victor Lin.
Which display manager for a non interactive Python app and mplayer?
9,260,878
0
2
1,163
0
python,linux,embedded-linux,xorg
I realize this is an old question, but I use openbox on my system, I have created a custom config file that disables all mouse keyboard shortcuts, and removes borders etc on the applications. In the openbox config i even created some secret shortcuts that can run fx. an xterm for debugging live on the box. The openbox documentation was very helpful in figuring everything out, I did the config in about 30 minutes.
0
1
0
0
2010-06-09T20:22:00.000
5
0
false
3,009,634
0
0
0
3
I am developing an application that will run on Linux to run fullscreen all the time (no menus or trays or anything will be visible). The application is going to be developed in Python, not that that matters as far as the window manager, but what I am having a hard time with is choosing a window manager. I need something with the smallest possible footprint, that will let me run a graphical Python app and have an mplayer window at the same time, at widescreen resolutions (widescreen, 16:10,16:9, etc). Other than that, it doesn't need a lot of features, but the end footprint size is the most important thing I'll be looking at. What window manager would you recommend? EDIT: There won't be any interaction with the application needed.
Which display manager for a non interactive Python app and mplayer?
3,012,123
1
2
1,163
0
python,linux,embedded-linux,xorg
I am doing something similar on my "set-top box" and I don't use any window manager. It boots debian, and from inittab I auto-login the user that runs the display. That user's .profile starts X, which runs .xinitrc, which starts my python app that runs as a network server in front of mplayer (running mplayer in -slave mode). My python app does not have a GUI element - only mplayer runs on the X display. But in your case, it should be no different. As I mentioned in a comment to another answer, you may want to look into how you can reparent mplayer's window to give you greater control over its placement and/or movement/size. Doing it this way avoided a display manager and a window manager. This simplifies the solution, boots faster and uses a smaller footprint (it runs of an SD card, with heaps of room to spare).
0
1
0
0
2010-06-09T20:22:00.000
5
0.039979
false
3,009,634
0
0
0
3
I am developing an application that will run on Linux to run fullscreen all the time (no menus or trays or anything will be visible). The application is going to be developed in Python, not that that matters as far as the window manager, but what I am having a hard time with is choosing a window manager. I need something with the smallest possible footprint, that will let me run a graphical Python app and have an mplayer window at the same time, at widescreen resolutions (widescreen, 16:10,16:9, etc). Other than that, it doesn't need a lot of features, but the end footprint size is the most important thing I'll be looking at. What window manager would you recommend? EDIT: There won't be any interaction with the application needed.
Which display manager for a non interactive Python app and mplayer?
3,009,693
1
2
1,163
0
python,linux,embedded-linux,xorg
You probably meant window manager. Display manages are KDM, GDM and the like. Windoe managers, to name, GNOME, Xfce, KDE, ratpoison, fvwm, twm, blackbox are a few. ratpoison gives full screen to the application that is in the foreground but demands heavy keyboard interaction (hence the name ratpoison) and no mouse interaction at all.
0
1
0
0
2010-06-09T20:22:00.000
5
0.039979
false
3,009,634
0
0
0
3
I am developing an application that will run on Linux to run fullscreen all the time (no menus or trays or anything will be visible). The application is going to be developed in Python, not that that matters as far as the window manager, but what I am having a hard time with is choosing a window manager. I need something with the smallest possible footprint, that will let me run a graphical Python app and have an mplayer window at the same time, at widescreen resolutions (widescreen, 16:10,16:9, etc). Other than that, it doesn't need a lot of features, but the end footprint size is the most important thing I'll be looking at. What window manager would you recommend? EDIT: There won't be any interaction with the application needed.
IDLE wont start Python 2.6.5
3,011,669
0
0
625
0
python,python-idle
Honestly I would advise you to stop using IDLE, the fact that it runs program code in the same process as itself caused me a lot of problems when I used it, including things like not refreshing imported modules that were modified. Personally I switched to emacs, but you might like to try something like Notepad++.
0
1
0
0
2010-06-09T21:19:00.000
1
1.2
true
3,010,030
1
0
0
1
I was using it as my primary text editor for quite sometime. However, one day it just stopped working. This had happened to me several times before, so I simply tried to end all procceses using windows task manager. However that didn't work. I've recently tried getting it to work again. Whenever I try to reopen it it informs me that it's subprocess couldn't connect. I tried uninstalling it and reinstalling it, yet the problem persists. Anyone have any other solutions? Important facts: Windows 7, Python 2.6.5
How to calculate network usage with Python on Windows 7?
3,010,921
2
1
2,541
0
python,networking
What you want technically isn't a problem of the language you're using - how much data is being transferred on your network interfaces is something you need to get from your operating system or network device driver. The way that you acquire these statistics will vary based on the OS, so that's what you need to nail down first.
0
1
0
0
2010-06-09T23:18:00.000
3
1.2
true
3,010,674
0
0
0
1
How would I go about writing a python script that shows how much bandwidth is being used and how much data is being transferred on a Windows 7 machine?
how to make a chat room on gae ,has any audio python-framework to do this?
3,020,384
0
0
749
0
python,google-app-engine,audio,chat
You'll need two things: A browser plugin to get audio. You could build this on top of eg. http://code.google.com/p/libjingle/'>libjingle which has the advantage of being cross-platform and allowing P2P communication, not to mention being able to talk to arbitrary other XMPP endoints. Or you could use Flash to grab the audio and bounce the stream off a server you build (I think trying to do STUN in Flash for P2P would be impossible), but this would be very tricky to do in App Engine because you'd need it to be long-running. A way to get signaling messages between your clients. You'll have to poll until the Channel API is released (soon). This is a big hairy problem, to put it mildly, but it would be awesome if you did it.
0
1
0
0
2010-06-10T08:07:00.000
4
0
false
3,012,661
0
0
1
3
i want to make a chat room on gae ,(audio chat) has any framework to do this ? thanks
how to make a chat room on gae ,has any audio python-framework to do this?
3,080,160
1
0
749
0
python,google-app-engine,audio,chat
Try Adobe Stratus (it works with p2p connections) and you could use Google App Engine only for exchanging peer ids.
0
1
0
0
2010-06-10T08:07:00.000
4
0.049958
false
3,012,661
0
0
1
3
i want to make a chat room on gae ,(audio chat) has any framework to do this ? thanks
how to make a chat room on gae ,has any audio python-framework to do this?
3,013,054
1
0
749
0
python,google-app-engine,audio,chat
App Engine doesn't directly support audio chat of any sort, and since it's based around a request-response system with (primarily) HTTP requests, you can't implement it yourself.
0
1
0
0
2010-06-10T08:07:00.000
4
1.2
true
3,012,661
0
0
1
3
i want to make a chat room on gae ,(audio chat) has any framework to do this ? thanks
How can I build a wrapper to wait for listening on a port?
3,019,494
0
0
838
0
python,testing,sockets,wrapper
Another option is to mock the socket module before importing the asyncore module. Of course, then you have to make sure that the mock works properly first.
0
1
1
1
2010-06-10T13:19:00.000
2
0
false
3,014,686
0
0
0
1
I am looking for a way of programmatically testing a script written with the asyncore Python module. My test consists of launching the script in question -- if a TCP listen socket is opened, the test passes. Otherwise, if the script dies before getting to that point, the test fails. The purpose of this is knowing if a nightly build works (at least up to a point) or not. I was thinking the best way to test would be to launch the script in some kind of sandbox wrapper which waits for a socket request. I don't care about actually listening for anything on that port, just intercepting the request and using that as an indication that my test passed. I think it would be preferable to intercept the open socket request, rather than polling at set intervals (I hate polling!). But I'm a bit out of my depths as far as how exactly to do this. Can I do this with a shell script? Or perhaps I need to override the asyncore module at the Python level? Thanks in advance, - B
exec: 23: python: not found error?
3,019,817
0
2
3,027
0
python,android
You should check your python instalation as the repo command is an python script made by Google to interact with git repositories. If you do have python installed it is possible that it is not in your shell path or you are using a diferent version than required by repo, ie. you have version 3 while repo requires version 2.5 (just an example, I'm not sure what version repo uses).
0
1
0
1
2010-06-11T01:59:00.000
1
0
false
3,019,742
0
0
0
1
im trying to build android from source on ubuntu 10.04. when i enter the repo command: repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair it get this error back exec: 23: python: not found any ideas.
how to make a python or perl script portable to both linux and windows?
3,020,285
2
11
5,770
0
python,perl,scripting,cross-platform,shebang
The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether.
0
1
0
0
2010-06-11T04:53:00.000
4
0.099668
false
3,020,267
0
0
0
2
I was wondering how to make a python script portable to both linux and windows? One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? Are there other problems besides shebang that I should know? Is the solution same for perl script? Thanks and regards!
how to make a python or perl script portable to both linux and windows?
3,020,286
14
11
5,770
0
python,perl,scripting,cross-platform,shebang
Windows will just ignore the shebang (which is, after all, a comment); in Windows you need to associate the .py extension to the Python executable in the registry, but you can perfectly well leave the shebang on, it will be perfectly innocuous there. There are many bits and pieces which are platform-specific (many only exist on Unix, msvcrt only on Windows) so if you want to be portable you should abstain from those; some are subtly different (such as the detailed precise behavior of subprocess.Popen or mmap) -- it's all pretty advanced stuff and the docs will guide you there. If you're executing (via subprocess or otherwise) external commands you'd better make sure they exist on both platforms, of course, or check what platform you're in and use different external commands in each case. Remember to always use /, not \, as path separator (forward slash works in both platforms, backwards slash is windows-only), and be meticulous as to whether each file you're opening is binary or text. I think that's about it...
0
1
0
0
2010-06-11T04:53:00.000
4
1.2
true
3,020,267
0
0
0
2
I was wondering how to make a python script portable to both linux and windows? One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? Are there other problems besides shebang that I should know? Is the solution same for perl script? Thanks and regards!
Help me sort programming languages a bit
3,021,757
1
3
333
0
python,c,ruby,programming-languages
If I assume this is your central question: Where is the line between language functions and system API? Then imagine if you will this analogy: OS API system calls are like lego bricks and lego components. Programming 'functions' are merely an arrangement of many lego bricks. Such that the combination results in a tool. Thus different languages may 'arrange' and create the tool in different ways. If I asked you to create a car with lego's, you could come up with many different designs.
0
1
0
0
2010-06-11T09:26:00.000
6
0.033321
false
3,021,652
0
0
0
5
so I asked here few days ago about C# and its principles. Now, if I may, I have some additional general questions about some languages, because for novice like me, it seems a bit confusing. To be exact I want to ask more about language functions capabilities than syntax and so. To be honest, its just these special functions that bothers me and make me so confused. For example, C has its printf(), Pascal has writeln() and so. I know in basic the output in assembler of these functions would be similar, every language has more or less its special functions. For console output, for file manipulation, etc. But all these functions are de-facto part of its OS API, so why is for example in C distinguished between C standard library functions and (on Windows) WinAPI functions when even printf() has to use some Windows feature, call some of its function to actually show desired text on console window, becouse the actual "showing" is done by OS. Where is the line between language functions and system API? Now languages I don't quite understand - Python, Ruby and similar. To be more specific, I know they are similar to java and C# in term they are compiled into bytecode. But, I do not unerstand what are its capabilities in term of building GUI applications. I saw tutorial for using Ruby to program GUI applications on Linux and Windows. But isn´t that just some kind of upgrade? I mean fram other tutorials It seemed like these languages was first intended for small scripts than building big applications. I hope you understand why I am confused. If you do, please help me sort it out a bit, I have no one to ask.
Help me sort programming languages a bit
3,021,731
1
3
333
0
python,c,ruby,programming-languages
So. For your first question, the interface between the C API and the OS API is the C runtime. On Windows this is some incarnation of MSVCRT.DLL, whereas on Linux this is glibc. For the second, the native language for most GUI toolkits is either C or C++. Higher-level languages seeking to use them require bindings which translate back and forth between the language and the C/C++ API. For the third, these high-level languages only appear to be used for "small scripts". The simple fact is that they are far more expressive than C or C++, which means that they have equal or more capabilities than a C or C++ program while being written in fewer lines of code.
0
1
0
0
2010-06-11T09:26:00.000
6
0.033321
false
3,021,652
0
0
0
5
so I asked here few days ago about C# and its principles. Now, if I may, I have some additional general questions about some languages, because for novice like me, it seems a bit confusing. To be exact I want to ask more about language functions capabilities than syntax and so. To be honest, its just these special functions that bothers me and make me so confused. For example, C has its printf(), Pascal has writeln() and so. I know in basic the output in assembler of these functions would be similar, every language has more or less its special functions. For console output, for file manipulation, etc. But all these functions are de-facto part of its OS API, so why is for example in C distinguished between C standard library functions and (on Windows) WinAPI functions when even printf() has to use some Windows feature, call some of its function to actually show desired text on console window, becouse the actual "showing" is done by OS. Where is the line between language functions and system API? Now languages I don't quite understand - Python, Ruby and similar. To be more specific, I know they are similar to java and C# in term they are compiled into bytecode. But, I do not unerstand what are its capabilities in term of building GUI applications. I saw tutorial for using Ruby to program GUI applications on Linux and Windows. But isn´t that just some kind of upgrade? I mean fram other tutorials It seemed like these languages was first intended for small scripts than building big applications. I hope you understand why I am confused. If you do, please help me sort it out a bit, I have no one to ask.
Help me sort programming languages a bit
3,021,849
2
3
333
0
python,c,ruby,programming-languages
At the bottom you have the OS kernel itself - code that runs in a special CPU mode that allows direct access to otherwise protected resources. You will never have to deal with this unless you're an OS developer. Then comes a do-not-cross line seperating this "kernel space" from "user space". Everything you do as "normal" developer is done in user space. The OS kernel exports a limited number of very basic functions into user space, dubbed "system calls". Open a file, read / write a number of bytes, closing the file, for example. Because these system calls usually require some Assembler code developers don't want to be bothered with, they are "wrapped" in (usually) C code functions: open(), read(), write(), close(). Now come two sets of APIs available to the developer: The OS API, and the standard language API. The standard language API provides functions that can be used on any platform supporting the language: fopen(), fputc(), fgetc(), fclose(). It will also provide higher-level functions that make life easier: fprintf(), for example. The OS API provides its own set of functions. These are not portable to a different operating system, but might be more intuitive to use, or more powerful, or merely different. OpenFile(), ReadFile(), WriteFile(), CloseFile(). Again, higher-level functions might be available, i.e. PrintLn(). The two sets of functions might partially rely on each other, or make system calls directly, but that shouldn't bother you too much. You should, however, decide beforehand which set of functions you will want to use for your project, because mixing the two sets - while not a mistake in itself - opens a whole new can of worms (i.e., potential errors).
0
1
0
0
2010-06-11T09:26:00.000
6
1.2
true
3,021,652
0
0
0
5
so I asked here few days ago about C# and its principles. Now, if I may, I have some additional general questions about some languages, because for novice like me, it seems a bit confusing. To be exact I want to ask more about language functions capabilities than syntax and so. To be honest, its just these special functions that bothers me and make me so confused. For example, C has its printf(), Pascal has writeln() and so. I know in basic the output in assembler of these functions would be similar, every language has more or less its special functions. For console output, for file manipulation, etc. But all these functions are de-facto part of its OS API, so why is for example in C distinguished between C standard library functions and (on Windows) WinAPI functions when even printf() has to use some Windows feature, call some of its function to actually show desired text on console window, becouse the actual "showing" is done by OS. Where is the line between language functions and system API? Now languages I don't quite understand - Python, Ruby and similar. To be more specific, I know they are similar to java and C# in term they are compiled into bytecode. But, I do not unerstand what are its capabilities in term of building GUI applications. I saw tutorial for using Ruby to program GUI applications on Linux and Windows. But isn´t that just some kind of upgrade? I mean fram other tutorials It seemed like these languages was first intended for small scripts than building big applications. I hope you understand why I am confused. If you do, please help me sort it out a bit, I have no one to ask.
Help me sort programming languages a bit
3,021,738
2
3
333
0
python,c,ruby,programming-languages
C is portable. That means that on different systems the assembler output for printf will be different... this is something the compiler does based on what your target system is. Write C code and compile as a Linux app and the output will be different than as a Win32 app, and also different than if you compile the exact same code for an iPhone or something like that. Internally, the C standard libraries might wrap a call to Win32 API when you call printf, but that's not really your concern in most cases. The C standard library (like printf and other I/O for files and stuff) wraps the low-level OS or hardware code needed to do what you want. It's worth noting the same effect happens in Java, but in a different way. At a broad level: In Java, the code you write always compiles to the same byte-code. But then when the JVM runs this byte-code, the JRE translates it to machine-specific instructions at run-time, rather than at compile-time on C.
0
1
0
0
2010-06-11T09:26:00.000
6
0.066568
false
3,021,652
0
0
0
5
so I asked here few days ago about C# and its principles. Now, if I may, I have some additional general questions about some languages, because for novice like me, it seems a bit confusing. To be exact I want to ask more about language functions capabilities than syntax and so. To be honest, its just these special functions that bothers me and make me so confused. For example, C has its printf(), Pascal has writeln() and so. I know in basic the output in assembler of these functions would be similar, every language has more or less its special functions. For console output, for file manipulation, etc. But all these functions are de-facto part of its OS API, so why is for example in C distinguished between C standard library functions and (on Windows) WinAPI functions when even printf() has to use some Windows feature, call some of its function to actually show desired text on console window, becouse the actual "showing" is done by OS. Where is the line between language functions and system API? Now languages I don't quite understand - Python, Ruby and similar. To be more specific, I know they are similar to java and C# in term they are compiled into bytecode. But, I do not unerstand what are its capabilities in term of building GUI applications. I saw tutorial for using Ruby to program GUI applications on Linux and Windows. But isn´t that just some kind of upgrade? I mean fram other tutorials It seemed like these languages was first intended for small scripts than building big applications. I hope you understand why I am confused. If you do, please help me sort it out a bit, I have no one to ask.
Help me sort programming languages a bit
3,021,872
0
3
333
0
python,c,ruby,programming-languages
C's printf() is a wrapper. You can use it and compile your code under any OS, but the resulting machine code will be different. In Windows, it might call some function inside the Windows API. In Linux, it will use the Linux API. You ask why is the Windows API distinguished. That's because, if you're programming for Windows, you can use it to do some OS-specific things like create GUIs, manipulate console text instead of just printing, asking for OS resources, and stuff like that. An API like that exists for Linux and Mac (and I guess all the other OS's) too, and they let you do more or less the same things. Unlike printf(), though, they are not portable. You ask what is the line between language functions and the system API. The language functions simply call the OS's API. You can call these yourself, but then you won't be able to compile your code on different systems. Python and Ruby (and some others) are interpreted. They are compiled to bytecode behind the scenes, but all the user sees is that double-clicking the source file will run it. No need to compile. That means, obviously, that they're slower than compiled languages. However, their dynamic nature makes for faster development, since you usually need less code to do the same thing (I said usually). That doesn't mean these languages can't be used for "big" applications: There are GUI libraries for them. That's because these are general purpose languages, unlike some others like Bash.
0
1
0
0
2010-06-11T09:26:00.000
6
0
false
3,021,652
0
0
0
5
so I asked here few days ago about C# and its principles. Now, if I may, I have some additional general questions about some languages, because for novice like me, it seems a bit confusing. To be exact I want to ask more about language functions capabilities than syntax and so. To be honest, its just these special functions that bothers me and make me so confused. For example, C has its printf(), Pascal has writeln() and so. I know in basic the output in assembler of these functions would be similar, every language has more or less its special functions. For console output, for file manipulation, etc. But all these functions are de-facto part of its OS API, so why is for example in C distinguished between C standard library functions and (on Windows) WinAPI functions when even printf() has to use some Windows feature, call some of its function to actually show desired text on console window, becouse the actual "showing" is done by OS. Where is the line between language functions and system API? Now languages I don't quite understand - Python, Ruby and similar. To be more specific, I know they are similar to java and C# in term they are compiled into bytecode. But, I do not unerstand what are its capabilities in term of building GUI applications. I saw tutorial for using Ruby to program GUI applications on Linux and Windows. But isn´t that just some kind of upgrade? I mean fram other tutorials It seemed like these languages was first intended for small scripts than building big applications. I hope you understand why I am confused. If you do, please help me sort it out a bit, I have no one to ask.
Google App Engine - update_indexes error
3,025,435
1
1
221
0
java,python,google-app-engine,google-cloud-datastore
I followed what was suggested in the error logs and that worked for me: Empty the index.yaml file (create a backup first) Run vacuum_indexes again Look at your app's admin console and don't go to the next step till all your indexes are deleted. Specify the indexes you want to be created in index.yaml Run update_indexes Look at your app's admin console and it should show that your indexes are now building. Enjoy the fruits of your labor :) Cheers, Keyur
0
1
0
0
2010-06-11T16:55:00.000
1
0.197375
false
3,024,663
0
0
1
1
I have a Java app deployed on app engine and I use appcfg.py of the Python SDK to vacuum and update my indexes. Yesterday I first ran vacuum_indexes and that completed successfully - i.e. it en-queued tasks to delete my existing indexes. The next step was probably a mistake on my part - I then ran update_indexes even though my previous indexes weren't yet deleted. Needless to say that my update_indexes call errored out. So much so that now when I look at my app engine console, it shows the status of all my indexes as "Error". A day has passed an it still shows the status on my indexes as "Error". Can someone help my out of my fix?! Thanks, Keyur P.S.: I have posted this on the GAE forums as well but hoping SO users have faced and resolved this issue as well.
Where is the Google App Engine SDK path on OSX?
3,030,645
60
31
17,766
0
python,eclipse,google-app-engine,pydev
/usr/local/google_appengine - that's a symlink that links to the SDK.
0
1
0
0
2010-06-13T00:14:00.000
3
1.2
true
3,030,585
0
0
1
2
I need to know for creating a Pydev Google App Engine Project in Eclipse.
Where is the Google App Engine SDK path on OSX?
5,189,889
28
31
17,766
0
python,eclipse,google-app-engine,pydev
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine
0
1
0
0
2010-06-13T00:14:00.000
3
1
false
3,030,585
0
0
1
2
I need to know for creating a Pydev Google App Engine Project in Eclipse.
is there any way to enforce the 30 seconds limit on local appengine dev server?
3,031,594
1
3
138
0
python,django,google-app-engine
It's possible, as Alex demonstrates, but it's not really a good idea: The performance characteristics of the development server are not the same as those of the production environment, so something that executes quickly locally may not be nearly as quick in production, and vice versa. Also, your user facing tasks should definitely not be so slow as to approach the 30 second limit.
0
1
0
0
2010-06-13T00:22:00.000
2
0.099668
false
3,030,593
0
0
1
1
Hey, i was wondering if there is a way to enforce the 30 seconds limit that is being enforced online at the appengine production servers to the local dev server? its impossible to test if i reach the limit before going production. maybe some django middlware?
uWSGI with Cherokee: first steps
5,033,390
1
2
2,309
0
python,wsgi,cherokee,uwsgi
There seems to be an issue with the 'make' method of installation on the uwsgi docs. Use 'python uwsgiconfig.py --build' instead. That worked for me. Cherokee, Django running on Ubuntu 10.10.
0
1
0
1
2010-06-13T03:16:00.000
3
0.066568
false
3,030,936
0
0
1
1
Has anyone tried using uWSGI with Cherokee? Can you share your experiences and what documents you relied upon the most? I am trying to get started from the documentation on both (uWSGI and Cherokee) websites. Nothing works yet. I am using Ubuntu 10.04. Edit: To clarify, Cherokee has been working fine. I am getting the error message: uWSGI Error, wsgi application not found So something must be wrong with my configurations. Or maybe my application.
Detecting and interacting with long running process
3,032,409
0
0
317
0
python
Well here is an idea... place a status somewhere else, that can be polled/queried. when the process starts, post the 'running' status. have the script check here to see if the process is running. I would also use a seperate place to post control values. e.g. set a value to the 'control set' and have the process look for those values whenever it gets to decision points in its runtime behavior.
0
1
0
0
2010-06-13T13:29:00.000
2
0
false
3,032,378
0
0
0
2
I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows. I am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use "named pipes"? Or is there some easier way?
Detecting and interacting with long running process
3,032,536
2
0
317
0
python
Sockets are easier to make portable between Windows and any other OS, so that's what I would recommend it over named pipes (that's why e.g. IDLE uses sockets rather than named pipes -- the latter require platform-dependent code on Windows, e.g. via ctypes [[or third-party win32all or cython &c]], while sockets just work).
0
1
0
0
2010-06-13T13:29:00.000
2
1.2
true
3,032,378
0
0
0
2
I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows. I am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use "named pipes"? Or is there some easier way?
Starting a separate process
3,032,818
15
17
44,315
0
python,multiprocessing
From the Python docs: When a process exits, it attempts to terminate all of its daemonic child processes. This is the expected behavior.
0
1
0
0
2010-06-13T15:41:00.000
6
1.2
true
3,032,805
1
0
0
1
I want a script to start a new process, such that the new process continues running after the initial script exits. I expected that I could use multiprocessing.Process to start a new process, and set daemon=True so that the main script may exit while the created process continues running. But it seems that the second process is silently terminated when the main script exits. Is this expected behavior, or am I doing something wrong?
App Engine HTTP 500s
3,033,229
2
1
829
0
python,google-app-engine,http-error
I agree that the correlation between startup log messages and 500 errors is not necessarily causal. However, it could be and pocoa should take steps to ensure that his startup time is low and that time consuming tasks be deferred when possible. One log entry and one 500 error does not mean much, but a few with time correlated probably points to excessive startup costs.
0
1
0
0
2010-06-13T16:31:00.000
3
0.132549
false
3,033,009
0
0
1
1
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application. I've handled all the situations, also DeadlineExceededError too. But sometimes I see these error messages in error logs. That request took about 10k ms, so it's not exceeded the limit too. But there is no other specific message about this error. All I know is that it returned HTTP 500. Is there anyone know the reason of these error messages? Thank you.
Storing task state between multiple django processes
3,036,073
0
0
537
0
python,django,transactions,multiprocessing,rabbitmq
This sounds brittle to me: You have a web app which posts to a queue and then inserts the initial state into the database. What happens if the consumer processes the message before the web app can commit the initial state? What happens if the web app tries to insert the new state while the DB is locked by the consumer? To fix this, the web app should add the initial state to the message and the consumer should be the only one ever writing to the DB. [EDIT] And you might also have an issue with logging. Check that races between the web app and the consumer produce the appropriate errors in the log by putting a message to the queue without modifying the DB. [EDIT2] Some ideas: How about showing just the number of pending tasks? For this, the web app could write into table 1 and the consumer writes into table 2 and the admin if would show the difference. Why can't the web app see the pending tasks which the consumer has in the queue? Maybe you should have two consumers. The first consumer just adds the task to the DB, commits and then sends a message to the second consumer with just the primary key of the new row. The admin iface could read the table while the second consumer writes to it. Last idea: Commit the transaction before you enqueue the message. For this, you simply have to send "commit" to the database. It will feel odd (and I certainly don't recommend it for any case) but here, it might make sense to commit the new row manually (i.e. before you return to your framework which handles the normal transaction logic).
0
1
0
0
2010-06-14T09:09:00.000
2
0
false
3,036,049
0
0
1
2
I am building a logging-bridge between rabbitmq messages and Django application to store background task state in the database for further investigation/review, also to make it possible to re-publish tasks via the Django admin interface. I guess it's nothing fancy, just a standard Producer-Consumer pattern. Web application publishes to message queue and inserts initial task state into the database Consumer, which is a separate python process, handles the message and updates the task state depending on task output The problem is, some tasks are missing in the db and therefore never executed. I suspect it's because Consumer receives the message earlier than db commit is performed. So basically, returning from Model.save() doesn't mean the transaction has ended and the whole communication breaks. Is there any way I could fix this? Maybe some kind of post_transaction signal I could use? Thank you in advance.
Storing task state between multiple django processes
3,036,410
0
0
537
0
python,django,transactions,multiprocessing,rabbitmq
Web application publishes to message queue and inserts initial task state into the database Do not do this. Web application publishes to the queue. Done. Present results via template and finish the web transaction. A consumer fetches from the queue and does things. For example, it might append to a log to the database for presentation to the user. The consumer may also post additional status to the database as it executes things. Indeed, many applications have multiple queues with multiple produce/consumer relationships. Each process might append things to a log. The presentation must then summarize the log entries. Often, the last one is a sufficient summary, but sometimes you need a count or information from earlier entries.
0
1
0
0
2010-06-14T09:09:00.000
2
0
false
3,036,049
0
0
1
2
I am building a logging-bridge between rabbitmq messages and Django application to store background task state in the database for further investigation/review, also to make it possible to re-publish tasks via the Django admin interface. I guess it's nothing fancy, just a standard Producer-Consumer pattern. Web application publishes to message queue and inserts initial task state into the database Consumer, which is a separate python process, handles the message and updates the task state depending on task output The problem is, some tasks are missing in the db and therefore never executed. I suspect it's because Consumer receives the message earlier than db commit is performed. So basically, returning from Model.save() doesn't mean the transaction has ended and the whole communication breaks. Is there any way I could fix this? Maybe some kind of post_transaction signal I could use? Thank you in advance.
How to determine what user and group a Python script is running as?
3,042,340
1
31
29,300
0
python,unix,permissions
os.getgid() and os.getuid() can be useful. For other environment variables, look into os.getenv. For example, os.getenv('USER') on my Mac OS X returns the username. os.getenv('USERNAME') would return the username on Windows machines.
0
1
0
1
2010-06-15T03:15:00.000
3
0.066568
false
3,042,304
0
0
0
1
I have a CGI script that is getting an "IOError: [Errno 13] Permission denied" error in the stack trace in the web server's error log. As part of debugging this problem, I'd like to add a little bit of code to the script to print the user and (especially) group that the script is running as, into the error log (presumably STDERR). I know I can just print the values to sys.stderr, but how do I figure out what user and group the script is running as? (I'm particularly interested in the group, so the $USER environment variable won't help; the CGI script has the setgid bit set so it should be running as group "list" instead of the web server's "www-data" - but I need code to see if that's actually happening.)
How can I make the Eclipse Python debugger more reliable?
5,732,993
2
4
1,295
0
python,eclipse,debugging,pydev
There are known issues with Python 2.4 (so, if possible, get a newer version), still, if you're unable to get a newer version, at least use threadframe extension (http://pypi.python.org/pypi/threadframe). If None of that's possible, it's really expected that the debugger doesn't work as well as it could (as the debugger needs features that are not available in that version).
0
1
0
0
2010-06-15T08:27:00.000
2
0.197375
false
3,043,597
1
0
0
2
I've found that under some circumstances the Eclipse python debugger can be unreliable. For example, when stepping through a memory-hungry Python program I've found that after a certain point the debugger fails to respond. The entire process hangs with 100% cpu load. I've heard (unconfirmed) reports from developers that when this occurs it might actually not be a hang but very slow, for example a step which usually takes a micro-second might be taking five minutes. I've observed this with both the regular eclipse debugger (e.g. when you do debug as->python run) and the pydev network debugger. The point at which things stop working seems quite arbitrary but re-producable. I'm debugging purely numerical functions so there's no obvious socket or tcp activity which could disrupt a network debugger. Nevertheless, the point at which the failure occurs seems to be quite consistent for a given workstation & task. I get almost exactly the same effect whether I debug using debug as->python run as I might if I use the pydev's network debugger ('import pydevd;pydevd.settrace()') - where one fails the other is also likely to fail. If I were to run the script normally (no debugger) it executes without any hangs. Furthermore, if I replace the eclipse debugger with the old-skool inline break-point ('import pdb;pdb.set_trace()') everything works just fine. Pdb almost never goes wrong, however there are times I simply cannot use it, for example when I am debugging a python function invoked from Excel - as there is no console present. I've noticed that this failure never seems to occur with trivial programs, hence I've tentatively concluded that the fault may be memory related. So - is anybody aware of what might be causing this unreliability. Are there any tweaks I can make to the debugger or environment that might make the debugger work more reliably? FYI, running Python 2.4.4 on Windows XP 32bit with the latest Eclipse & Pydev. Psyco (JIT Compiler) is not available.
How can I make the Eclipse Python debugger more reliable?
5,637,371
0
4
1,295
0
python,eclipse,debugging,pydev
Not sure if its related, but I had a scenario where too many debug messages will cause my PC to become very slow. You can try go to Window -> Preferences -> Run/Debug -> Console... tick Limit console output, and reduce Console buffer size (mine is set to 40000).
0
1
0
0
2010-06-15T08:27:00.000
2
0
false
3,043,597
1
0
0
2
I've found that under some circumstances the Eclipse python debugger can be unreliable. For example, when stepping through a memory-hungry Python program I've found that after a certain point the debugger fails to respond. The entire process hangs with 100% cpu load. I've heard (unconfirmed) reports from developers that when this occurs it might actually not be a hang but very slow, for example a step which usually takes a micro-second might be taking five minutes. I've observed this with both the regular eclipse debugger (e.g. when you do debug as->python run) and the pydev network debugger. The point at which things stop working seems quite arbitrary but re-producable. I'm debugging purely numerical functions so there's no obvious socket or tcp activity which could disrupt a network debugger. Nevertheless, the point at which the failure occurs seems to be quite consistent for a given workstation & task. I get almost exactly the same effect whether I debug using debug as->python run as I might if I use the pydev's network debugger ('import pydevd;pydevd.settrace()') - where one fails the other is also likely to fail. If I were to run the script normally (no debugger) it executes without any hangs. Furthermore, if I replace the eclipse debugger with the old-skool inline break-point ('import pdb;pdb.set_trace()') everything works just fine. Pdb almost never goes wrong, however there are times I simply cannot use it, for example when I am debugging a python function invoked from Excel - as there is no console present. I've noticed that this failure never seems to occur with trivial programs, hence I've tentatively concluded that the fault may be memory related. So - is anybody aware of what might be causing this unreliability. Are there any tweaks I can make to the debugger or environment that might make the debugger work more reliably? FYI, running Python 2.4.4 on Windows XP 32bit with the latest Eclipse & Pydev. Psyco (JIT Compiler) is not available.
unattended install of binary python packages (modules) for windows
3,542,501
0
11
4,548
0
python,windows,setuptools
If you want scripted automation of installs on Windows, look into AutoIt.
0
1
0
0
2010-06-15T10:36:00.000
4
0
false
3,044,359
1
0
0
1
Is there no sane way to peform a scripted install of binary python packages for windows? Unfortunately it seems like several essential windows python packages like pywin32 and py2exe are only available as EXE's not MSI's (and as far as I know only the latter are scriptable). Easy_install/pip also seems no use since they apparently only find source packages and then try to compile locally which is obviously unsatisfactory. Am I missing something?
I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one Terminal should launch?
3,046,210
4
1
1,464
0
python,macos,terminal
When you run python in a shell or command prompt it will execute the first executable file which is found in your PATH environment variable. To find out what file is being executed use which python or where python.
0
1
0
0
2010-06-15T14:37:00.000
3
0.26052
false
3,046,183
1
0
0
1
When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to have lots of folers in different places. If there are multiple installations, I could really do with being able to set which one should be used.
On Ubuntu, how do you install a newer version of python and keep the older python version?
3,050,521
10
8
11,229
0
python,ubuntu,installation,gnu,configure
When you install from source, by default, the installation goes in /usr/local -- the executable in particular becomes /usr/local/bin/pythonX.Y with a symlink to it that's named /usr/local/python. Ubuntu's own installation is in /usr/ (e.g., /usr/bin/python), so the new installation won't overwrite it. Take care that the PATH environment variable doesn't have /usr/local/bin before /usr/bin, or else simple mentions of python would execute the new one, not the old one.
0
1
0
0
2010-06-16T03:18:00.000
4
1.2
true
3,050,512
1
0
0
1
Background: I am using Ubuntu The newer python version is not in the apt-get repository (or synaptic) I plan on keeping the old version as the default python when you call "python" from the command line I plan on calling the new python using pythonX.X (X.X is the new version). Given the background, how do you install a newer version of python and keep the older python version? I have downloaded from python.org the "install from source" *.tgz package. The readme is pretty simple and says "execute three commands: ./configure; make; make test; sudo make install;" If I do the above commands, will the installation overwrite the old version of python I have (I definitely need the old version)?
Gathering mac addresses with Python
3,056,396
1
0
1,429
0
python,django,networking,mac-address
The easiest thing to do would be to run a tool that can achieve this and parse its output (e.g. nmap). Depending on your needs, you could run it periodically and keep a file with the mac addresses. Looking at the leases file could work, assuming that all your machines are in there. If you want to actively look for machines, do a nmap scan.
0
1
0
0
2010-06-16T19:00:00.000
2
1.2
true
3,056,324
1
0
0
2
is there a good way to gather the mac addresses of machines on a local network using Python. If it helps I'm trying to execute this python script from the DHCP server for the network. I'm new to Python but would it be a bad idea to look at the DHCP leases file for this info? I'd like to use this inside a Django app eventually. Thanks.
Gathering mac addresses with Python
3,056,384
1
0
1,429
0
python,django,networking,mac-address
Really a unix question (one will assume) You can either look at the arp addresses registered "/sbin/arp -a" or a DHCP lease table. If you go the arp route you will on find addresses that your system has recently received/sent packets to, the DHCP lease table will give you the ability to see everything. Though if it's static configured it won't show up.
0
1
0
0
2010-06-16T19:00:00.000
2
0.099668
false
3,056,324
1
0
0
2
is there a good way to gather the mac addresses of machines on a local network using Python. If it helps I'm trying to execute this python script from the DHCP server for the network. I'm new to Python but would it be a bad idea to look at the DHCP leases file for this info? I'd like to use this inside a Django app eventually. Thanks.
A daemon to call a function every 2 minutes with start and stop capablities
3,057,550
4
1
549
0
python,django
There are a number of ways to achieve this. Assuming the correct server resources I would write a python script that calls function xyz "outside" of your django directory (although importing the necessary stuff) that only runs if /var/run/django-stuff/my-daemon.run exists. Get cron to run this every two minutes. Then, for your django functions, your start function creates the above mentioned file if it doesn't already exist and the stop function destroys it. As I say, there are other ways to achieve this. You could have a python script on loop waiting for approx 2 minutes... etc. In either case, you're up against the fact that two python scripts run on two different invocations of cpython (no idea if this is the case with mod_wsgi) cannot communicate with each other and as such IPC between python scripts is not simple, so you need to use some sort of formal IPC (like semaphores, files etc) rather than just common variables (which won't work).
0
1
0
0
2010-06-16T22:03:00.000
3
0.26052
false
3,057,507
0
0
1
2
I am working on a django web application. A function 'xyx' (it updates a variable) needs to be called every 2 minutes. I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it. Appreciate your ideas. Thanks Vishal Rana
A daemon to call a function every 2 minutes with start and stop capablities
3,057,553
2
1
549
0
python,django
Probably a little hacked but you could try this: Set up a crontab entry that runs a script every two minutes. This script will check for some sort of flag (file existence, contents of a file, etc.) on the disk to decide whether to run a given python module. The problem with this is it could take up to 1:59 to run the function the first time after it is started. I think if you started a daemon in the view function it would keep the httpd worker process alive as well as the connection unless you figure out how to send a connection close without terminating the django view function. This could be very bad if you want to be able to do this in parallel for different users. Also to kill the function this way, you would have to somehow know which python and/or httpd process you want to kill later so you don't kill all of them. The real way to do it would be to code an actual daemon in w/e language and just make a system call to "/etc/init.d/daemon_name start" and "... stop" in the django views. For this, you need to make sure your web server user has permission to execute the daemon.
0
1
0
0
2010-06-16T22:03:00.000
3
0.132549
false
3,057,507
0
0
1
2
I am working on a django web application. A function 'xyx' (it updates a variable) needs to be called every 2 minutes. I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it. Appreciate your ideas. Thanks Vishal Rana
Python: disabling $HOME/.python-eggs?
3,064,433
3
1
719
0
python,egg
The best way to fix it is by creating a directory where it can write it's egg cache. You can specify the directory with the PYTHON_EGG_CACHE variable. [edit] And yes, you can convert your apps so they won't need an egg-cache. If you install the python packages with easy_install you can use easy_install -Z so it won't zip the eggs and it won't need to extract them. You should be able to unzip the current eggs to make sure you won't need them. But personally I would just create the egg cache directory.
0
1
0
1
2010-06-17T18:19:00.000
1
1.2
true
3,064,405
0
0
0
1
Is there an easy way to disable Python egg caching? We have the situation where a system account needs to run a python program which imports a module. Since this is a non-login robot account, it does not have a home directory, and dies trying to create the directory /.python-eggs. What's the best way to fix this? Can I convert my eggs in site-files to something which will not be cached in .python-eggs?
Reboot windows machines at a certain time of day and automatically login with Python
3,066,480
1
1
1,489
0
python,login,restart,boot
I can't think of any way to do strictly what you want off the top of my head other than the registry, at least not without even more drastic measures. But doing this registry modification isn't a big deal; just change the autologon username/password and reboot the computer. To have the computer reboot when the user logs off, give them a "logoff" option that actually reboots rather than logging off; I've seen other places do that. (edit)FYI: for registry edits, Windows has a REG command that will be useful if you decide to go with that route.(/edit) Also, what kind of process are you trying to run? If it's not a GUI app that needs your interaction, you don't have to go through any great pains; just run the app remotely. At my work, we use psexec to do it very simply, and I've also created C++ programs that run code remotely. It's not that difficult, the way I do it is to have C++ call the WinAPI function to remotely register a service on the remote PC and start it, the service then does whatever I want (itself, or as a staging point to launch other things), then unregisters itself. I have only used Python for simple webpage stuff, so I'm not sure what kind of support it has for accessing the DLLs required, but if it can do that, you can still use Python here. Or even better yet, if you don't need to do this remotely but just want it done every night, you can just use the Windows scheduler to run whatever application you want run during the night. You can even do this programmatically as there are a couple Windows commands for that: one is the "at" command, and I don't recall right now what the other is but just a little Googling should find it for you.
0
1
0
0
2010-06-18T00:05:00.000
3
1.2
true
3,066,438
1
0
0
2
I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal. I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?
Reboot windows machines at a certain time of day and automatically login with Python
3,076,111
0
1
1,489
0
python,login,restart,boot
Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or whenever they log off for a period of time, for example). I'm not sure if I necessarily require a GUI app, but the computer would need to boot and login to launch a server application that does the rendering, and I'm not certain if that can be done without logging in. What i'm needing to run is Autodesk's Backburner Server.exe Maybe that can be run without needing to be logged in specifically, but I'm unfamiliar with doing things of that nature.
0
1
0
0
2010-06-18T00:05:00.000
3
0
false
3,066,438
1
0
0
2
I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal. I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?
django on appengine
13,855,137
0
1
253
0
python,django,google-app-engine
Appengine comes with built in Django, if you look under your (google_appengine/lib/django_1_3) lib dir you will see a few versions. You can define what version you want to be used in your app.yaml It isn't a full release of Django and if you do want to have full admin functionality of Django you might have to use something like nonrel but personally I would say its not necessary and you stand to gain more by getting to understand the underlying nosql structure of appengine, in particular the NDB model is very useful
0
1
0
0
2010-06-18T05:48:00.000
3
0
false
3,067,452
0
0
1
1
I am impressed with django.Am am currenty a java developer.I want to make some cool websites for myself but i want to host it in some third pary environmet. Now the question is can i host the django application on appengine?If yes , how?? Are there any site built using django which are already hosted on appengine?
Need a way to determine if a file is done being written to
3,073,958
1
8
8,480
0
python,windows,linux,pdf,file-io
I ended up resolving it for our situation. As it turns out the process that was writing the files out had them opened exclusively so all we had to do was try opening them for read access - when denied they were in use.
0
1
1
0
2010-06-18T13:59:00.000
2
1.2
true
3,070,210
0
0
0
2
The situation I'm in is this - there's a process that's writing to a file, sometimes the file is rather large say 400 - 500MB. I need to know when it's done writing. How can I determine this? If I look in the directory I'll see it there but it might not be done being written. Plus this needs to be done remotely - as in on the same internal LAN but not on the same computer and typically the process that wants to know when the file writing is done is running on a Linux box with a the process that's writing the file and the file itself on a windows box. No samba isn't an option. xmlrpc communication to a service on that windows box is an option as well as using snmp to check if that's viable. Ideally Works on either Linux or Windows - meaning the solution is OS independent. Works for any type of file. Good enough: Works just on windows but can be done through some library or whatever that can be accessed with Python. Works only for PDF files. Current best idea is to periodically open the file in question from some process on the windows box and look at the last bytes checking for the PDF end tag and accounting for the eol differences because the file may have been created on Linux or Windows.
Need a way to determine if a file is done being written to
3,070,749
8
8
8,480
0
python,windows,linux,pdf,file-io
There are probably many approaches you can take. I would try to open the file with write access. If that succeeds then no-one else is writing to that file. Build a web service around this concept if you don't have direct access to the file between machines.
0
1
1
0
2010-06-18T13:59:00.000
2
1
false
3,070,210
0
0
0
2
The situation I'm in is this - there's a process that's writing to a file, sometimes the file is rather large say 400 - 500MB. I need to know when it's done writing. How can I determine this? If I look in the directory I'll see it there but it might not be done being written. Plus this needs to be done remotely - as in on the same internal LAN but not on the same computer and typically the process that wants to know when the file writing is done is running on a Linux box with a the process that's writing the file and the file itself on a windows box. No samba isn't an option. xmlrpc communication to a service on that windows box is an option as well as using snmp to check if that's viable. Ideally Works on either Linux or Windows - meaning the solution is OS independent. Works for any type of file. Good enough: Works just on windows but can be done through some library or whatever that can be accessed with Python. Works only for PDF files. Current best idea is to periodically open the file in question from some process on the windows box and look at the last bytes checking for the PDF end tag and accounting for the eol differences because the file may have been created on Linux or Windows.
ZeroConf Chat with Python
3,072,977
0
0
1,923
0
python,linux,bonjour,zeroconf,chatbot
The easiest thing to do is to use Telepathy Salut or Pidgin/libpurple, and talk with it over D-Bus.
0
1
0
0
2010-06-18T20:43:00.000
2
0
false
3,072,934
0
0
0
1
I am trying to set up a Bonjour (or Ahavi) chatbot for our helpdesk system that would answer basic questions based on a menu system. The basis of my question is how do I get python to create the bot so that it connects to the network as a chat client. Basically, anyone on my network with iChat or Empathy (or any chat program able to view users over the local network) should see the bot just as they see another user. The actual bot part would be quite simple to program, but I have no idea how to get it on the network. I have looked into ZeroConf, but I'm not exactly sure how it works, or how to get a chat service running with python. I have seen references to pybonjour, python bindings for avahi, and pyzeroconf, but again, I have no idea how to set them up. If anyone could give an example, or reference, or even a good article to read on the subject, it would be much appreciated. Thanks! Kory
Does GQL automatically add an "ID" Property
3,078,018
4
1
282
1
python,google-app-engine,gql
An object has a Key, part of which is either an automatically-generated numeric ID, or an assigned key name. IDs are not guaranteed to be increasing, and they're almost never going to be consecutive because they're allocated to an instance in big chunks, and IDs unused by the instance to which they're allocated will never be used by another instance (at least, not currently). They're also only unique within the same entity group for a kind; they're not unique to the entire kind if you have parent relationships.
0
1
0
0
2010-06-19T20:38:00.000
3
0.26052
false
3,077,156
0
0
1
2
I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically? regards,
Does GQL automatically add an "ID" Property
3,077,170
3
1
282
1
python,google-app-engine,gql
Yes, they have id's by default, and it is named ID as you mentioned.
0
1
0
0
2010-06-19T20:38:00.000
3
1.2
true
3,077,156
0
0
1
2
I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically? regards,
Adding printf to the starting of all functions in a file
3,078,693
24
9
937
0
python,c,perl
Just pass -finstrument-functions to gcc when compiling. See the gcc(1) man page for details.
0
1
0
0
2010-06-20T08:47:00.000
2
1
false
3,078,680
1
0
0
1
I have some very large C files, having lots of functions. I need to trace the execution path at run time. There is no way I can trace it through debugging as its a hypervisor code currently running over qemu and doing a lot of binary translations. Can anyone point me to some script in Perl or Python which can add a printf at the starting of all functions and the text could be something like "I am in < function name >"?
is mac good for python programming?
3,081,478
0
3
3,465
0
python,macos
FWIW, mod_wsgi is developed on MacOS X. My experience in supporting users of mod_wsgi is however that MacPorts and fink are an absolute PITA. Specifically, trying to use Python and Apache from those third party systems usually causes nothing but hurt. This is based on problems encountered over the last couple of years. I haven't heard much lately though, so it may be the case that those systems have finally fixed up their 32/64 bit issues and Python build problems.
0
1
0
0
2010-06-20T16:40:00.000
4
0
false
3,080,019
1
0
0
3
I am programming a django based website. I actually use a small computer under Ubuntu 10.04. I would like to buy something more professional, so I am wondering whether an iMac is good for that, because : Is there a free IDE as good as eclipse on MacOS ? Is there a remote python debugger like pydev for eclipse ? Is there some typical issues with python on MacOS ? does apache+mod_wsgi works well on MacOS ?
is mac good for python programming?
3,080,040
5
3
3,465
0
python,macos
All of the things you mentioned (Eclipse+plugins, Python, Apache, mod_wsgi) can run fine on OS X.
0
1
0
0
2010-06-20T16:40:00.000
4
0.244919
false
3,080,019
1
0
0
3
I am programming a django based website. I actually use a small computer under Ubuntu 10.04. I would like to buy something more professional, so I am wondering whether an iMac is good for that, because : Is there a free IDE as good as eclipse on MacOS ? Is there a remote python debugger like pydev for eclipse ? Is there some typical issues with python on MacOS ? does apache+mod_wsgi works well on MacOS ?
is mac good for python programming?
3,080,121
6
3
3,465
0
python,macos
Why do you consider iMac to be more or less professional than anything else? Hardware? System? Note: I'm myself a MacOSX and Linux user. Unless it's a requisite, most times I'd say it's only a matter of personal taste. As said by others earlier, everything you cited works fine on MacOSX. However, you should consider the 3rd party libraries you're going to use with Python. I would cite a problem I had with MySQLdb (MySQL-python) on MacOSX, but it has been solved. You might face other problems in the way, but nothing that could stop you from using Django, Eclipse, etc.
0
1
0
0
2010-06-20T16:40:00.000
4
1.2
true
3,080,019
1
0
0
3
I am programming a django based website. I actually use a small computer under Ubuntu 10.04. I would like to buy something more professional, so I am wondering whether an iMac is good for that, because : Is there a free IDE as good as eclipse on MacOS ? Is there a remote python debugger like pydev for eclipse ? Is there some typical issues with python on MacOS ? does apache+mod_wsgi works well on MacOS ?
How to exit when viewing python help like help(os.listdir)
38,031,055
2
44
40,312
0
python
Other options to exit the help screen would be to type any one of the following(as described in the help section) q,:q,Q,:Q and ZZ .These can be seen when you press 'h' once you are on the help screen
0
1
0
0
2010-06-20T19:05:00.000
2
0.197375
false
3,080,563
0
0
0
1
when the help window pops up, what are the basic commands (mac os) to page up/down, end of document and exiting the help screen? I just had to close my terminal as I couldn't figure it out!
what does python.exe take as arguments?
3,088,518
8
7
12,210
0
python,arguments
It takes any options for python.exe itself, then the name of the file (or command or module), then any arguments to be passed to your program. If no file is specified, it puts you in interactive mode. As indicated in the comments by Adam, type python -h to see the full list.
0
1
0
0
2010-06-21T21:01:00.000
2
1.2
true
3,088,493
1
0
0
1
does it take the filename of the .py and then what?
How to trap a copy/move-file operation in a custom filesystem based on Fuse?
7,040,661
0
2
1,016
0
python,fuse
Copy is as Weholt said: difficult to trap because it is basically the same as creating a new file and writing to it. Move is the same operation as a rename.
0
1
0
0
2010-06-22T07:39:00.000
3
0
false
3,091,166
0
0
0
2
I`m implementing a custom filesystem on Ubuntu using Fuse, but I need to trap when a copy or move operation occur. Right now all I see are when some file are opened for writing or reading, but I need to see these operations in context so I can see what file are being copied or moved. Any hints?
How to trap a copy/move-file operation in a custom filesystem based on Fuse?
3,091,286
0
2
1,016
0
python,fuse
What you want to do is probably not easily done, considering that a "copy" or "move" program could do just what you see - open a file and write to it. That's a perfectly good way of copying a file. Even if you can see what actual binary is doing it, that wouldn't give you enough information to know if this was a copy, a move or simply a program writing data to a file. If you tell us why you need to do this, then maybe someone can suggest another solution, that fulfills your needs.
0
1
0
0
2010-06-22T07:39:00.000
3
0
false
3,091,166
0
0
0
2
I`m implementing a custom filesystem on Ubuntu using Fuse, but I need to trap when a copy or move operation occur. Right now all I see are when some file are opened for writing or reading, but I need to see these operations in context so I can see what file are being copied or moved. Any hints?
sound way to feed commands to twisted ssh after reactor.run()
3,102,192
0
3
1,007
0
python,ssh,twisted
You're trying to put a square peg in a round hole. Everything in Twisted is asynchronous, so you have to think about the sequence of events differently. You can't say "here are 10 operations to be run one after the other" that's serial thinking. In Twisted you issue the first command and register a callback that will be triggered when it completes. When that callback occurs you issue the 2nd command and register a callback that will be triggered when that completes. And so on and so on.
0
1
0
0
2010-06-23T13:36:00.000
2
0
false
3,102,098
0
0
0
1
Guys this is a question about python twisted ssh lib. All sample code even production code I saw acting as a ssh client based on twisted.conch.ssh are all interacting with server in such a mode: prepare some commands to run remotely; define call backs; kick off reactor then suspend for new feedback; After the reactor.run(), I never found people tried to deliver commands to sshd, the script just sit their waiting. I think it'll be possible to fork or spawn stuffs to send commands. However since one of twisted's strengths is its de-multiplexing mechanism so it doesn't have to fork to process incoming requests when running as a server. May I say it is a reasonable requirement not to fork (as a client script) to continuously send requests to server? Any thought on this ? TIA.
Determine user connecting a local socket with Python
3,107,066
1
2
195
0
python,sockets
Unfortunately, at this point in time the python libraries don't support the usual SCM_CREDENTIALS method of passing credentials along a Unix socket. You'll need to use an "ugly" method as described in another answer to find it.
0
1
1
0
2010-06-23T21:30:00.000
3
0.066568
false
3,105,705
0
0
0
1
If Python, if you are developing a system service that communicates with user applications through sockets, and you want to treat sockets connected by different users differently, how would you go about that? If I know that all connecting sockets will be from localhost, is there a way to lookup through the OS (either on windows or linux) which user is making the connection request?
In Python script, how do I set PYTHONPATH?
48,543,222
-4
146
173,492
0
python,linux,unix,environment-variables
you can set PYTHONPATH, by os.environ['PATHPYTHON']=/some/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective.
0
1
0
0
2010-06-24T08:25:00.000
6
-1
false
3,108,285
1
0
0
1
I know how to set it in my /etc/profile and in my environment variables. But what if I want to set it during a script? Is it import os, sys? How do I do it?
os.path.exists() lies
3,112,744
1
14
7,646
0
python
The problem is related to the fact that the Python process runs in its own shell. When you run subprocess.Popen(shell=True) you are spawning a new shell, which is working around the issue you're experiencing. Python is not causing this issue. It's a combination of how NFS (file storage) and directory listings function in Linux.
0
1
0
0
2010-06-24T17:48:00.000
2
0.099668
false
3,112,546
0
0
0
1
I'm running a number of python scripts on a linux cluster, and the output from one job is generally the input to another script, potentially run on another node. I find that there is some not insignificant lag before python notices files that have been created on other nodes -- os.path.exists() returns false and open() fails as well. I can do a while not os.path.exists(mypath) loop until the file appears, and it can take upwards of a full minute, which is not optimal in a pipeline with many steps and potentially running many datasets in parallel. The only workaround I've found so far is to call subprocess.Popen("ls %s"%(pathdir), shell=True), which magically fixes the problem. I figure this is probably a system problem, but any way python might be causing this? Some sort of cache or something? My sysadmin hasn't been much help so far.
PHP vs. Other Languages in Hadoop/MapReduce implementations, and in the Cloud generally
3,113,643
10
3
906
0
java,php,python,hadoop,mapreduce
PHP is designed primarily as a language for displaying output to a browser. Most jobs being run on MapReduce/Hadoop clusters have nothing to do with displaying output. They instead tend to lean much more heavily towards data processing. PHP is not the most commonly supported language for data processing, by far. Thus, it's logical that the most common supported languages for data processing-related technologies don't include PHP.
0
1
0
1
2010-06-24T20:18:00.000
3
1.2
true
3,113,573
0
0
1
2
I'm beginning to learn some Hadoop/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. But, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. I've looked, and it looks like there are some Hadoop/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages. Is there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. If this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries/projects should I look into?
PHP vs. Other Languages in Hadoop/MapReduce implementations, and in the Cloud generally
3,113,644
1
3
906
0
java,php,python,hadoop,mapreduce
The reason is PHP lack of support for multi-threading and process communication.
0
1
0
1
2010-06-24T20:18:00.000
3
0.066568
false
3,113,573
0
0
1
2
I'm beginning to learn some Hadoop/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. But, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. I've looked, and it looks like there are some Hadoop/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages. Is there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. If this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries/projects should I look into?
Update datastore in Google App Engine from the iPhone
3,113,823
5
2
411
0
java,iphone,python,google-app-engine,google-cloud-datastore
Why not have the iPhone application communicate this information to app engine by making a simple HTTP request? Specifically, I would do an HTTP POST to the server and include the relevant fields. Then your app engine request handler would simply store the information in the datastore.
0
1
0
0
2010-06-24T20:44:00.000
1
1.2
true
3,113,734
0
0
1
1
I'm working on an app that communicates with Google App Engine to update and retrieve user information, but I can't think of a way to modify elements in the datastore. For example, every user for my app is represented by a User object in the datastore. If this user inputs things like email, phone number, etc into fields inside the iPhone application, I want to be able to update those objects in the datastore. The datastore can be in Java or Python, I'm just looking for an idea that will work. Thanks
Terminating android ASE shell from within the script
3,125,831
1
2
329
0
python,android,ase
You should use android.exit().
0
1
0
0
2010-06-26T19:56:00.000
2
0.099668
false
3,125,325
0
0
1
2
I'm using android scripting environment with python (ASE), and I'd like to terminate the shell executing the script when the script terminates. Is there a good way to do this? I have tried executing on the last line: os.system( 'kill %d' % os.getppid() ) but to no avail.
Terminating android ASE shell from within the script
3,304,337
0
2
329
0
python,android,ase
My guess is that the above answer ought to be android.Android().exit()
0
1
0
0
2010-06-26T19:56:00.000
2
0
false
3,125,325
0
0
1
2
I'm using android scripting environment with python (ASE), and I'd like to terminate the shell executing the script when the script terminates. Is there a good way to do this? I have tried executing on the last line: os.system( 'kill %d' % os.getppid() ) but to no avail.
Disable all `pylint` 'Convention' messages
3,125,349
28
23
10,285
0
python,pylint
If I'm not mistaken, you should be able to use --disable-msg-cat=C (can't remember whether it's uppercase or lowercase or both) to accomplish this. UPDATE: In later versions of pylint, you should use --disable=C
0
1
0
0
2010-06-26T20:02:00.000
1
1.2
true
3,125,333
0
0
0
1
Background I find pylint useful, but I also find it is horrifically undocumented, has painfully verbose output, and lacks an intuitive interface. I'd like to use pylint, but it keeps pumping out an absurd number of pointless 'convention' messages, e.g. C: 2: Line too long (137/80) etc. Question If I could disable these, pylint would be much more usable for me. How does one disable these 'convention' messages? My own efforts I've tried putting disable-msg=C301 in ~/.pylintrc (which is being loaded because when I put an error in there pylint complains) which I understand to be the "Line too Long" message based on running this command in the pylint package directory (documentation that can be found would be nice): $ grep "Line too long" **/*.py checkers/format.py: 'C0301': ('Line too long (%s/%s)', Yet this disable-msg does nothing. I'd disable the entire convention category with the disable-msg-cat= command, but there's no indication anywhere I can find of what an identifier of the convention category would be for this command — the intuitive disable-message-cat=convention has no effect. I'd be much obliged for some direction on this issue. Thank you. Brian
Is there any linux distribution that comes with python 3?
7,409,203
5
6
5,178
0
python,linux,python-3.x
All of them have the repositories, but if you care for one that has python3 as default, I only know of ArchLinux.
0
1
0
0
2010-06-27T14:49:00.000
6
0.16514
false
3,127,715
1
0
0
4
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
3,128,073
2
6
5,178
0
python,linux,python-3.x
I think most distros have it. Debian has it so all derived distros (Ubuntu et. all) do. Fedora as well. It's just that it's not used for the standard system utilities so just typing python will give you a 2.x interpreter.
0
1
0
0
2010-06-27T14:49:00.000
6
0.066568
false
3,127,715
1
0
0
4
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
3,129,338
1
6
5,178
0
python,linux,python-3.x
Gentoo has Python3 (I have 2.6.4-r1 and 3.1.2-r3 installed, 2.6 being the default). A quick search reveals that ebuilds of python libraries tested on both 2.x and 3.x have already been built for both versions on my machine (thank God for python-updater, obviously). Gentoo + Python developing is a very nice combination (if you do like the way Gentoo works, that is).
0
1
0
0
2010-06-27T14:49:00.000
6
0.033321
false
3,127,715
1
0
0
4
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
3,127,755
11
6
5,178
0
python,linux,python-3.x
Ubuntu 10.04 comes by default w/ Python 2.6.5, but the following python 3 packages are in the standard repositories as well: python3 python3.1-minimal python3-dev python3.0 python3.1-profiler python3-doc python3.1 python3.1-tk python3-examples python3.1-celementtree python3.1-wsgiref python3-gdbm python3.1-cjkcodecs python3.2 python3-gdbm-dbg python3.1-ctypes python3-all python3-minimal python3.1-dbg python3-all-dbg python3-pkg-resources python3.1-dev python3-all-dev python3-profiler python3.1-doc python3-bsddb python3-setuptools python3.1-elementtree python3-bsddb3 python3-tk python3.1-examples python3-bsddb3-dbg python3-tk-dbg python3.1-gdbm python3-dbg update: for *ubuntu 11.04 the list is (as expected) a bit longer) note that I left out the python3.1- and python3.2- prefixed packages): python3-all python3-examples python3-pkg-resources python3-all-dbg python3-gdbm python3-profiler python3-all-dev python3-gdbm-dbg python3-pygments python3-apt python3-gearman.libgearman python3-pyudev python3-apt-dbg python3-httplib2 python3-serial python3-beaker python3-ipaddr python3-setuptools python3-bsddb3 python3-jinja2 python3-sip python3-bsddb3-dbg python3-jinja2-dbg python3-sip-dbg python3-cxx python3-lxml python3-sip-dev python3-cxx-dev python3-lxml-dbg python3-sqlalchemy python3-dbg python3-mako python3-tk python3-dev python3-markupsafe python3-tk-dbg python3-distutils-extra python3-markupsafe-dbg python3-yaml python3-dns python3-minimal python3-yaml-dbg python3-doc python3-objgraph python3-zope.fixers UPDATE (2013-03-21): The current version of *buntu (12.10) already has fairly many Python 3 packages available (>200; too many to list). Prominent exceptions include python3-django and python3-matplotlib (though the latter will be included in 13.04 Raring Ringtail). If you require a package not yet in the package manager but already ported, 12.10 includes both pip and easy_install for Python 3.
0
1
0
0
2010-06-27T14:49:00.000
6
1.2
true
3,127,715
1
0
0
4
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is it possible to run two versions of Python side-by-side?
3,130,801
0
4
758
0
python,google-app-engine
OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer: 1) Install Python 2.5. 2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default. 3) Install the Google App Engine SDK. 4) Launch, "Google App Engine Launcher" from the Start Menu 5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe
0
1
0
0
2010-06-27T16:07:00.000
3
0
false
3,127,915
1
0
1
2
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Is it possible to run two versions of Python side-by-side?
3,127,950
5
4
758
0
python,google-app-engine
Absolutely. If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course. Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.) Windows users generally just install to different directories.
0
1
0
0
2010-06-27T16:07:00.000
3
0.321513
false
3,127,915
1
0
1
2
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
How to Log All IRC data on Channel Using Twisted?
3,128,285
0
0
617
0
python,twisted,logging,irc
I don't think you can do this if you just connect to a server... the servers don't send you messages for channels you haven't joined. Or are you the host of the server?
0
1
0
1
2010-06-27T16:41:00.000
2
0
false
3,128,025
0
0
0
2
I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages/commands/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?
How to Log All IRC data on Channel Using Twisted?
5,207,277
1
0
617
0
python,twisted,logging,irc
We addressed this issue in a somewhat round about way. We worked off a generic hexdumping proxy server constructed in twisted and then created finer detail parsing algorithms off of that.
0
1
0
1
2010-06-27T16:41:00.000
2
1.2
true
3,128,025
0
0
0
2
I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages/commands/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?
How to 'catch' c printf in python with ctypes?
3,133,108
0
5
2,287
0
python,c,printf,ctypes
Well printf simply writes its output to whatever the stdout file pointer refers to. Im not sure how you're executing the C program, but it should be possible to redirect the C program's stdout to something that you can read in Python.
0
1
0
0
2010-06-28T11:38:00.000
2
0
false
3,131,977
0
0
0
1
I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this? Thanks
How do I access the command history from IDLE?
3,132,305
49
114
75,492
0
python,python-idle
just use Alt+P to go up. Similarly, Alt+N could be used to go down.
0
1
0
0
2010-06-28T12:20:00.000
5
1
false
3,132,265
1
0
0
2
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result. But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied? Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?
How do I access the command history from IDLE?
26,785,641
12
114
75,492
0
python,python-idle
If you're on mac, it's ctrl+p.
0
1
0
0
2010-06-28T12:20:00.000
5
1
false
3,132,265
1
0
0
2
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result. But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied? Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?
How to properly use PyDev with two different Python versions with scripts that are recalling other python scripts?
3,165,062
0
2
1,364
0
python,windows,environment-variables
I believe your call should be: import sys os.system(sys.executable+ ' second.py') So that you guarantee you're using the same interpreter you're currently running and not launching the other one (or did you really mean to use the other interpreter?)
0
1
0
0
2010-06-28T15:22:00.000
3
0
false
3,133,690
1
0
0
2
The story began with a very strange error while I was running my script from PyDev. Running the same script from outside will not encounter the same problem. Fatal Python error: Py_Initialize: can't initialize sys standard streams File "C:\Python26\lib\encodings\__init__.py", line 123 raise CodecRegistryError,\ ^ SyntaxError: invalid syntax This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I was able to find why this is happening: In PyDev I use two different Python versions: 3.1 that is the default installation and 2.6 as the alternative one. My Windows Environment does not contains PYTHONHOME, CLASSPATH, PYTHONPATH but PyDev does add them. Now the problem is at one stage my python script does execute another python script using os.system(python second.py) and the second script will fail with the above error. Now I'm looking to find a way to prevent this issue, issue that is happening because it will run the execute the default python using the settings for the non-default one (added by PyDev). I do not want to change the standard call (python file.py) but I want to be able to run my script from pydev without problem and being able to use default or alternative python environment. Any ideas?
How to properly use PyDev with two different Python versions with scripts that are recalling other python scripts?
3,133,843
2
2
1,364
0
python,windows,environment-variables
I found a solution that seams acceptable specially because it will not interfere with running the scripts on other systems, just to run python -E second.py - this will force Python to ignore PYTHON* environment variables.
0
1
0
0
2010-06-28T15:22:00.000
3
1.2
true
3,133,690
1
0
0
2
The story began with a very strange error while I was running my script from PyDev. Running the same script from outside will not encounter the same problem. Fatal Python error: Py_Initialize: can't initialize sys standard streams File "C:\Python26\lib\encodings\__init__.py", line 123 raise CodecRegistryError,\ ^ SyntaxError: invalid syntax This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I was able to find why this is happening: In PyDev I use two different Python versions: 3.1 that is the default installation and 2.6 as the alternative one. My Windows Environment does not contains PYTHONHOME, CLASSPATH, PYTHONPATH but PyDev does add them. Now the problem is at one stage my python script does execute another python script using os.system(python second.py) and the second script will fail with the above error. Now I'm looking to find a way to prevent this issue, issue that is happening because it will run the execute the default python using the settings for the non-default one (added by PyDev). I do not want to change the standard call (python file.py) but I want to be able to run my script from pydev without problem and being able to use default or alternative python environment. Any ideas?
Switch python distributions
3,134,369
1
1
645
0
python,osx-snow-leopard,numpy,macports
You need to update your PATH so that the stuff from MacPorts is in front of the standard system directories, e.g., export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:$PATH. UPDATE: Pay special attention to the fact that /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin is in front of your old PATH value.
0
1
0
0
2010-06-28T16:43:00.000
3
0.066568
false
3,134,332
0
1
0
1
I have a MacBook Pro with Snow Leopard, and the Python 2.6 distribution that comes standard. Numpy does not work properly on it. Loadtxt gives errors of the filename being too long, and getfromtxt does not work at all (no object in module error). So then I tried downloading the py26-numpy port on MacPorts. Of course when I use python, it defaults the mac distribution. How can I switch it to use the latest and greatest from MacPorts. This seems so much simpler than building all the tools I need from source... Thanks!
SSH Dynamic Port Forwarding ('ssh -D') in Python
3,141,104
1
4
1,634
0
python,windows,ssh,tunneling,ssh-tunnel
There are ssh executables for Windows, so you can uses the subprocess.Popen approach. This is not exactly elegant, a pure Python approach would be better.
0
1
0
1
2010-06-29T13:28:00.000
2
0.099668
false
3,141,063
0
0
0
1
I'm looking for a way to implement SSH Dynamic Port Forwarding ('ssh -D') under Python. The problem is that it has to work under Windows, i.e., running SSH with popen/pexec/etc. won't work. Any ideas? cheers, Bruno Nery.
os.path.getmtime of shared files in Dropbox
3,142,886
1
1
384
0
python,dropbox
It looks that Dropbox preserves mtime when synchronizing files. Try to detect changed file by changed file size and/or checksum (MD5, SHA1 or so) instead of modification time. Or just ask Dropbox :) (I don't know if it has any API for this).
0
1
0
0
2010-06-29T16:38:00.000
1
0.197375
false
3,142,770
0
0
0
1
I want to run a script to check whether certain files in my Dropbox folder have changed. I am currently using os.path.getmtime() to check that the modified time is in some window of time.time(). The problem is that if I modify a file in my Dropbox folder from a different computer than where the script is set to run, the modified time does not change on that latter computer. Is there a good way to watch shared files that doesn't run into this problem? Thanks for any help! I am just getting into python. *******UPDATE******* I have been playing more with how Dropbox handles file timestamping. It only updates the mtime if the file changes. If you open a file, modify it, but save it unchanged, the mtime stays the same.