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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is it possible to get python purple running either in cygwin or on a linux that isn't debian? | 1,250,118 | 5 | 0 | 266 | 0 | python,linux,cygwin,debhelper | Both cdbs and debhelper are only needed if you are trying to build a debian package. Just do a regular python setup.py build, and it should work fine (assuming you have the other prerequisites available). | 0 | 1 | 0 | 0 | 2009-08-03T21:30:00.000 | 1 | 1.2 | true | 1,224,726 | 0 | 0 | 0 | 1 | python purple says it needs dbms and debhelper in order to run, but I don't run debian. Is there a way to get this running on a different linux? or in cygwin? |
In Twisted Python - Make sure a protocol instance would be completely deallocated | 1,236,382 | 0 | 4 | 721 | 0 | python,sockets,twisted,twisted.words | ok, for sorting out this issue I have set a __del__ method in the protocol class and I am now logging protocol instances that have not been garbage collected within 1 minute from the time the client has disconnected.
If anybody has any better solution I'll still be glad to hear about it but so far I have already fixed a few potential memory leaks using this log.
Thanks! | 0 | 1 | 1 | 0 | 2009-08-05T16:23:00.000 | 1 | 1.2 | true | 1,234,292 | 0 | 0 | 0 | 1 | I have a pretty intensive chat socket server written in Twisted Python, I start it using internet.TCPServer with a factory and that factory references to a protocol object that handles all communications with the client.
How should I make sure a protocol instance completely destroys itself once a client has disconnected?
I've got a function named connectionLost that is fired up once a client disconnects and I try stopping all activity right there but I suspect some reactor stuff (like twisted.words instances) keep running for obsolete protocol instances.
What would be the best approach to handle this?
Thanks! |
Cron job python Google App Engine | 1,237,224 | 0 | 0 | 1,453 | 0 | python,google-app-engine,cron,scheduled-tasks | "fetch" your OWN url (on appspot.com probably, but, who cares -- use a relative url anywau1-), not google.com, the homepage of the search engine -- what's that got to do w/your app anyway?!-)... | 0 | 1 | 0 | 0 | 2009-08-06T05:32:00.000 | 1 | 0 | false | 1,237,126 | 0 | 0 | 1 | 1 | I want to add a scheduled task to fetch a URL via cron job using google app engine. I am continuously getting a failure. I am just fetching www.google.com. Why is the url fetch failing? Am I missing something? |
curses-like library for cross-platform console app in python | 1,244,980 | -7 | 24 | 13,292 | 0 | python,windows,linux,console,ncurses | develop two interfaces for your program, a text console ui and a graphical ui. Make the console one work only on linux. Nobody on windows uses text console apps. | 0 | 1 | 0 | 0 | 2009-08-07T14:06:00.000 | 5 | -1 | false | 1,244,897 | 1 | 0 | 0 | 1 | I'm looking into developing a console application in python which should be able to run under Windows as well as Linux. For this, I'd really like to use a high-level console library like curses. However, as far as I know, curses is not available on Windows.
What other options do I have? Unfortunately, using cygwin under Windows is not an option...
Thanks for your help! |
Run Python script without opening Pythonwin | 1,245,828 | 3 | 2 | 6,240 | 0 | python | Rename it to *.pyw to hide the console on execution in Windows. | 0 | 1 | 0 | 1 | 2009-08-07T16:48:00.000 | 4 | 0.148885 | false | 1,245,818 | 0 | 0 | 0 | 1 | I have a python script which I can run from pythonwin on which I give the arguments.
Is it possible to automate this so that when I just click on the *.py file, I don't see the script and it asks for the path in a dos window? |
Python/mySQL on an Embedded ARM9 Device? | 4,729,963 | -1 | 0 | 1,766 | 0 | python,arm,embedded | I suggest using SQLite. I have an application running Python+SQLite for telemetry purposes and it works like a charm. It's much easier than MySQL. | 0 | 1 | 0 | 0 | 2009-08-07T18:12:00.000 | 2 | -0.099668 | false | 1,246,235 | 0 | 0 | 0 | 1 | I have an application where a small embedded ARM9 device (running Linux) must gather information from sensors and then connect to a remote mySQL database and INSERT the data. I have Python 2.5 running on the ARM9 device fine. I have developed a prototype application in Python 2.5 running on x86 Windows and it connects with mySQL and INSERTS just fine. My confusion in this issue come from working with "mySQL Connect/C" which would have to be cross compiled for the ARM processor before being used.
What is the best way to port or move this DB app onto the ARM device?
Are there underlying x86 binaries in supporting libraries that must be cross compiled?
Or, is MySQLdb simply portable across platforms? |
Manipulate MP3 programmatically: Muting certain parts? | 5,060,666 | 1 | 5 | 1,648 | 0 | java,python,audio,mp3 | One (somehow pretentious) idea: record a mute (silent) mp3 in bitrate that your mp3 is. Then, copy all the frames from original mp3 up to the point when you want your silence to start. Then, copy as much muted frames you need from your 'silence file'. Then, copy the rest from the original file.
You'll have muted file without re-encoding the file! | 0 | 1 | 0 | 0 | 2009-08-08T22:57:00.000 | 4 | 0.049958 | false | 1,250,086 | 0 | 0 | 1 | 1 | I'm trying to write a batch process that can take an MP3 file and mute certain parts of it, ideally in Python or Java.
Take this example: Given a 2 minute MP3, I want to mute the time between 1:20 and 1:30. When saved back to a file, the rest of the MP3 will play normally -- only that portion will be silent.
Any advice for setting this up in a way that's easy to automate/run on the command line would be fantastic! |
Creating alternative login to Google Users for Google app engine | 1,251,369 | 1 | 4 | 928 | 0 | python,google-app-engine,model-view-controller,google-cloud-datastore | If you roll your own user model, you're going to need to do your own session handling as well; the App Engine Users API creates login sessions for you behind the scenes.
Also, while this should be obvious, you shouldn't store the user's password in plaintext; store an SHA-1 hash and compare it to a hash of the user's submitted password when they login. | 0 | 1 | 0 | 0 | 2009-08-09T02:46:00.000 | 2 | 0.099668 | false | 1,250,437 | 0 | 0 | 1 | 1 | How does one handle logging in and out/creating users, without using Google Users? I'd like a few more options then just email and password. Is it just a case of making a user model with the fields I need? Is that secure enough?
Alternatively, is there a way to get the user to log in using the Google ID, but without being redirected to the actual Google page? |
Writing Windows GUI applications with embedded Python scripts | 1,251,275 | 3 | 1 | 1,987 | 0 | python,windows,user-interface | I would recommend that you use IronPython, which is Microsoft's implementation of Python for the .NET framework. | 0 | 1 | 0 | 0 | 2009-08-09T12:04:00.000 | 3 | 0.197375 | false | 1,251,260 | 1 | 0 | 0 | 1 | What would be the optimal way to develop a basic graphical application for Windows based on a Python console script? It would be great if the solution could be distributed as a standalone directory, containing the .exe file. |
Has anyone succeeded in using Google App Engine with Python version 2.6? | 1,255,893 | 6 | 9 | 3,409 | 0 | python,google-app-engine | There are a few issues with using Python 2.6 with the SDK, mostly related to the SDK's sandboxing, which is designed to imitate the sandbox limitations in production. Note, of course, that even if you get Python 2.6 running with the SDK, your code will still have to run under 2.5 in production. | 0 | 1 | 0 | 0 | 2009-08-10T09:58:00.000 | 2 | 1 | false | 1,254,028 | 0 | 0 | 1 | 1 | Since Python 2.6 is backward compatible to 2.52 , did anyone succeeded in using it with Google app Engine ( which supports 2.52 officially ).
I know i should try it myself. But i am a python and web-apps new bee and for me installation and configuration is the hardest part while getting started with something new in this domain.
( .... I am trying it myself in the meanwhile ....)
Thanks |
Is it possible to add a network drive to %PATH% environment variable | 1,272,313 | 4 | 1 | 5,469 | 0 | python,windows,sysinternals | Yes you can put a UNC path in your %PATH% env variable, and it will work if you have access to that path with your current session. | 0 | 1 | 0 | 0 | 2009-08-13T14:17:00.000 | 2 | 0.379949 | false | 1,272,242 | 0 | 0 | 0 | 1 | I have a python script calling an exe file. The exe file can be in the same folder as that of the python script or in a network drive. Is it possible to call the exe if it is in a remote drive/computer? Can this be done by setting the %PATH% variable |
How do you install lxml on OS X Leopard without using MacPorts or Fink? | 1,277,175 | -5 | 36 | 27,228 | 0 | python,macos,shell,lxml,osx-leopard | I compile it in /usr/local without any issues whatsoever.
Install Python, libxml2, libxslt and then lxml. You might need setuptools installed too. | 0 | 1 | 0 | 0 | 2009-08-14T10:22:00.000 | 15 | -1 | false | 1,277,124 | 0 | 0 | 0 | 2 | I've tried this and run in to problems a bunch of times in the past. Does anyone have a recipe for installing lxml on OS X without MacPorts or Fink that definitely works?
Preferably with complete 1-2-3 steps for downloading and building each of the dependencies. |
How do you install lxml on OS X Leopard without using MacPorts or Fink? | 7,850,559 | 1 | 36 | 27,228 | 0 | python,macos,shell,lxml,osx-leopard | I had this working fine with Snow Lepoard but after I upgraded to Lion I had to symlink gcc-4.2 to gcc. Running sudo env ARCHFLAGS="-arch i386 -arch x86_64" easy_install lxml was looking for gcc-4.2 instead of gcc. | 0 | 1 | 0 | 0 | 2009-08-14T10:22:00.000 | 15 | 0.013333 | false | 1,277,124 | 0 | 0 | 0 | 2 | I've tried this and run in to problems a bunch of times in the past. Does anyone have a recipe for installing lxml on OS X without MacPorts or Fink that definitely works?
Preferably with complete 1-2-3 steps for downloading and building each of the dependencies. |
Python - capture Popen stdout AND display on console? | 1,283,191 | 1 | 5 | 11,350 | 0 | python,pipe,popen | Alternatively, you can pipe your process into tee and capture only one of the streams.
Something along the lines of sh -c 'process interesting stuff' | tee /dev/stderr.
Of course, this only works on Unix-like systems. | 0 | 1 | 0 | 0 | 2009-08-15T22:48:00.000 | 5 | 0.039979 | false | 1,283,061 | 0 | 0 | 0 | 2 | I want to capture stdout from a long-ish running process started via subprocess.Popen(...) so I'm using stdout=PIPE as an arg.
However, because it's a long running process I also want to send the output to the console (as if I hadn't piped it) to give the user of the script an idea that it's still working.
Is this at all possible?
Cheers. |
Python - capture Popen stdout AND display on console? | 1,283,062 | 1 | 5 | 11,350 | 0 | python,pipe,popen | Can you simply print it as you read it from the pipe? | 0 | 1 | 0 | 0 | 2009-08-15T22:48:00.000 | 5 | 1.2 | true | 1,283,061 | 0 | 0 | 0 | 2 | I want to capture stdout from a long-ish running process started via subprocess.Popen(...) so I'm using stdout=PIPE as an arg.
However, because it's a long running process I also want to send the output to the console (as if I hadn't piped it) to give the user of the script an idea that it's still working.
Is this at all possible?
Cheers. |
Entity Framwework-like ORM NOT for .NET | 1,325,558 | 0 | 2 | 433 | 1 | php,python,entity-framework,open-source | I have heard iBattis is good. A few companies fall back to iBattis when their programmer teams are not capable of understanding Hibernate (time issue).
Personally, I still like Linq2Sql. Yes, the first time someone needs to delete and redrag over a table seems like too much work, but it really is not. And the time that it doesn't update your class code when you save is really a pain, but you simply control-a your tables and drag them over again. Total remakes are very quick and painless. The classes it creates are extremely simple. You can even create multiple table entities if you like with SPs for CRUD.
Linking SPs to CRUD is similar to EF: You simply setup your SP with the same parameters as your table, then drag it over your table, and poof, it matches the data types.
A lot of people go out of their way to take IQueryable away from the repository, but you can limit what you link in linq2Sql, so IQueryable is not too bad.
Come to think of it, I wonder if there is a way to restrict the relations (and foreign keys). | 0 | 1 | 0 | 0 | 2009-08-16T07:03:00.000 | 3 | 0 | false | 1,283,646 | 0 | 0 | 1 | 1 | What I really like about Entity framework is its drag and drop way of making up the whole model layer of your application. You select the tables, it joins them and you're done. If you update the database scheda, right click -> update and you're done again.
This seems to me miles ahead the competiting ORMs, like the mess of XML (n)Hibernate requires or the hard-to-update Django Models.
Without concentrating on the fact that maybe sometimes more control over the mapping process may be good, are there similar one-click (or one-command) solutions for other (mainly open source like python or php) programming languages or frameworks?
Thanks |
How can I check to see if a Python script was started interactively? | 1,285,056 | 11 | 2 | 1,179 | 0 | python,interactive | You should simply add a command-line switch in the scheduled task, and check for it in your script, modifying the behavior as appropriate. Explicit is better than implicit.
One benefit to this design: you'll be able to test both behaviors, regardless of how you actually invoked the script. | 0 | 1 | 0 | 1 | 2009-08-16T18:48:00.000 | 3 | 1 | false | 1,285,024 | 0 | 0 | 0 | 1 | I'd like for a script of mine to have 2 behaviours, one when started as a scheduled task, and another if started manually. How could I test for interactiveness?
EDIT: this could either be a cron job, or started by a windows batch file, through the scheduled tasks. |
Implement Comet / Server push in Google App Engine in Python | 2,784,805 | 1 | 25 | 11,567 | 0 | python,google-app-engine,comet,server-push,channel-api | 30 seconds is more than enough; either way you should return a no-op message when a time passed and no new events occur.
This prevents client timeouts and is done by everybody who does comet.
Just send the request, and on the server make it wait until an event or timeout after 25 seconds. | 0 | 1 | 0 | 0 | 2009-08-16T19:34:00.000 | 6 | 0.033321 | false | 1,285,150 | 0 | 0 | 1 | 4 | How can I implement Comet / Server push in Google App Engine in Python? |
Implement Comet / Server push in Google App Engine in Python | 3,918,651 | 0 | 25 | 11,567 | 0 | python,google-app-engine,comet,server-push,channel-api | Looking inside the App Engine 1.3.8-pre release, I see the Channel API service stub and more code. So it looks like we can start trying it out locally. | 0 | 1 | 0 | 0 | 2009-08-16T19:34:00.000 | 6 | 0 | false | 1,285,150 | 0 | 0 | 1 | 4 | How can I implement Comet / Server push in Google App Engine in Python? |
Implement Comet / Server push in Google App Engine in Python | 1,285,251 | 3 | 25 | 11,567 | 0 | python,google-app-engine,comet,server-push,channel-api | At this time, I would rule out doing Comet in App Engine (any language). Comet is based on long-lived HTTP connections, and App Engine will time out any single connection in about 30 seconds or so at most; it's hard to conceive of a worse match! | 0 | 1 | 0 | 0 | 2009-08-16T19:34:00.000 | 6 | 0.099668 | false | 1,285,150 | 0 | 0 | 1 | 4 | How can I implement Comet / Server push in Google App Engine in Python? |
Implement Comet / Server push in Google App Engine in Python | 4,480,891 | 0 | 25 | 11,567 | 0 | python,google-app-engine,comet,server-push,channel-api | Google App Engine supports server push using the Channel API since 2nd December. | 0 | 1 | 0 | 0 | 2009-08-16T19:34:00.000 | 6 | 0 | false | 1,285,150 | 0 | 0 | 1 | 4 | How can I implement Comet / Server push in Google App Engine in Python? |
how to register more than 10 apps in Google App Engine | 1,294,678 | 3 | 14 | 1,877 | 0 | python,google-app-engine,registration | Call or write to Google! Google's policies are very exact and very strict, because they are catering to thousands of developers, and thus need those standards and uniformity. But if you have a good reason for needing more than 10, and you can get a real person at the end of a telephone line, I'd think you'd have a good chance of getting the limit raised.
Alternatively, you could just get a friend or co-worker to register. That seems like it ought to be legal...but check the User Agreement first. | 0 | 1 | 0 | 0 | 2009-08-18T15:25:00.000 | 1 | 0.53705 | false | 1,294,618 | 0 | 0 | 1 | 1 | Anyone knows any "legal" way to surpass the 10-app-limit Google imposes?
I wouldn't mind to pay, or anything, but I wasn't able to find a way to have more
than 10 apps and can't either remove one. |
How to check if python is installed in windows from java? | 1,299,061 | 0 | 3 | 13,675 | 0 | java,python,installation | exec(String command)
Executes the specified string command in a separate process.
Check for Python from command | 0 | 1 | 0 | 0 | 2009-08-19T10:32:00.000 | 5 | 0 | false | 1,299,018 | 1 | 0 | 0 | 3 | How can I check from inside a java program if python is installed in windows?
Python does not add its path to the system Path and no assumption is to be made about the probable path of installation(i.e it can be installed anywhere). |
How to check if python is installed in windows from java? | 1,299,062 | 2 | 3 | 13,675 | 0 | java,python,installation | Use the Java Runtime to exec the following command "python --version".
If it works, you have Python, and the standard output is the version number.
If it doesn't work, you don't have Python. | 0 | 1 | 0 | 0 | 2009-08-19T10:32:00.000 | 5 | 1.2 | true | 1,299,018 | 1 | 0 | 0 | 3 | How can I check from inside a java program if python is installed in windows?
Python does not add its path to the system Path and no assumption is to be made about the probable path of installation(i.e it can be installed anywhere). |
How to check if python is installed in windows from java? | 19,837,856 | -2 | 3 | 13,675 | 0 | java,python,installation | this would work
Process process = Runtime.getRuntime().exec("cmd /c
C:\Python27\python --version"); | 0 | 1 | 0 | 0 | 2009-08-19T10:32:00.000 | 5 | -0.07983 | false | 1,299,018 | 1 | 0 | 0 | 3 | How can I check from inside a java program if python is installed in windows?
Python does not add its path to the system Path and no assumption is to be made about the probable path of installation(i.e it can be installed anywhere). |
Why is Standard Input is not displayed as I type in Mac OS X Terminal application? | 2,623,452 | 25 | 11 | 2,868 | 0 | python,django,macos,shell,terminal | Maybe this is because there was an error while running Django. Sometimes it happens that the std input disappears because stty was used. You can manually hide your input by typing:
$ stty -echo
Now you won't see what you typed. To restore this and solve your problem just type
$ stty echo
This could help. | 0 | 1 | 0 | 0 | 2009-08-19T18:44:00.000 | 3 | 1 | false | 1,301,887 | 0 | 0 | 1 | 2 | I'm confused by some behavior of my Mac OS X Terminal and my Django manage.py shell and pdb.
When I start a new terminal, the Standard Input is displayed as I type. However, if there is an error, suddenly Standard Input does not appear on the screen. This error continues until I shut down that terminal window.
The Input is still being captured as I can see the Standard Output.
E.g. in pdb.set_trace() I can 'l' to display where I'm at in the code. However, the 'l' will not be displayed, just an empty prompt.
This makes it hard to debug because I can't determine what I'm typing in.
What could be going wrong and what can I do to fix it? |
Why is Standard Input is not displayed as I type in Mac OS X Terminal application? | 2,018,573 | 3 | 11 | 2,868 | 0 | python,django,macos,shell,terminal | If you exit pdb you can type reset and standard input echo will return. I'm not sure if you can execute something similar within pdb. It will erase what is currently displayed however. | 0 | 1 | 0 | 0 | 2009-08-19T18:44:00.000 | 3 | 0.197375 | false | 1,301,887 | 0 | 0 | 1 | 2 | I'm confused by some behavior of my Mac OS X Terminal and my Django manage.py shell and pdb.
When I start a new terminal, the Standard Input is displayed as I type. However, if there is an error, suddenly Standard Input does not appear on the screen. This error continues until I shut down that terminal window.
The Input is still being captured as I can see the Standard Output.
E.g. in pdb.set_trace() I can 'l' to display where I'm at in the code. However, the 'l' will not be displayed, just an empty prompt.
This makes it hard to debug because I can't determine what I'm typing in.
What could be going wrong and what can I do to fix it? |
Do any Python ORMs (SQLAlchemy?) work with Google App Engine? | 11,325,656 | 2 | 11 | 5,333 | 1 | python,google-app-engine,sqlalchemy,orm | Nowadays they do since Google has launched Cloud SQL | 0 | 1 | 0 | 0 | 2009-08-20T19:39:00.000 | 2 | 0.197375 | false | 1,308,376 | 0 | 0 | 1 | 1 | I'd like to use the Python version of App Engine but rather than write my code specifically for the Google Data Store, I'd like to create my models with a generic Python ORM that could be attached to Big Table, or, if I prefer, a regular database at some later time. Is there any Python ORM such as SQLAlchemy that would allow this? |
Where is the best place to put cache-evicting logic in an AppEngine application? | 1,348,633 | 1 | 2 | 306 | 0 | python,google-app-engine,optimization,caching,memcached | A couple of alternatives to regular eviction:
The obvious one: Don't evict, and set a timer instead. Even a really short one - a few seconds - can cut down on effort a huge amount for a popular app, without users even noticing data may be a few seconds stale.
Instead of evicting, generate the cache key based on criteria that change when the data does. For example, if retrieving the key of the most recent announcement is cheap, you could use that as part of the key of the cached data. When a new announcement is posted, you go looking for a key that doesn't exist, and create a new one as a result. | 0 | 1 | 0 | 0 | 2009-08-21T18:44:00.000 | 2 | 0.099668 | false | 1,313,626 | 0 | 0 | 1 | 1 | I've written an application for Google AppEngine, and I'd like to make use of the memcache API to cut down on per-request CPU time. I've profiled the application and found that a large chunk of the CPU time is in template rendering and API calls to the datastore, and after chatting with a co-worker I jumped (perhaps a bit early?) to the conclusion that caching a chunk of a page's rendered HTML would cut down on the CPU time per request significantly. The caching pattern is pretty clean, but the question of where to put this logic of caching and evicting is a bit of a mystery to me.
For example, imagine an application's main page has an Announcements section. This section would need to be re-rendered after:
first read for anyone in the account,
a new announcement being added, and
an old announcement being deleted
Some options of where to put the evict_announcements_section_from_cache() method call:
in the Announcement Model's .delete(), and .put() methods
in the RequestHandler's .post() method
anywhere else?
Then in the RequestHandler's get page, I could potentially call get_announcements_section() which would follow the standard memcache pattern (check cache, add to cache on miss, return value) and pass that HTML down to the template for that chunk of the page.
Is it the typical design pattern to put the cache-evicting logic in the Model, or the Controller/RequestHandler, or somewhere else? Ideally I'd like to avoid having evicting logic with tentacles all over the code. |
easiest way to program a virtual file system in windows with Python | 1,325,685 | 3 | 10 | 4,784 | 0 | python,windows,filesystems | Does it need to be Windows-native? There is at least one protocol which can be both browsed by Windows Explorer, and served by free Python libraries: FTP. Stick your program behind pyftpdlib and you're done. | 0 | 1 | 0 | 0 | 2009-08-25T01:10:00.000 | 5 | 0.119427 | false | 1,325,568 | 1 | 0 | 0 | 2 | I want to program a virtual file system in Windows with Python.
That is, a program in Python whose interface is actually an "explorer windows". You can create & manipulate file-like objects but instead of being created in the hard disk as regular files they are managed by my program and, say, stored remotely, or encrypted or compressed or versioned, or whatever I can do with Python.
What is the easiest way to do that? |
easiest way to program a virtual file system in windows with Python | 1,325,652 | 2 | 10 | 4,784 | 0 | python,windows,filesystems | If you are trying to write a virtual file system (I may misunderstand you) - I would look at a container file format. VHD is well documented along with HDI and (embedded) OSQ. There are basically two things you need to do. One is you need to decide on a file/container format. After that it is as simple as writing the API to manipulate that container. If you would like it to be manipulated over the internet, pick a transport protocol then just write a service (would would emulate a file system driver) that listens on a certain port and manipulates this container using your API | 0 | 1 | 0 | 0 | 2009-08-25T01:10:00.000 | 5 | 0.07983 | false | 1,325,568 | 1 | 0 | 0 | 2 | I want to program a virtual file system in Windows with Python.
That is, a program in Python whose interface is actually an "explorer windows". You can create & manipulate file-like objects but instead of being created in the hard disk as regular files they are managed by my program and, say, stored remotely, or encrypted or compressed or versioned, or whatever I can do with Python.
What is the easiest way to do that? |
How to remotely restart a service on a password protected machine using Python? | 1,332,904 | 1 | 0 | 4,489 | 0 | python,remote-access | Which OS for the target machines? If 'service' is 'Windows NT service', and your local machine is also Windows, I'd use IronPython as the Python language implementation and call straight into the WMI facilities in the .net System.Management namespace -- they're meant for remote admin like that. | 0 | 1 | 0 | 0 | 2009-08-26T07:10:00.000 | 5 | 0.039979 | false | 1,332,853 | 0 | 0 | 0 | 1 | I decided to tackle Python as a new language to learn. The first thing I want to do is code a script that will allow me to remotely restart services on other machines from my local machine. How would I accomplish this when the remote machine requires a username and password to log on? I don't need a full solution to be given to me but maybe some pointers on what libraries I should use or any issues I need to address when writing the script.
EDIT: All the remote machines are using Windows 2003 |
Locally Hosted Google App Engine (WebApp Framework / BigTable) | 1,342,175 | 4 | 1 | 911 | 0 | python,google-app-engine,mod-wsgi | Webapp is a fine choice for a simple web framework but there are plenty of other simple python web frameworks that have instructions for setting them up in your use case (cherrypy, web.py, etc). Since google developed webapp for gae I don't believe they published instructions for setting it up behind apache.
BigTable is proprietary to Google so you will not be able to run it locally. If you are looking for something with similar performance characteristics I'd look into the schemaless 'document-oriented' databases. | 0 | 1 | 0 | 0 | 2009-08-27T12:51:00.000 | 1 | 1.2 | true | 1,340,887 | 0 | 0 | 1 | 1 | I have been playing with Google App engine a lot lately, from home on personal projects, and I have been really enjoying it. I've converted a few of my coworkers over and we are interested in using GAE for a few of our projects at work.
Our work has to be hosted locally on our own servers. I've done some searching around and I really can't find any information on using the WebApp framework and BigTable locally.
Any information you could provide on setting up a GAE-ish environment on a local Windows server would be much appreciated. I know GAE is much more than just the framework and BigTable - the scalability, propogation of your application/data across many servers are all features we don't need. We just want to get the webapp framework and BigTable up and running through mod_wsgi on Apache. |
Python version shipping with Mac OS X Snow Leopard? | 1,350,316 | 12 | 10 | 10,496 | 0 | python,macos,osx-snow-leopard | It ships with both python 2.6.1 and 2.5.4.
$ python2.5
Python 2.5.4 (r254:67916, Jul 7 2009, 23:51:24)
$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) | 0 | 1 | 0 | 0 | 2009-08-28T14:30:00.000 | 5 | 1 | false | 1,347,376 | 1 | 0 | 0 | 3 | I would appreciate it if somebody running the final version of Snow Leopard could post what version of Python is included with the OS (on a Terminal, just type "python --version")
Thanks! |
Python version shipping with Mac OS X Snow Leopard? | 1,352,207 | 1 | 10 | 10,496 | 0 | python,macos,osx-snow-leopard | You can get an installer for 2.6.2 from python.org, no reason to go without. | 0 | 1 | 0 | 0 | 2009-08-28T14:30:00.000 | 5 | 0.039979 | false | 1,347,376 | 1 | 0 | 0 | 3 | I would appreciate it if somebody running the final version of Snow Leopard could post what version of Python is included with the OS (on a Terminal, just type "python --version")
Thanks! |
Python version shipping with Mac OS X Snow Leopard? | 1,347,397 | 3 | 10 | 10,496 | 0 | python,macos,osx-snow-leopard | Python 2.6.1
(according to the web)
Really good to know :) | 0 | 1 | 0 | 0 | 2009-08-28T14:30:00.000 | 5 | 0.119427 | false | 1,347,376 | 1 | 0 | 0 | 3 | I would appreciate it if somebody running the final version of Snow Leopard could post what version of Python is included with the OS (on a Terminal, just type "python --version")
Thanks! |
How do I create a file in python without overwriting an existing file | 1,348,441 | 0 | 25 | 12,132 | 0 | python,multithreading,file | If you have an id associated with each thread / process that tries to create the file, you could put that id in the suffix somewhere, thereby guaranteeing that no two processes can use the same file name.
This eliminates the race condition between the processes. | 0 | 1 | 0 | 0 | 2009-08-28T16:14:00.000 | 3 | 0 | false | 1,348,026 | 1 | 0 | 0 | 1 | Currently I have a loop that tries to find an unused filename by adding suffixes to a filename string. Once it fails to find a file, it uses the name that failed to open a new file wit that name. Problem is this code is used in a website and there could be multiple attempts to do the same thing at the same time, so a race condition exists.
How can I keep python from overwriting an existing file, if one is created between the time of the check and the time of the open in the other thread.
I can minimize the chance by randomizing the suffixes, but the chance is already minimized based on parts of the pathname. I want to eliminate that chance with a function that can be told, create this file ONLY if it doesn't exist.
I can use win32 functions to do this, but I want this to work cross platform because it will be hosted on linux in the end. |
Python 3.1.1 on Mac OS X 10.6 Snow Leopard | 1,649,335 | 0 | 2 | 8,496 | 0 | macos,osx-snow-leopard,python-3.x | Kenneth Reitz's soluton doesn't work for me. In fact, the install works fine but my default PATH still points to /usr/bin/python (v2.6.1.). I vaguely recall that we should be modifying our ~/.profile to point to /.../Frameworks and I expected the installer to do this for me (nope).
Anyway, /Library/Frameworks/Python.framework/Versions/3.1/bin exists so we could add it.
But I'm curious why the python bin in there does a crash and burn on me.
No time to resolve this now. Bye. | 0 | 1 | 0 | 0 | 2009-08-29T19:56:00.000 | 4 | 0 | false | 1,352,230 | 0 | 0 | 0 | 1 | I've spent some time today playing with getting the source for python 3.1.1 to build on my MacBook Pro using the --enable-framework and --enable-universalsdk options with no success. I will humbly admit that I have no real clue why I can't compile 3.1.1 on Snow Leopard, I did make sure to get the new Xcode version for Snow Leopard, and made sure I also installed the 10.4u SDK. It seems to be choking on the 10.4 SDK during the make stage, and has several error regarding headers for wchar, cursor, and ncursor during the configure stage. I have been able to get a make from a plain configure, and most the test pass, but that just isn't challenging enough. Has anyone else attempted to build python 3.1.1 on a Mac running Snow Leopard |
Python script performance as a background process | 1,352,777 | 5 | 0 | 738 | 0 | python,performance,process,background | If you are using blocking I/O to your devices, then the script won't consume any processor while waiting for the data. How much processor you use depends on what sorts of computation you are doing with the data. | 0 | 1 | 1 | 0 | 2009-08-30T00:58:00.000 | 2 | 0.462117 | false | 1,352,760 | 1 | 0 | 0 | 1 | Im in the process of writing a python script to act as a "glue" between an application and some external devices. The script itself is quite straight forward and has three distinct processes:
Request data (from a socket connection, via UDP)
Receive response (from a socket connection, via UDP)
Process response and make data available to 3rd party application
However, this will be done repetitively, and for several (+/-200 different) devices. So once its reached device #200, it would start requesting data from device #001 again. My main concern here is not to bog down the processor whilst executing the script.
UPDATE:
I am using three threads to do the above, one thread for each of the above processes. The request/response is asynchronous as each response contains everything i need to be able to process it (including the senders details).
Is there any way to allow the script to run in the background and consume as little system resources as possible while doing its thing? This will be running on a windows 2003 machine.
Any advice would be appreciated. |
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'? | 1,352,927 | 5 | 71 | 38,302 | 0 | python,bash | It finds 'python' also in /usr/local/bin, ~/bin, /opt/bin, ... or wherever it may hide. | 0 | 1 | 0 | 1 | 2009-08-30T02:30:00.000 | 5 | 0.197375 | false | 1,352,922 | 1 | 0 | 0 | 3 | Anyone know this? I've never been able to find an answer. |
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'? | 1,352,941 | 10 | 71 | 38,302 | 0 | python,bash | it finds the python executable in your environment and uses that. it's more portable because python may not always be in /usr/bin/python. env is always located in /usr/bin. | 0 | 1 | 0 | 1 | 2009-08-30T02:30:00.000 | 5 | 1 | false | 1,352,922 | 1 | 0 | 0 | 3 | Anyone know this? I've never been able to find an answer. |
Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'? | 1,352,938 | 67 | 71 | 38,302 | 0 | python,bash | If you're prone to installing python in various and interesting places on your PATH (as in $PATH in typical Unix shells, %PATH on typical Windows ones), using /usr/bin/env will accomodate your whim (well, in Unix-like environments at least) while going directly to /usr/bin/python won't. But losing control of what version of Python your scripts run under is no unalloyed bargain... if you look at my code you're more likely to see it start with, e.g., #!/usr/local/bin/python2.5 rather than with an open and accepting #!/usr/bin/env python -- assuming the script is important I like to ensure it's run with the specific version I have tested and developed it with, NOT a semi-random one;-). | 0 | 1 | 0 | 1 | 2009-08-30T02:30:00.000 | 5 | 1.2 | true | 1,352,922 | 1 | 0 | 0 | 3 | Anyone know this? I've never been able to find an answer. |
file system performance testing | 1,356,966 | 0 | 1 | 1,679 | 0 | python,filesystems,performance-testing | You might be inetersting in looking at tools like caollectd and iotop. Then again, yopu mightalso by interested in just using them instead of reinventing the wheel - as far as I see, such performance analysis is not learned in a day, and these guys invested significant amounts of time and knowledge in building these tools. | 0 | 1 | 0 | 1 | 2009-08-31T07:29:00.000 | 4 | 0 | false | 1,356,240 | 0 | 0 | 0 | 1 | I am writing a python script that will perform performance test in linux file system. so besides deadlocks, race conditions and time takes to perform an action (delete, read, write and create) what other variables/parameters should the test contain? |
Block requests from *.appspot.com and force custom domain in Google App Engine | 1,364,875 | 17 | 14 | 5,133 | 0 | python,google-app-engine,redirect | You can check if os.environ['HTTP_HOST'].endswith('.appspot.com') -- if so, then you're serving from something.appspot.com and can send a redirect, or otherwise alter your behavior as desired.
You could deploy this check-and-redirect-if-needed (or other behavior alteration of your choice) in any of various ways (decorators, WSGI middleware, inheritance from an intermediate base class of yours that subclasses webapp.RequestHandler [[or whatever other base handler class you're currently using]] and method names different than get and post in your application-level handler classes, and others yet) but I think that the key idea here is that os.environ is set by the app engine framework according to CGI standards and so you can rely on those standards (similarly WSGI builds its own environment based on the values it picks up from os.environ). | 0 | 1 | 0 | 0 | 2009-09-01T21:26:00.000 | 5 | 1.2 | true | 1,364,733 | 0 | 0 | 1 | 1 | How can I prevent a user from accessing my app at example.appspot.com and force them to access it at example.com? I already have example.com working, but I don't want users to be able to access the appspot domain. I'm using python. |
How to deal with user authentication and wrongful modification in scripting languages? | 1,365,394 | 1 | 2 | 272 | 0 | python,security,design-patterns,authentication,cracking | Possibly:
The user enters their credentials into the desktop client.
The client says to the server: "Hi, my name username and my password is password".
The server checks these.
The server says to the client: "Hi, username. Here is your secret token: ..."
Subsequently the client uses the secret token together with the username to "sign" communications with the server. | 0 | 1 | 0 | 1 | 2009-09-02T00:03:00.000 | 2 | 0.099668 | false | 1,365,254 | 0 | 0 | 0 | 2 | I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory).
Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project.
The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows.
I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app.
One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that.
Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?" |
How to deal with user authentication and wrongful modification in scripting languages? | 1,365,422 | 3 | 2 | 272 | 0 | python,security,design-patterns,authentication,cracking | How malicious are your users? Really.
Exactly how malicious?
If your users are evil sociopaths and can't be trusted with a desktop solution, then don't build a desktop solution. Build a web site.
If your users are ordinary users, they'll screw the environment up by installing viruses, malware and keyloggers from porn sites before they try to (a) learn Python (b) learn how your security works and (c) make a sincere effort at breaking it.
If you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop.
Otherwise, relax, do the right thing, and don't worry about "scripting".
C++ programs are easier to hack because people are lazy and permit SQL injection. | 0 | 1 | 0 | 1 | 2009-09-02T00:03:00.000 | 2 | 1.2 | true | 1,365,254 | 0 | 0 | 0 | 2 | I'm building a centralized desktop application using Python/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory).
Users of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project.
The problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing/getting sensible information from the system, because "compiling" with py2exe is the closest I can get to obfuscation of the code on Windows.
I'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app.
One of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that.
Of course this question is changing now and is not just "Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?", but "How do you harden an scripting (Python) against wrongful modification?" |
On localhost, how do I pick a free port number? | 1,365,281 | 47 | 189 | 154,753 | 0 | python,sockets,ipc,port | Bind the socket to port 0. A random free port from 1024 to 65535 will be selected. You may retrieve the selected port with getsockname() right after bind(). | 0 | 1 | 1 | 0 | 2009-09-02T00:07:00.000 | 5 | 1 | false | 1,365,265 | 0 | 0 | 0 | 2 | I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21?
I'm using Python, if that cuts the choices down. |
On localhost, how do I pick a free port number? | 1,365,283 | 4 | 189 | 154,753 | 0 | python,sockets,ipc,port | You can listen on whatever port you want; generally, user applications should listen to ports 1024 and above (through 65535). The main thing if you have a variable number of listeners is to allocate a range to your app - say 20000-21000, and CATCH EXCEPTIONS. That is how you will know if a port is unusable (used by another process, in other words) on your computer.
However, in your case, you shouldn't have a problem using a single hard-coded port for your listener, as long as you print an error message if the bind fails.
Note also that most of your sockets (for the slaves) do not need to be explicitly bound to specific port numbers - only sockets that wait for incoming connections (like your master here) will need to be made a listener and bound to a port. If a port is not specified for a socket before it is used, the OS will assign a useable port to the socket. When the master wants to respond to a slave that sends it data, the address of the sender is accessible when the listener receives data.
I presume you will be using UDP for this? | 0 | 1 | 1 | 0 | 2009-09-02T00:07:00.000 | 5 | 0.158649 | false | 1,365,265 | 0 | 0 | 0 | 2 | I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21?
I'm using Python, if that cuts the choices down. |
Managing multiple Twisted client connections | 1,408,498 | 4 | 6 | 4,725 | 0 | python,twisted | The best option is really just to do the obvious thing here. Don't have a loop, or a repeating timed call; just have handlers that do the right thing.
Keep a central connection-management object around, and make event-handling methods feed it the information it needs to keep going. When it starts, make 5 outgoing connections. Keep track of how many are in progress, maintain a list with them in it. When a connection succeeds (in connectionMade) update the list to remember the connection's new state. When a connection completes (in connectionLost) tell the connection manager; its response should be to remove that connection and make a new connection somewhere else. In the middle, it should be fairly obvious how to fire off a request for the names you need and stuff them into a database (waiting for the database insert to complete before dropping your IRC connection, most likely, by waiting for the Deferred to come back from adbapi). | 0 | 1 | 1 | 0 | 2009-09-02T03:45:00.000 | 3 | 1.2 | true | 1,365,737 | 0 | 0 | 0 | 1 | I'm trying to use Twisted in a sort of spidering program that manages multiple client connections. I'd like to maintain of a pool of about 5 clients working at one time. The functionality of each client is to connect to a specified IRC server that it gets from a list, enter a specific channel, and then save the list of the users in that channel to a database.
The problem I'm having is more architectural than anything. I'm fairly new to Twisted and I don't know what options are available for managing multiple clients. I'm assuming the easiest way is to simply have each ClientCreator instance die off once it's completed its work and have a central loop that can check to see if there's room to add a new client. I would think this isn't a particularly unusual problem so I'm hoping to glean some information from other peoples' experiences. |
Python long filename support broken in Windows | 1,365,827 | 9 | 13 | 8,165 | 0 | python,windows,python-2.x | In order to use the \\?\ prefix (as already proposed), you also need to make sure you use Unicode strings as filenames, not regular (byte) strings. | 0 | 1 | 0 | 0 | 2009-09-02T04:15:00.000 | 6 | 1 | false | 1,365,797 | 0 | 0 | 0 | 1 | I write Python script to copy files; unfortunately it keeps failing because filename is too long(>256). Is there anyway to deal with that problem?
I'm using Python 2.5.4 and Windows XP.
Cheers, |
How would you query Picasa from a Google App Engine app? Data API or Url Fetch? | 1,369,908 | 2 | 0 | 1,248 | 0 | python,api,google-app-engine,picasa,urlfetch | Your question is a little off, since the Data API is exposed through RESTful URLs, so both methods are ultimately a "URL Fetch".
The Data API works quite well, though. It gives you access to nearly all the functionality of Picasa, and responses are sent back and forth in well-formed, well-documented XML. Google's documentation for the API is very good.
If you only need access to limited publicly available content (like a photostream) then you can do this at a very basic level by just fetching the feed url and parsing that... but even for that you can get the same data with more configuration options via the Data API URLs.
I'm not sure what code samples you'd like... it really depends what you actually want to do with Picasa. | 0 | 1 | 0 | 0 | 2009-09-02T20:10:00.000 | 1 | 1.2 | true | 1,369,861 | 0 | 0 | 1 | 1 | How would you query Picasa from a Google App Engine app? Data API or Url Fetch? What are the pros and cons of using either method?
[Edit]
I would like to be able to query a specific album in Picasa and list all the photos in it.
Code examples to do this in python are much appreciated. |
How to get list opened windows in PyGTK or GTK in Ubuntu? | 1,380,909 | 2 | 10 | 9,460 | 0 | python,ubuntu,gtk,pygtk,window-management | I really don't know how to check if a window is a GTK one. But if you want to check how many windows are currently open try "wmctrl -l". Install it first of course. | 0 | 1 | 0 | 0 | 2009-09-04T18:18:00.000 | 6 | 0.066568 | false | 1,380,784 | 0 | 0 | 0 | 1 | How to get list opened windows in PyGTK or GTK or other programming language? in Ubuntu?
edit:
i want get list paths opened directories on desktop! |
Is packaging scripts as executables a solution for comercial applications? | 1,381,231 | 2 | 0 | 260 | 0 | python,ruby,executable | py2exe is great, I've used it before and it works just fine for encapsulating a program so it can run on other computers, even those lacking python. Like Alex said, it can be disassembled, but then so can C++ binaries. It's just a question of how much work the person is has to put into it. If someone has physical access to a the computer where data is stored, they have access to the data (And there's no difference between code and data). Compress it, encrypt it, compile it, those will only slow the determined.
Realistically, if you want to make the source code to your program as inaccessible as possible, you probably shouldn't look at Python or Ruby. C++ and some of the others are far more difficult to decompile, thereby providing more obscurity. You can practice the fine art of obfuscation, but even that won't stop someone trying to steal it (It's not like you have to understand the code to put it up on the Pirate Bay). | 0 | 1 | 0 | 0 | 2009-09-04T18:34:00.000 | 4 | 0.099668 | false | 1,380,852 | 1 | 0 | 0 | 2 | What happens when you package a script as an executable? Is this a good way to distribute commercial applications? I remember I read something a long time ago that when you package scripts as executables, at runtime the exe decompresses the scripts to a temporary directory where they get ran.
If it's like that, than I don't think this can be viewed as a good solution, because a skilled user could find out where that directory is located and find the source code. I'm interested in Python & Ruby. |
Is packaging scripts as executables a solution for comercial applications? | 1,381,289 | 3 | 0 | 260 | 0 | python,ruby,executable | Creating an application and creating a commercial software business are two distinct things.
At my job we have a commercial application developed in Ruby on Rails that is installed at client sites; no obfuscation or encryption applied.
There is just so much more going on at a business level: support, customization, training that it's almost ludicrous to think that they'd do something with the source code. Most sites are lucky if they can spare the cycles to manage the application, much less start wallowing in someone else's codebase.
Now that being said, we aren't publicly distributing the code or anything, just that we've made the choice to invest in making the application better and doing better by our customers than to burn the time trying to restrict access to our application. | 0 | 1 | 0 | 0 | 2009-09-04T18:34:00.000 | 4 | 0.148885 | false | 1,380,852 | 1 | 0 | 0 | 2 | What happens when you package a script as an executable? Is this a good way to distribute commercial applications? I remember I read something a long time ago that when you package scripts as executables, at runtime the exe decompresses the scripts to a temporary directory where they get ran.
If it's like that, than I don't think this can be viewed as a good solution, because a skilled user could find out where that directory is located and find the source code. I'm interested in Python & Ruby. |
Converting latex code to Images (or other displayble format) with Python | 1,381,791 | 0 | 26 | 19,039 | 0 | python,latex | You're going to need to use LaTeX to process to string. The process of rendering LaTex/TeX is very involved (it generally takes a 100+MB package to do the work), you're just not going to be able toss in a little python module to get the work done. | 0 | 1 | 0 | 0 | 2009-09-04T22:04:00.000 | 7 | 0 | false | 1,381,741 | 1 | 0 | 0 | 1 | I have a function I am consuming that returns a string of latex code. I need to generate an image from this. Most of the methods I have seen for doing so suggest calling an external application via say the subprocess module which will generate the image for me.
However, management is not keen on this as it will require external users to install additional software in addition to our own which, with our user base, is not something we can assume to be a simple task.
So are there any python libraries that will accomplish the task of taking latex into a format (such as an image file) which is displayable in a GUI? |
OS X - multiple python versions, PATH and /usr/local | 1,384,223 | 0 | 5 | 4,778 | 0 | python,macos,path,multiple-versions | I just noticed/encountered this issue on my Mac. I have Python 2.5.4, 2.6.2, and 3.1.1 on my machine, and was looking for a way to easily change between them at will. That is when I noticed all the symlinks for the executables, which I found in both '/usr/bin' and '/usr/local/bin'. I ripped all the non-version specific symlinks out, leaving python2.5, python2.6, etc, and wrote a bash shell script that I can run as root to change one symlink I use to direct the path to the version of my choice
'/Library/Frameworks/Python.framework/Versions/Current'
The only bad thing about ripping the symlinks out, is if some other application needed them for some reason. My opinion as to why these symlinks are created is similar to Alex's assessment, the installer is trying to cover all of the bases. All of my versions have been installed by an installer, though I've been trying to compile my own to enable full 64-bit support, and when compiling and installing your own you can choose to not have the symlinks created or the PATH modified during installation. | 0 | 1 | 0 | 0 | 2009-09-05T17:40:00.000 | 2 | 0 | false | 1,383,863 | 1 | 0 | 0 | 2 | If you install multiple versions of python (I currently have the default 2.5, installed 3.0.1 and now installed 2.6.2), it automatically puts stuff in /usr/local, and it also adjusts the path to include the /Library/Frameworks/Python/Versions/theVersion/bin, but whats the point of that when /usr/local is already on the PATH, and all installed versions (except the default 2.5, which is in /usr/bin) are in there? I removed the python framework paths from my PATH in .bash_profile, and I can still type "python -V" => "Python 2.5.1", "python2.6 -V" => "Python 2.6.2","python3 -V" => "Python 3.0.1". Just wondering why it puts it in /usr/local, and also changes the PATH. And is what I did fine? Thanks.
Also, the 2.6 installation made it the 'current' one, having .../Python.framework/Versions/Current point to 2.6., So plain 'python' things in /usr/local/bin point to 2.6, but it doesn't matter because usr/bin comes first and things with the same name in there point to 2.5 stuff.. Anyway, 2.5 comes with leopard, I installed 3.0.1 just to have the latest version (that has a dmg file), and now I installed 2.6.2 for use with pygame.
EDIT: OK, here's how I understand it. When you install, say, Python 2.6.2:
A bunch of symlinks are added to /usr/local/bin, so when there's a #! /usr/local/bin/python shebang in a python script, it will run, and in /Applications/Python 2.6, the Python Launcher is made default application to run .py files, which uses /usr/local/bin/pythonw, and /Library/Frameworks/Python.framework/Versions/2.6/bin is created and added to the front of the path, so which python will get the python in there, and also #! /usr/bin/env python shebang's will run correctly. |
OS X - multiple python versions, PATH and /usr/local | 1,383,891 | 5 | 5 | 4,778 | 0 | python,macos,path,multiple-versions | There's no a priori guarantee that /usr/local/bin will stay on the PATH (especially it will not necessarily stay "in front of" /usr/bin!-), so it's perfectly reasonable for an installer to ensure the specifically needed /Library/.../bin directory does get on the PATH. Plus, it may be the case that the /Library/.../bin has supplementary stuff that doesn't get symlinked into /usr/local/bin, although I believe that's not currently the case with recent Mac standard distributions of Python.
If you know that the way you'll arrange your path, and the exact set of executables you'll be using, are entirely satisfied from /usr/local/bin, then it's quite OK for you to remove the /Library/etc directories from your own path, of course. | 0 | 1 | 0 | 0 | 2009-09-05T17:40:00.000 | 2 | 1.2 | true | 1,383,863 | 1 | 0 | 0 | 2 | If you install multiple versions of python (I currently have the default 2.5, installed 3.0.1 and now installed 2.6.2), it automatically puts stuff in /usr/local, and it also adjusts the path to include the /Library/Frameworks/Python/Versions/theVersion/bin, but whats the point of that when /usr/local is already on the PATH, and all installed versions (except the default 2.5, which is in /usr/bin) are in there? I removed the python framework paths from my PATH in .bash_profile, and I can still type "python -V" => "Python 2.5.1", "python2.6 -V" => "Python 2.6.2","python3 -V" => "Python 3.0.1". Just wondering why it puts it in /usr/local, and also changes the PATH. And is what I did fine? Thanks.
Also, the 2.6 installation made it the 'current' one, having .../Python.framework/Versions/Current point to 2.6., So plain 'python' things in /usr/local/bin point to 2.6, but it doesn't matter because usr/bin comes first and things with the same name in there point to 2.5 stuff.. Anyway, 2.5 comes with leopard, I installed 3.0.1 just to have the latest version (that has a dmg file), and now I installed 2.6.2 for use with pygame.
EDIT: OK, here's how I understand it. When you install, say, Python 2.6.2:
A bunch of symlinks are added to /usr/local/bin, so when there's a #! /usr/local/bin/python shebang in a python script, it will run, and in /Applications/Python 2.6, the Python Launcher is made default application to run .py files, which uses /usr/local/bin/pythonw, and /Library/Frameworks/Python.framework/Versions/2.6/bin is created and added to the front of the path, so which python will get the python in there, and also #! /usr/bin/env python shebang's will run correctly. |
Reliably detect Windows in Python | 1,387,226 | 16 | 64 | 34,871 | 0 | python,windows,platform-detection | On my Windows box, platform.system() returns 'Windows'.
However, I'm not sure why you'd bother. If you want to limit the platform it runs on technologically, I'd use a white-list rather than a black-list.
In fact, I wouldn't do it technologically at all since perhaps the next release of Python may have Win32/Win64 instead of Windows (for black-listing) and *nix instead of Linux (for white-listing).
My advice is to simply state what the requirements are and, if the user chooses to ignore that, that's their problem. If they ring up saying they got an error message stating "Cannot find FHS" and they admit they're running on Windows, gently point out to them that it's not a supported configuration.
Maybe your customers are smart enough to get FHS running under Windows so that your code will work. They're unlikely to appreciate what they would then consider an arbitrary limitation of your software.
This is a problem faced by software developers every day. Even huge organizations can't support every single platform and configuration out there. | 0 | 1 | 0 | 0 | 2009-09-07T01:29:00.000 | 6 | 1 | false | 1,387,222 | 1 | 0 | 0 | 1 | I'm working on a couple of Linux tools and need to prevent installation on Windows, since it depends on FHS and is thus rendered useless on that platform. The platform.platform function comes close but only returns a string.
Unfortunately I don't know what to search for in that string for it to yield a reliable result. Does anyone know what to search for or does anyone know of another function that I'm missing here? |
Upgrade python in linux | 1,388,552 | 6 | 2 | 25,211 | 0 | python,linux | The safest way to upgrading Python is to install it to a different location (away from the default system path).
To do this, download the source of python and do a
./configure --prefix=/opt
(Assuming you want to install it to /opt which is where most install non system dependant stuff to)
The reason why I say this is because some other system libraries may depend on the current version of python.
Another reason is that as you are doing your own custom development, it is much better to have control over what version of the libraries (or interpreters) you are using rather than have a operating system patch break something that was working before. A controlled upgrade is better than having the application break on you all of a sudden. | 0 | 1 | 0 | 0 | 2009-09-07T09:36:00.000 | 3 | 1 | false | 1,388,464 | 1 | 0 | 0 | 2 | I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it? |
Upgrade python in linux | 1,391,295 | 0 | 2 | 25,211 | 0 | python,linux | The best solution will be installing python2.6 in the choosen directory - It will you give you access to many great features and better memory handling (infamous python=2.4 memory leak problem).
I have got several pythons installed onto my two computers, I found that the best solution for are two directories:
$HOME/usr-32
$HOME/usr-64
respectively to using operating system (I share $HOME between 32 and 64 bit versions of Linux).
In each I have one directory for every application/program, for example:
ls ~/usr-64/python-2.6.2/
bin include lib share
It leads completetely to avoiding conflicts between version and gives great portability (you can use usb pendrives etc).
Python 2.6.2 in previously example has been installed with option:
./configure --prefix=$HOME/usr-64/python-2.6.2 | 0 | 1 | 0 | 0 | 2009-09-07T09:36:00.000 | 3 | 0 | false | 1,388,464 | 1 | 0 | 0 | 2 | I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it? |
How to process UDP data in Appengine | 17,618,253 | 0 | 1 | 2,113 | 0 | python,google-app-engine,udp | You could run a separate agent on a cloud host like DigitalOcean or Amazon EC2 that proxies this protocol and makes itself available to Google App Engine via ordinary HTTP or web sockets. | 0 | 1 | 0 | 0 | 2009-09-07T13:14:00.000 | 3 | 0 | false | 1,389,385 | 0 | 0 | 1 | 1 | I have a service provider who is transmitting data thro' UDP. I want to establish a connection to them, receive & process data (will be with in the 30 sec limit/request)
Is it possible to get & process UDP data in appengine. I am looking for some simple example. |
Is it possible to deploy one GAE application from another GAE application? | 1,392,766 | 5 | 3 | 418 | 0 | python,google-app-engine | Is it possible? Yes. The protocol appcfg uses to update apps is entirely HTTP-based, so there's absolutely no reason you couldn't write an app that's capable of deploying other apps (or redeploying itself - self-modifying code)! You may even be able to reuse large parts of appcfg.py to do it.
Is it easy? Probably not. It's quite likely you'll need to understand a decent chunk of appcfg's internals, and the RPCs it uses to upload new apps - not a trivial undertaking. You'll also need to store your credentials in the app, in all likelihood - though you can use a role account that is and admin only for the apps it's deploying to minimize risk there. | 0 | 1 | 0 | 0 | 2009-09-08T02:02:00.000 | 3 | 1.2 | true | 1,391,608 | 0 | 0 | 1 | 3 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? |
Is it possible to deploy one GAE application from another GAE application? | 1,391,649 | 2 | 3 | 418 | 0 | python,google-app-engine | One limiting constraint could be the protocol that the python sdk uses to communicate with the GAE servers. If it only uses HTTP, you might be OK. but if it's anything else, you might be out of luck because you can't open a socket directly from within GAE. | 0 | 1 | 0 | 0 | 2009-09-08T02:02:00.000 | 3 | 0.132549 | false | 1,391,608 | 0 | 0 | 1 | 3 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? |
Is it possible to deploy one GAE application from another GAE application? | 1,391,652 | 0 | 3 | 418 | 0 | python,google-app-engine | What problem did you have by trying to update behind a firewall?
I've got some, but finally I manage to work around them.
About your question, the constraint is that you cannot write files into a GAE app, so even though you could possibly pull from the VCS you can't write those pulled files.
So you would have to update from outside the GAE in first place.
Anyway every machine that needs to update the GAE should have the SDK anyway just to see if they changes work.
So, If you really want to do this you have two alternatives:
Host your own "updater" site and istall the SDK there, then when you want to update log into your side ( or run a script ) and do the remote update.
Although I don't know Amazon EC2 well, I think you can do pretty much the same thing as op 1 from there.
Finally I think the password to update has to be typed always. ( you could have the SDK of the App engine and modify that, because it is open source ) | 0 | 1 | 0 | 0 | 2009-09-08T02:02:00.000 | 3 | 0 | false | 1,391,608 | 0 | 0 | 1 | 3 | In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on every machine that will be used for updating GAE apps. A more ideal solution would be if I could update a GAE application from another GAE application that I have deployed previously. This would remove the need to have multiple systems configured to deploy apps.
Since the GAE deployment tools are written in Python and the GAE App Engine supports Python, is it possible to modify appcfg.py to work from within GAE? The use case would be to pull a project from GitHub or some other online repository and update one GAE application from another GAE app. If this is not possible, what is the limiting constraint? |
How do I keep state between requests in AppEngine (Python)? | 1,406,768 | 3 | 1 | 564 | 0 | python,google-app-engine | The ways to reliable keep state between requests are memcache, the datastore or through the user (cookies or post/get).
You can use the runtime cache too, but this is very unreliable as you don't know if a request will end up in the same runtime or the runtime can drop it's entire cache if it feels like it.
I really wouldn't use the runtime cache except for very specific situations, for example I use it to cache the serialization of objects to json as that is pretty slow and if the caching is gone I can regenerate the result easily. | 0 | 1 | 0 | 0 | 2009-09-10T17:32:00.000 | 2 | 0.291313 | false | 1,406,636 | 0 | 0 | 1 | 1 | I'm writing a simple app with AppEngine, using Python. After a successful insert by a user and redirect, I'd like to display a flash confirmation message on the next page.
What's the best way to keep state between one request and the next? Or is this not possible because AppEngine is distributed? I guess, the underlying question is whether AppEngine provides a persistent session object.
Thanks
Hannes |
Does python logging.handlers.RotatingFileHandler allow creation of a group writable log file? | 67,012,969 | 0 | 38 | 14,631 | 0 | python,logging,python-logging | I think what described here is an anti-pattern - different processes should not write data into the same file.
And non of the solutions above worked for me, causing different permissions issues in different scenarios.
As a temp workaround I've added a random suffix into the log filename so each process will get a unique filename on a startup.
The proper way to solve this issue - have a centralized log handler (log server), e.g. rsyslog. | 0 | 1 | 0 | 0 | 2009-09-10T20:14:00.000 | 8 | 0 | false | 1,407,474 | 0 | 0 | 0 | 1 | I'm using the standard python (2.5.2) logging module, specifically the RotatingFileHandler, on a linux system. My application supports both a command-line interface and a web-service interface. I would like to have both write to the same log file. However, when the log file gets rotated, the new file has 644 permissions and is owned by the web server user which prevents the command-line user from writing to it. Can I specify that new log files should be group-writable in the logging configuration or during logging initialization?
I have looked into the mode setting (r/w/a), but it doesn't seem to support any file permissions. |
Get file creation time with Python on linux | 48,969,869 | -1 | 21 | 11,846 | 0 | python,linux | What do you mean it can't be done [1]? The function, os.stat(path).st_birthtime, works great.
[1]:
Somebody said that it couldn’t be done
But he with a chuckle replied
That “maybe it couldn’t,” but he would be one
Who wouldn’t say so till he’d tried.
So he buckled right in with the trace of a grin
On his face. If he worried he hid it.
He started to sing as he tackled the thing
That couldn’t be done, and he did it!
-- Edgar Albert Guest | 0 | 1 | 0 | 1 | 2009-09-10T23:35:00.000 | 7 | -0.028564 | false | 1,408,272 | 0 | 0 | 0 | 1 | os.stat returns st_mtime and st_ctime attributes, the modification time is st_mtime and st_ctime "change time" on POSIX.
is there any function that return the creation time of a file using python and under Linux? |
send an arbitrary number of inputs from python to a .exe | 1,408,428 | 1 | 2 | 656 | 0 | python,executable | Avoid concatenating all arguments into one string using that string.
It's a lot simpler and better and safer to just pass a sequence (list or tuple) of arguments. This is specially true if any argument contains a space character (which is quite common for filenames). | 0 | 1 | 0 | 0 | 2009-09-10T23:48:00.000 | 4 | 0.049958 | false | 1,408,326 | 1 | 0 | 0 | 1 | p = subprocess.Popen(args = "myprog.exe" + " " +
str(input1) + " " +
str(input2) + " " +
str(input3) + " " +
strpoints, stdout = subprocess.PIPE)
in the code above, input1, input2, and input3 are all integers that get converted to strings. the variable "strpoints" is a list of arbitrary length of strings. input1 tells myprog the length of strpoints. of course, when i try to run the above code, i get the following error message:
TypeError: Can't convert 'list' object to str implicitly
how do i pass all the elements of strpoints to myprog.exe? am i doomed to having to do str(strpoints) and then have myprog.exe parse this for commas, apostrophes, etc.? e.g.,
`>>> x = ['a', 'b']
`>>> str(x)
"['a', 'b']"
or should i create a huge string in advance? e.g.,
'>>> x = ['a', 'b']
'>>> stringify(x)
' a b'
where stringify would be something like
def stringify(strlist):
rlist = ""
for i in strlist:
rlist = rlist + i + " "
return rlist |
Track process status with Python | 1,408,646 | 1 | 3 | 4,015 | 0 | python,process,crash,subprocess | Yes to all. | 0 | 1 | 0 | 0 | 2009-09-11T01:47:00.000 | 2 | 0.099668 | false | 1,408,627 | 0 | 0 | 0 | 1 | I want to start a number of subprocesses in my Python script and then track when they complete or crash.
subprocess.Popen.poll() seems to return None when the process is still running, 0 on success, and non-zero on failure. Can that be expected on all OS's?
Unfortunately the standard library documentation is lacking for these methods...
Is the subprocess module the most suitable to achieve this goal?
thanks |
Apache vs Twisted | 1,411,038 | 11 | 6 | 4,183 | 0 | python,apache,twisted | Twisted is a platform for developing internet applications, for handling the underlying communications and such. It doesn't "do" anything out of the box--you've got to program it.
Apache is an internet application, of sorts. Upon install, you have a working web server which can serve up static and dynamic web pages. Beyond that, it can be extended to do more than that, if you wish. | 0 | 1 | 0 | 0 | 2009-09-11T13:46:00.000 | 4 | 1.2 | true | 1,410,967 | 0 | 0 | 0 | 3 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. |
Apache vs Twisted | 1,456,513 | 2 | 6 | 4,183 | 0 | python,apache,twisted | @alphazero You read that Twisted vs. Tornado benchmark wrong (or you didn't read it at all). Quote from the article: " Lower mean response time is better." Twisted is lower. People want their webservers to respond with lower (faster) times.
Twisted leaves Tornado in the dust... or, in reality, they differ by a nearly trivial constant factor. | 0 | 1 | 0 | 0 | 2009-09-11T13:46:00.000 | 4 | 0.099668 | false | 1,410,967 | 0 | 0 | 0 | 3 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. |
Apache vs Twisted | 1,411,014 | 2 | 6 | 4,183 | 0 | python,apache,twisted | They are two different things, one is a pure WEB server and one is a WEB framework with a builtin event driven servers.
Twisted is good for constructing high-end ad-hoc network services. | 0 | 1 | 0 | 0 | 2009-09-11T13:46:00.000 | 4 | 0.099668 | false | 1,410,967 | 0 | 0 | 0 | 3 | I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. |
Twisted(asynch server) vs Django(or any other framework) | 1,468,718 | 5 | 15 | 11,799 | 0 | python,django,asynchronous,twisted,real-time | The biggest advantage for me is that Twisted gives me an application that has state, and can communicate with many different clients using many protocols.
For me, my Twisted server communicates with a number of sensors installed in houses and businesses that monitor power usage. It stores the data and keeps recent data and state in handy-dandy python classes in memory. Requests via xmlrpc from django get this state and can present recent data to the user. My Gridspy stuff is still in development so the actual site at your.gridspy.co.nz is a bit pre-alpha.
The best part is that you need surprisingly little code to make an effective server. An amazing amount of the work is done for you. | 0 | 1 | 0 | 0 | 2009-09-11T17:09:00.000 | 6 | 0.16514 | false | 1,412,169 | 0 | 0 | 1 | 4 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. |
Twisted(asynch server) vs Django(or any other framework) | 1,417,358 | 3 | 15 | 11,799 | 0 | python,django,asynchronous,twisted,real-time | In twisted you can implement protocols of your own. Django certainly can't do this. | 0 | 1 | 0 | 0 | 2009-09-11T17:09:00.000 | 6 | 0.099668 | false | 1,412,169 | 0 | 0 | 1 | 4 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. |
Twisted(asynch server) vs Django(or any other framework) | 1,412,226 | 16 | 15 | 11,799 | 0 | python,django,asynchronous,twisted,real-time | Asynchronous servers support much larger numbers of simultaneous client connections. More conventional servers come up against thread and process limits when servicing large number of concurrent clients, particularly those with long-lived connections. Async servers can also provide better performance as they avoid the overheads of e.g. thread context switching.
As well as the Twisted framework, there are also asynchronous server building blocks in Python's standard library: previously asyncore and asynchat, but now also asyncio. | 0 | 1 | 0 | 0 | 2009-09-11T17:09:00.000 | 6 | 1.2 | true | 1,412,169 | 0 | 0 | 1 | 4 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. |
Twisted(asynch server) vs Django(or any other framework) | 1,412,372 | 19 | 15 | 11,799 | 0 | python,django,asynchronous,twisted,real-time | First off Django is a framework for writing web apps so it provides ORM, html templating, it requires running an http server etc. Twisted helps to write much lower level code than that. You could use twisted to write the http server Django runs on. If you use Django you are limited to http model, with twisted it could be communicating in any protocol you like including push protocols. So for your chat example you get a server that scales better since it can push comments to people who have logged in VS with django every client having to poll repeatedly.
edited to reflect comments by: sos-skyl | 0 | 1 | 0 | 0 | 2009-09-11T17:09:00.000 | 6 | 1 | false | 1,412,169 | 0 | 0 | 1 | 4 | I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?
Sorry I am obviously little confused about the need for an asynchronous framework. |
Resources for developing Python and Google App Engine | 1,415,236 | 3 | 2 | 471 | 0 | python,google-app-engine,user-controls,controls | The google app engine "Getting Started" tutorial is very good. The django documentation is also really detailed.
Take a look at GoogleIO on youtube and watch some of the tutorials. | 0 | 1 | 0 | 0 | 2009-09-12T14:07:00.000 | 3 | 0.197375 | false | 1,415,208 | 0 | 0 | 1 | 2 | I would like to ask about some sources for developing applications with Python and Google App Engine.
For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome.
Thank you! |
Resources for developing Python and Google App Engine | 1,419,518 | 7 | 2 | 471 | 0 | python,google-app-engine,user-controls,controls | The Python community tends to look askance at code generation; so, @Hoang, if you think code generation is THE way to go, I suggest you try just about any other language BUT Python.
@Dominic has already suggested some excellent resources, I could point you to more (App Engine Fan, App Engine Utilities, etc, etc) but they're all based on the Pythonic mindset: understand what you need and what you could be doing, wrap as much of it as feasible into reusable components, reuse those components from your own sources.
You want magic, wizards and code generation that basically excused you (in theory) from STUDYING and UNDERSTANDING: give up on Python, it's SO not the language for that, | 0 | 1 | 0 | 0 | 2009-09-12T14:07:00.000 | 3 | 1.2 | true | 1,415,208 | 0 | 0 | 1 | 2 | I would like to ask about some sources for developing applications with Python and Google App Engine.
For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome.
Thank you! |
Google appengine string replacement in template file | 1,416,947 | 1 | 0 | 600 | 0 | python,google-app-engine | Apart from the argument-less .fetch() call in your code, which I believe can't possibly work (you ALWAYS have to pass fetch an argument -- the max number of entities you're willing to fetch!), I can't reproduce your problem -- assigning a new attribute (including one obtained by processing existing ones) to each item just works fine in my tests.
Can you please reproduce your observed problem in as tiny as compass as possible and edit your question to include all relevant files pls? Seems to be the only way we could help you with your weird observed bug!
BTW, select name,LEFT( description, 50 ) or whatever OF COURSE won't work in GQL -- GQL, very very explicitly, ONLY supports select * to get whole entities, or select __key__ to get just the entities' keys -- that's all; NO selectivity of columns in the select, much less any OPERATIONS on them!-) | 0 | 1 | 0 | 0 | 2009-09-13T05:23:00.000 | 2 | 0.099668 | false | 1,416,921 | 0 | 0 | 1 | 1 | I'm using google appengine (python, of course :) ) and I'd like to do a string.replace on a string from the template file.
{% for item in items %}
<p>{{ item.code.replace( '_', ' ' ) }}</p>
{% endfor %}
But that isn't working. So we cannot execute anything other than basic checks in the app engine templates. Is that Correct ?
Another related problem is I'm trying to shorten a string and make it available to the template.
Each furniture object has a name and a longer description field. In this view I'm rendering, I want only the first 50 characters of the description field.
So I tried something like
items = db.GqlQuery( 'select * from furniture' )
# edit: if you change the above line to
# items = db.GqlQuery( 'select * from furniture' ).fetch( 1000 )
# the .fetch() command makes the addition of dynamic properties work!
for item in items :
item.shortdescr = item.description[ 0:50 ]
# pass data off to template for rendering
self.response.out.write(
template.render( 'furnitureAll.html', { 'items' : items } )
)
Template goes
{% for item in items %}
<p>{{ item.name }}</p>
<p>{{ item.shortdescr }}</p>
<!-- items.shortdescr does not exist here,
probably because I did not .put() it previously. -->
{% endfor %}
Since that didn't work, I tried changing the Gql Query to shorten the string instead. But I'm quickly realizing Gql isn't like SQL. I'm trying to write queries like
select name,LEFT( description, 50 ) from furniture
With little success |
Auto executable python file without opening from terminal? | 1,419,455 | 3 | 3 | 9,279 | 0 | python,linux | First, pick a file extension you want for files you want to have this behavior. pyw is probably a good choice.
Name your file that, and in your file browser associate that file type with python. In GNOME, you'd open its Properties window, go to the Open With tab, and enter python as a custom command.
Now here's the important part: That little dialog you've been getting asking you what you'd like to do with the file is because it is marked as executable. Remove the executable bit with chmod -x. Now when you double click it, it will simply be opened with the associated program.
Of course, if you want to run it from the command line, you'll now have to start it with python explicitly since it isn't marked executable. The shebang line doesn't matter anymore, but I'd leave it in anyway in case someone else marks it executable and expects it to work. | 0 | 1 | 0 | 1 | 2009-09-13T18:53:00.000 | 6 | 1.2 | true | 1,418,553 | 0 | 0 | 0 | 1 | Sorry if this is on the wrong site ( maybe superuser ) but I'm trying to make my python.py file executable so I can click on it and it automatically does its thing, without me specifying it to open in the terminal by that default prompt, and I already have 'chmod +x' for its permissions.
Clarification:
I want to run it by clicking on it, not through the terminal ( I meant that when I said 'can click on it and it automatically does its thing ' )
Already have a shebang line
When I click it right now, it prompts me with do you want to open it in a text file, terminal - can I make it always default to opening in the terminal or is this just an oddball request? |
fcntl substitute on Windows | 1,422,436 | 95 | 86 | 122,994 | 0 | python,windows,linux | The substitute of fcntl on windows are win32api calls. The usage is completely different. It is not some switch you can just flip.
In other words, porting a fcntl-heavy-user module to windows is not trivial. It requires you to analyze what exactly each fcntl call does and then find the equivalent win32api code, if any.
There's also the possibility that some code using fcntl has no windows equivalent, which would require you to change the module api and maybe the structure/paradigm of the program using the module you're porting.
If you provide more details about the fcntl calls people can find windows equivalents. | 0 | 1 | 0 | 1 | 2009-09-14T15:43:00.000 | 3 | 1.2 | true | 1,422,368 | 0 | 0 | 0 | 1 | I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportError, because this module does not exist here.
Is there any way for me to make a small change in the program to make it work on Windows? |
Default save path for Python IDLE? | 20,500,218 | 4 | 9 | 28,611 | 0 | python,python-idle | I actually just discovered the easiest answer, if you use the shortcut link labeled "IDLE (Python GUI)". This is in Windows Vista, so I don't know if it'll work in other OS's.
1) Right-click "Properties".
2) Select "Shortcut" tab.
3) In "Start In", write file path (e.g. "C:\Users...").
Let me know if this works! | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.072599 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 35,376,000 | 1 | 9 | 28,611 | 0 | python,python-idle | For OS X:
Open a new finder window,then head over to applications.
Locate your Python application. (For my mac,it's Python 3.5)
Double click on it.
Right click on the IDLE icon,show package contents.
Then go into the contents folder,then resources.
Now,this is the important part:
(Note: You must be the administrator or have the administrator's password for the below to work)
Right click on the idlemain.py,Get Info.
Scroll all the way down. Make sure under the Sharing & Permissions tab,your "name"(Me) is on it with the privilege as Read & Write.
If not click on the lock symbol and unlock it.
Then add/edit yourself to have the Read & Write privilege.
Lastly,as per Ned Deily's instructions,edit the line:
os.chdir(os.path.expanduser('~/Documents'))
with your desired path and then save the changes.
Upon restarting the Python IDLE,you should find that your default Save as path to be the path you've indicated. | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.01818 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 53,340,799 | 2 | 9 | 28,611 | 0 | python,python-idle | In Windows 10+, click the Windows Start button, then type idle, and then right-click on the IDLE desktop app and open the file location. This should bring you to the Start Menu shortcuts for Python, and you'll find a shortcut to IDLE there. Right-click on the IDLE shortcut and select properties. Set the "Start in" directory to be where you want default save path to be. | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.036348 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 43,900,532 | 1 | 9 | 28,611 | 0 | python,python-idle | I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit)
The click on properties and then in the shortcut tab go to
Start in and entering the desired path worked for me kindly note if IDLE is open and running while you do this you'll have to shut it down and restart it for this to work | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.01818 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 5,161,261 | 2 | 9 | 28,611 | 0 | python,python-idle | It seems like you can get idle into the directory you want if you run any module from that directory.
I had previously tried opening idlemain.py through the path browser. I was able to open and edit the file, but it seemed like I wasn't able to save my modifications.
I'm just glad to hear other people are having this problem. I just thought I was being stupid. | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.036348 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 1,424,722 | 1 | 9 | 28,611 | 0 | python,python-idle | On Windows (Vista at least, which is what I'm looking at here), shortcut icons on the desktop have a "Start in" field where you can set the directory used as the current working directory when the program starts. Changing that works for me. Anything like that on the Mac? (Starting in the desired directory from the command line works, too.) | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.01818 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 1,424,502 | 0 | 9 | 28,611 | 0 | python,python-idle | If you locate the idlelib directory in your Python install, it will have a few files with the .def extension. config-main.def has instructions on where to put the custom config files. However, looking through these I did not find any configurable paths (your install may vary). Looks like you might need to crack open the editor code to alter it. | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Default save path for Python IDLE? | 1,424,507 | 1 | 9 | 28,611 | 0 | python,python-idle | If you open a module, that sets the default working directory.
Start IDLE.
File -> Open to open your file. And set the current working directory. | 0 | 1 | 0 | 1 | 2009-09-14T23:28:00.000 | 11 | 0.01818 | false | 1,424,398 | 0 | 0 | 0 | 8 | Does anyone know where or how to set the default path/directory on saving python scripts prior to running?
On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas? |
Proxy for Google App Engine | 1,427,324 | 1 | 2 | 5,503 | 0 | python,google-app-engine,proxy | SOCKS is not an HTTP-based protocol, so it's not possible to write a SOCKS proxy on App Engine.
Edit: Note I wrote the above when you were specifically referring to a SOCKS proxy.
Regarding general HTTP proxy servers, you can't really do that on App Engine, either, because proxies need to be able to accept requests for any hostname; your App Engine app will only accept requests for the hosts you're serving off it.
You could write an 'anonymizer' type interface on App Engine, but it's not a true proxy, because it will require rewriting URLs to work. | 0 | 1 | 0 | 0 | 2009-09-15T12:08:00.000 | 3 | 0.066568 | false | 1,426,779 | 0 | 0 | 1 | 1 | I am looking for a basic open source http proxy server for Google App Engine.
Preferably written in Python. Any suggestions? |
Finding the command for a specific PID in Linux from Python | 1,440,965 | 0 | 8 | 9,565 | 0 | python,linux,process | The proc filesystem exports this (and other) information.
Look at the /proc/PID/cmd symlink. | 0 | 1 | 0 | 1 | 2009-09-17T19:44:00.000 | 7 | 0 | false | 1,440,941 | 0 | 0 | 0 | 3 | I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.
Any help would be great. Thanks. |
Finding the command for a specific PID in Linux from Python | 1,443,544 | 5 | 8 | 9,565 | 0 | python,linux,process | Look in /proc/$PID/cmdline, and then os.readlink() on /proc/$PID/exe.
/proc/$PID/cmdline is not necessarily going to be correct, as a program can change its argument vector or it may not contain a full path. Three examples of this from my current process list are:
avahi-daemon: chroot helper
qmgr -l -t fifo -u
/usr/sbin/postgrey --pidfile=/var/run/postgrey.pid --daemonize --inet=127.0.0.1:60000 --delay=55
That first one is obvious - it's not a valid path or program name. The second is just an executable with no path name. The third looks ok, but that whole command line is actually in argv[0], with spaces separating the arguments. Normally you should have NUL separated arguments.
All this goes to show that /proc/$PID/cmdline (or the ps(1) output) is not reliable.
However, nor is /proc/$PID/exe. Usually it is a symlink to the executable that is the main text segment of the process. But sometimes it has " (deleted)" after it if the executable is no longer in the filesystem.
Also, the program that is the text segment is not always what you want. For instance, /proc/$PID/exe from that /usr/sbin/postgrey example above is /usr/bin/perl. This will be the case for all interpretted scripts (#!).
I settled on parsing /proc/$PID/cmdline - taking the first element of the vector, and then looking for spaces in that, and taking all before the first space. If that was an executable file - I stopped there. Otherwise I did a readlink(2) on /proc/$PID/exe and removed any " (deleted)" strings on the end. That first part will fail if the executable filename actually has spaces in it. There's not much you can do about that.
BTW. The argument to use ps(1) instead of /proc/$PID/cmdline does not apply in this case, since you are going to fall back to /proc/$PID/exe. You will be dependent on the /proc filesystem, so you may as well read it with read(2) instead of pipe(2), fork(2), execve(2), readdir(3)..., write(2), read(2). While ps and /proc/$PID/cmdline may be the same from the point of view of lines of python code, there's a whole lot more going on behind the scenes with ps. | 0 | 1 | 0 | 1 | 2009-09-17T19:44:00.000 | 7 | 0.141893 | false | 1,440,941 | 0 | 0 | 0 | 3 | I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.
Any help would be great. Thanks. |
Finding the command for a specific PID in Linux from Python | 1,440,969 | 6 | 8 | 9,565 | 0 | python,linux,process | Look in /proc/$PID/cmdline | 0 | 1 | 0 | 1 | 2009-09-17T19:44:00.000 | 7 | 1 | false | 1,440,941 | 0 | 0 | 0 | 3 | I'd like to know if it's possible to find out the "command" that a PID is set to. When I say command, I mean what you see in the last column when you run the command "top" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.
Any help would be great. Thanks. |
Python execute program change path | 1,442,077 | 3 | 1 | 3,173 | 0 | python,path,executable | You can change the current directory of your script with os.chdir(). You can also set environment variables with os.environ | 0 | 1 | 0 | 0 | 2009-09-18T00:22:00.000 | 3 | 1.2 | true | 1,442,024 | 1 | 0 | 0 | 1 | I'm trying to make a Python script run another program from its own path.
I've got the execution of the other program working using os.system, but the program will crash because it cannot find its resources (wrong path, I assume). I tried adding the folder harboring the executable to the path, but that didn't help. |
How to get the name of a running Python script? | 1,451,204 | 10 | 12 | 16,150 | 0 | python | It depends on what you mean by "a running python script".
__file__ will give you the name of the currently executing file. If that's a module, you'll get where it was imported from e.g. blahblah.pyc
sys.argv[0] will give you the name of the script that is being run, even if called from a module that that script imported.
Please do look up the answers to the earlier question on this topic (see S.Lott's comment on your question). | 0 | 1 | 0 | 0 | 2009-09-20T06:59:00.000 | 6 | 1 | false | 1,450,478 | 1 | 0 | 0 | 2 | How do I get the name of a running Python script?
I tried os.__file__ but that returns the name of the file where os resides. |
How to get the name of a running Python script? | 1,450,484 | 1 | 12 | 16,150 | 0 | python | sys.argv[0] should give you the name of the script. | 0 | 1 | 0 | 0 | 2009-09-20T06:59:00.000 | 6 | 0.033321 | false | 1,450,478 | 1 | 0 | 0 | 2 | How do I get the name of a running Python script?
I tried os.__file__ but that returns the name of the file where os resides. |
Detecting symlinks (mklink) on Vista/7 in Python without Pywin32 | 4,610,520 | 0 | 4 | 1,727 | 0 | python,windows,windows-vista,pywin32 | You could leverage the Tcl you have available with Tkinter, as that has a 'file link' command that knows about junctions, unlike Pythons os module. | 0 | 1 | 0 | 0 | 2009-09-20T22:06:00.000 | 5 | 0 | false | 1,452,148 | 0 | 0 | 0 | 1 | Currently the buildout recipe collective.recipe.omelette uses junction.exe on all versions of Windows to create symlinks. However junction.exe does not come with Windows by default and most importantly does not support creating symlinks to files (only directories) which causes a problem with quite a few Python packages.
On NT6+ (Vista and 7) there is now the mklink utility that not only comes by default but is also capable of creating symlinks to files as well as directories. I would like to update collective.recipe.omelette to use this if available and have done so except for one otherwise simple feature; detecting whether a file or folder is actually a symlink. Since this is a small buildout recipe, requiring Pywin32 in my opinion is a bit too much (unless setuptools could somehow only download it on Windows?).
Currently on Windows what omelette does is call junction.exe on the folder and then grep the response for "Substitute Name:" but I can't find anything as simple for mklink.
The only method I can think of is to call "dir" in the directory and then to go through the response line by line looking for "<SYMLINK>" and the folder/filename on the same line. Surely there is something better? |
Nose unable to find tests in ubuntu | 1,579,787 | 110 | 54 | 20,517 | 0 | python,nose | The other thing which always gets me with nose is that it won't run tests in executable files. I'm not exactly sure why that would make a difference across Mac/Ubuntu, but it's worth a shot.
Make sure that the scripts didn't somehow get chmod +x'd on the Mac… And if they did, fix them with chmod -x $(find tests/ -name '*.py'). | 0 | 1 | 0 | 0 | 2009-09-21T21:55:00.000 | 7 | 1 | false | 1,457,104 | 0 | 0 | 0 | 2 | Is there any reason why Nose wouldn't be able to find tests in Ubuntu 9.04?
I'm using nose 0.11.1 with python 2.5.4.
I can run tests only if I explicitly specify the filename.
If I don't specify the filename it just says, 0 tests.
The same project runs tests fine on my Mac, so I'm quite stumped! |
Nose unable to find tests in ubuntu | 47,909,167 | 2 | 54 | 20,517 | 0 | python,nose | Use the -all-modules and it will find all the tests.
nosetests --all-modules ./tests | 0 | 1 | 0 | 0 | 2009-09-21T21:55:00.000 | 7 | 0.057081 | false | 1,457,104 | 0 | 0 | 0 | 2 | Is there any reason why Nose wouldn't be able to find tests in Ubuntu 9.04?
I'm using nose 0.11.1 with python 2.5.4.
I can run tests only if I explicitly specify the filename.
If I don't specify the filename it just says, 0 tests.
The same project runs tests fine on my Mac, so I'm quite stumped! |
Install python 2.6 in CentOS | 1,465,105 | 25 | 87 | 189,056 | 0 | python,centos,rpath | No, that's it. You might want to make sure you have all optional library headers installed too so you don't have to recompile it later. They are listed in the documentation I think.
Also, you can install it even in the standard path if you do make altinstall. That way it won't override your current default "python". | 0 | 1 | 0 | 0 | 2009-09-23T09:53:00.000 | 15 | 1 | false | 1,465,036 | 1 | 0 | 0 | 1 | I have a shell that runs CentOS.
For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4.
From what I've read, a number of things will break if you upgrade to 2.5.
I want to install 2.5 separately from 2.4, but I'm not sure how to do it. So far I've downloaded the source tarball, untarred it, and did a ./configure --prefix=/opt which is where I want it to end up. Can I now just make, make install ? Or is there more? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.