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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Python subprocess how to determine if child process hangs?
| 3,724,322
| 2
| 2
| 2,476
| 0
|
python,process,subprocess,parent-child
|
Well, how do you tell the difference between a stuck process and a process that takes longer than usual to complete? The short answer is: No, you can't detect if your child process is stuck.
I would say that to be able to detect this you need some kind of continuous communication with the process (e.g. look at log files, IPC or similar). Based on this communication you might be able to tell when and if a process is stuck.
| 0
| 1
| 0
| 0
|
2010-09-16T06:35:00.000
| 2
| 1.2
| true
| 3,724,238
| 1
| 0
| 0
| 2
|
How do I know is there my child process got hang while operating?
|
How to call an executable as independent process using python in windows
| 3,727,415
| 1
| 3
| 1,090
| 0
|
python,windows,python-3.x
|
I sounds as if you want the callee to callback the caller (sorry for the alliteration :) Since you are using Python 3.1 maybe the subprocess module will provide the intended behavior. It is not a true callback per se, but the calling program can perform decisions based on the output of the called program (exe in this case.)
| 0
| 1
| 0
| 0
|
2010-09-16T10:43:00.000
| 1
| 0.197375
| false
| 3,725,859
| 0
| 0
| 0
| 1
|
After calling an exe using python script in windows, the exe should run independent of this python script and once it is initiated the control should comeback to python script and executes the further script and control of .py file will die. But on other side before finishing execution, the exe should call this python script.
Ideas would be highly appreciated.
I have tried following commands:
os.system("start test.exe")
os.startfile("test.exe")
os.spawnlv(os.P_NOWAIT, "test.exe")
os.spawnv(os.P_NOWAIT, 'C:\Python31\python.exe', ('python', 'test.py'))
os.execvp("python3", ("test.py", ))
|
Using Python in Netbeans
| 3,743,725
| 0
| 1
| 486
| 0
|
python,netbeans
|
You probably want to ask this question on www.serverfault.com rather than stackoverflow as it is more of a configuration issue rather than a programming issue.
Include the version of Netbeans and the Java you are using - and whether you using native python and/or Jython as well.
Also include at which point you see the error message - when you create a new file, new project etc - does Netbeans start up ok etc ?
| 0
| 1
| 0
| 0
|
2010-09-16T15:42:00.000
| 1
| 0
| false
| 3,728,310
| 1
| 0
| 1
| 1
|
I have x64 Windows XP machine.
I use Netbeans to code Java.
I am now trying to use it for Python, but I get this error:
\NetBeans was unexpected at this time.
Any idea how to fix it?
|
How to update $PATH
| 3,730,090
| 1
| 3
| 3,792
| 0
|
python,scripting,path,bash
|
You shouldn't. It's the user choice whether he wants that in the PATH, in what cases and how to achieve that. What you can do is inform the user about the directory where your scripts reside and suggest putting it to the PATH.
Or maybe you're asking from the user's perspective?
| 0
| 1
| 0
| 1
|
2010-09-16T19:17:00.000
| 7
| 0.028564
| false
| 3,729,965
| 0
| 0
| 0
| 5
|
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts).
I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal).
Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ?
What advantages / disadvantages I might encounter ?
For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login.
Thanks
|
How to update $PATH
| 3,730,011
| 2
| 3
| 3,792
| 0
|
python,scripting,path,bash
|
.profile would be a reasonable place if it's a per-user install; /etc/profile.d for system-wide installs. (You'll need root to do that, of course.)
Your installer won't be able to change the path of the current shell (unless it's being run via source, which would be...odd.)
| 0
| 1
| 0
| 1
|
2010-09-16T19:17:00.000
| 7
| 0.057081
| false
| 3,729,965
| 0
| 0
| 0
| 5
|
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts).
I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal).
Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ?
What advantages / disadvantages I might encounter ?
For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login.
Thanks
|
How to update $PATH
| 3,730,014
| 2
| 3
| 3,792
| 0
|
python,scripting,path,bash
|
For scripts that go in the $HOME directory you'd typically use $HOME/bin folder instead which is (usually) on the path.
| 0
| 1
| 0
| 1
|
2010-09-16T19:17:00.000
| 7
| 0.057081
| false
| 3,729,965
| 0
| 0
| 0
| 5
|
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts).
I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal).
Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ?
What advantages / disadvantages I might encounter ?
For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login.
Thanks
|
How to update $PATH
| 3,730,027
| 1
| 3
| 3,792
| 0
|
python,scripting,path,bash
|
~/.bashrc is read every time gnome-terminal is opened, (assuming the user has SHELL set to /bin/bash).
Be sure to check os.environ['PATH'] to see if the directory has already been added, so that the script doesn't add it more than once.
| 0
| 1
| 0
| 1
|
2010-09-16T19:17:00.000
| 7
| 1.2
| true
| 3,729,965
| 0
| 0
| 0
| 5
|
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts).
I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal).
Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ?
What advantages / disadvantages I might encounter ?
For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login.
Thanks
|
How to update $PATH
| 3,730,001
| 1
| 3
| 3,792
| 0
|
python,scripting,path,bash
|
/etc/profile.d would add it to every user's path
~/.bashrc would just be your own
you can always do "$ source ~/.bashrc" to re-read the config files.
| 0
| 1
| 0
| 1
|
2010-09-16T19:17:00.000
| 7
| 0.028564
| false
| 3,729,965
| 0
| 0
| 0
| 5
|
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts).
I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal).
Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ?
What advantages / disadvantages I might encounter ?
For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login.
Thanks
|
Python subprocess timeout?
| 3,733,359
| 2
| 19
| 37,063
| 0
|
python,timeout,pipe,subprocess,popen
|
Unfortunately, there isn't such a solution. I managed to do this using a threaded timer that would launch along with the process that would kill it after the timeout but I did run into some stale file descriptor issues because of zombie processes or some such.
| 0
| 1
| 0
| 0
|
2010-09-17T07:00:00.000
| 10
| 0.039979
| false
| 3,733,270
| 1
| 0
| 0
| 1
|
Is there any argument or options to setup a timeout for Python's subprocess.Popen method?
Something like this:
subprocess.Popen(['..'], ..., timeout=20) ?
|
TCP server: how to avoid message overlapping
| 3,733,452
| 0
| 0
| 772
| 0
|
python,networking,tcp
|
You often write clients in the plural form: are there several clients connecting to your server? In this case, each client should be using its own TCP stream, and the issue you are describing should never occur.
If the various commands are send from a single client, then you should write your client code so that it waits for the answer to a command before issuing the next one.
| 0
| 1
| 1
| 0
|
2010-09-17T07:20:00.000
| 3
| 1.2
| true
| 3,733,363
| 0
| 0
| 0
| 2
|
I am going to write a TCP server, the client sends me XML message, I am wondering if below condition will happen and how to avoid that:
1) client sends <cmd ...></cmd>
2) sever is busy doing something
3) clients sends <cmd ...></cmd>
4) server does a recv() and put the string to buffer
Will the buffer be filled with <cmd ...></cmd><cmd ...></cmd> or even worse <cmd ...></cmd><cmd ... if my buffer is not big enough?
What I want is the TCP stack divides the messages to the same pieces as how clients sent them.
Is it doable?
|
TCP server: how to avoid message overlapping
| 3,733,419
| 4
| 0
| 772
| 0
|
python,networking,tcp
|
This is impossible to guarantee at the TCP level, since it only knows about streams.
Depending on the XML parser you're using, you should be able to feed it the stream and have it tell you when it has a complete object, leaving the second <cmd... in its buffer until it is closed also.
| 0
| 1
| 1
| 0
|
2010-09-17T07:20:00.000
| 3
| 0.26052
| false
| 3,733,363
| 0
| 0
| 0
| 2
|
I am going to write a TCP server, the client sends me XML message, I am wondering if below condition will happen and how to avoid that:
1) client sends <cmd ...></cmd>
2) sever is busy doing something
3) clients sends <cmd ...></cmd>
4) server does a recv() and put the string to buffer
Will the buffer be filled with <cmd ...></cmd><cmd ...></cmd> or even worse <cmd ...></cmd><cmd ... if my buffer is not big enough?
What I want is the TCP stack divides the messages to the same pieces as how clients sent them.
Is it doable?
|
How to set Google App Engine cron job using different interval in different period of time?
| 3,736,761
| 3
| 0
| 502
| 0
|
python,google-app-engine,cron
|
I would recommend just using every 5 minutes synchronized in the cron.yaml, and then just terminate immediately in the handler if the exact time is not to your liking (hour before 9 or after 20 and minute // 5 is odd, for example). GAE's cron is not very sophisticated, but running a trivial handler which just gets the time, checks whether that's OK, and terminates immediately otherwise, is pretty simple and cheap (and the 70 or so "extra hits per day", each with a trivial amount of resource consumption, will hardly make a difference to your app's overall resource consumption anyway).
| 0
| 1
| 0
| 0
|
2010-09-17T15:01:00.000
| 2
| 0.291313
| false
| 3,736,497
| 0
| 0
| 0
| 1
|
How to config a cron job to run every 5 minutes between 9:00am~20:00pm,
but every 10 minutes in other time of the day.
|
is there a compatible TCL environment variable for cygwin and python idle
| 3,739,923
| 0
| 0
| 167
| 0
|
python,cygwin,tcl
|
If you could change the variable, you know already which it is, and to which value it is set. Would you kindly share this information, maybe someone can make an educated guess?
| 0
| 1
| 0
| 0
|
2010-09-18T00:05:00.000
| 1
| 0
| false
| 3,739,837
| 1
| 0
| 0
| 1
|
Idle stopped working after installing cygwin and after some troubleshooting (on windows if its not obvious), it looks like the issue is with a TCL library. They both use an environment variable to locate tcl. when I installed cygwin, it overwrote the variable to a different (and incompatible to python) version. Now I figure I can just change the variable, but it seems kind of a hassle to switch between them all of the time. Does anyone have a good solution to this? (besides not using cygwin or something...)
|
Total number of live sessions on GAE
| 3,740,943
| 1
| 0
| 94
| 0
|
python,google-app-engine
|
Considering the distributed nature of GAE, I don't think you can do this directly.
You can store visits in the database (with timestamp) and query this (use a cookie to check if a user is already counted, avoid writing on each request!).
Alternatively, you can use some external service that uses included javascript or image that counts this for you, much like how analytics works.
| 0
| 1
| 0
| 0
|
2010-09-18T08:37:00.000
| 1
| 1.2
| true
| 3,740,932
| 0
| 0
| 1
| 1
|
Is there a way to count total number of active sessions (e.g. in 10 minutes) on Google App Engine (Python)?
I want to show something on frontpage like, This site currently haz 200 people online
|
Read EXE, MSI, and ZIP file metadata in Python in Linux
| 3,742,782
| 1
| 7
| 4,161
| 0
|
python,windows-installer,metadata,md5
|
To answer your second question: no, there is no way to hash a PE file or ZIP file, ignoring the metadata, without locating and reading the metadata. This is because the metadata you're interested in is stored at variable locations in the file.
In the case of PE files (EXE, DLL, etc), it's stored in a resource block, typically towards the end of the file, and a series of pointers and tables at the start of the file gives the location.
In the case of ZIP files, it's scattered throughout the archive -- each included file is preceded by its own metadata, and then there's a table at the end giving the locations of each metadata block. But it sounds like you might actually be wanting to read the files within the ZIP archive and look for EXEs in there if you're after program metadata; the ZIP archive itself does not store company names or version numbers.
| 0
| 1
| 0
| 0
|
2010-09-18T16:55:00.000
| 4
| 0.049958
| false
| 3,742,583
| 1
| 0
| 0
| 1
|
I am writing a Python script to index a large set of Windows installers into a DB.
I would like top know how to read the metadata information (Company, Product Name, Version, etc) from EXE, MSI and ZIP files using Python running on Linux.
Software
I am using Python 2.6.5 on Ubuntu 10.04 64-bit with Django 1.2.1.
Found so far:
Windows command line utilities that can extract EXE metadata (like filever from SysUtils), or other individual CL utils that only work in Windows. I've tried running these through Wine but they have problems and it hasn't been worth the work to go and find the libs and frameworks that those CL utils depend on and try installing them in Wine/Crossover.
Win32 modules for Python that can do some things but won't run in Linux (right?)
Secondary question:
Obviously changing the file's metadata would change the MD5 hashsum of the file. Is there a general method of hashing a file independent of the metadata besides locating it and reading it in (ex: like skipping the first 1024 byes?)
|
Making Python script accessible system wide
| 3,743,825
| 0
| 3
| 3,533
| 0
|
python,linux,windows,shell,osx-leopard
|
All of those operating systems should support a PATH environment variable which specifies directories that have executables that should be available everywhere. Make your script executable by chmod +x and place it into one of those directories (or add a new one to your PATH - I have ~/bin for instance).
I don't know how to make new kinds of files directly executable on Windows, though, but I guess you could use a .bat file as a proxy.
| 0
| 1
| 0
| 0
|
2010-09-18T22:43:00.000
| 2
| 0
| false
| 3,743,812
| 0
| 0
| 0
| 1
|
Can someone tell me how to make my script callable in any directory?
My script simply returns the number of files in a directory. I would like it to work in any directory by invoking it, instead of first being copied there and then typing python myscript.py
I am using Mac OS X, but is there a common way to get it installed on Windows and Linux?
|
How to write a python program that automatically starts when windows start?
| 3,745,929
| 2
| 2
| 2,821
| 0
|
python,windows,pyqt4,startup
|
You can just place a shortcut in the "Startup" folder, in the windows start menu.
| 0
| 1
| 0
| 0
|
2010-09-19T13:48:00.000
| 2
| 1.2
| true
| 3,745,917
| 1
| 0
| 0
| 1
|
I'm writing a program using python 2.6 and pyqt4. I want this program to automatically start whenever windows stars (something like uTorrent client). How do I make this work? I am using windows 7.
|
Other solutions/languages that are superior to the TCL-based Expect?
| 3,747,275
| 4
| 8
| 1,532
| 0
|
python,perl,awk,tcl,expect
|
ajsie asks, "Which other automation tools are you talking about?"
I'll answer a different question: "which other contexts do I have in mind"? The answer: any interactive environment OTHER than a stdio one. Expect is NOT for automation of GUI points-and-clicks, for example. Expect is also not available for Win* non-console applications, even if they look as though they are character-oriented (such exist).
An exciting counter-realization: Expect is for automation of wacky equipment that permits control by a term-like connection. If your diesel engine (or, more typically, telecomm iron) says it can be monitored by hooking up a telnet-like process (even through an old-style serial line, say), you're in a domain where Expect has a chance to work its magic.
| 0
| 1
| 0
| 1
|
2010-09-19T15:11:00.000
| 4
| 0.197375
| false
| 3,746,221
| 1
| 0
| 0
| 2
|
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do.
I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does?
Eg. I have read that people compare Expect with Awk and also Perl.
Could Awk and Perl do the same thing?
How about other languages like Python and Ruby?
Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
|
Other solutions/languages that are superior to the TCL-based Expect?
| 3,747,203
| 9
| 8
| 1,532
| 0
|
python,perl,awk,tcl,expect
|
There's more to it.
Bluntly, the original Expect--the Tcl Expect--is the best one. It better supports "interact" and various pty eccentricities than any of its successors. It has no superior, for what it does.
HOWEVER, at the same time, most Expect users exploit such a small fraction of Expect's capabilities that this technical superiority is a matter of indifference to them. In nearly all cases, I advise someone coming from Perl to use Expect.pm, someone familiar with Python to rely on Pexpect, and so on.
Naive comparisons of Perl with "... Awk and also Perl" are ill-founded.
In the abstract, all the common scripting languages--Lua, awk, sh, Tcl, Ruby, Perl, Python, ...--are about the same. Expect slightly but very effectively extends this common core in the direction of pty-awareness (there's a little more to the story that we can neglect for the moment). Roughly speaking, if your automation involves entering an invisible password, you want Expect. Awk and Perl do NOT build in this capability.
There are other automation tools for other contexts.
| 0
| 1
| 0
| 1
|
2010-09-19T15:11:00.000
| 4
| 1.2
| true
| 3,746,221
| 1
| 0
| 0
| 2
|
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do.
I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does?
Eg. I have read that people compare Expect with Awk and also Perl.
Could Awk and Perl do the same thing?
How about other languages like Python and Ruby?
Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
|
Getting BadValueError on Google App Engine Datastore Delete
| 3,747,783
| 3
| 3
| 481
| 0
|
python,google-app-engine
|
Try updating your model so that the Districts field is not required (i.e., pass required=False as a keyword parameter to the Districts field). Then the validator shouldn't complain about the existing entities and you should be able to delete the entities.
Alternatively, if you know the keys for the entities you want to delete, you can delete them directly using db.delete() without ever needing to fetch them in the first place.
You might even be able to use the datastore viewer from the Dashboard to delete them (if you don't have many entities to delete, this might be easiest).
| 0
| 1
| 0
| 0
|
2010-09-19T22:36:00.000
| 2
| 1.2
| true
| 3,747,772
| 0
| 0
| 1
| 2
|
I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader error.
What can I do?
|
Getting BadValueError on Google App Engine Datastore Delete
| 3,747,781
| 0
| 3
| 481
| 0
|
python,google-app-engine
|
Change your entities/models so that Districts is no longer a required property?
| 0
| 1
| 0
| 0
|
2010-09-19T22:36:00.000
| 2
| 0
| false
| 3,747,772
| 0
| 0
| 1
| 2
|
I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader error.
What can I do?
|
Retrieve header information from exe
| 3,749,339
| 0
| 2
| 3,428
| 0
|
python,header,exe
|
Of course it is possible to write a Python script to retrieve header information from an XYZ file. Three simple steps:
(1) Find docs for the header part of an XYZ file; read them.
(2) Read the docs for the Python struct module or ctypes module or both.
(3) Write and test the script.
Which step are you having trouble with?
| 0
| 1
| 0
| 0
|
2010-09-20T07:04:00.000
| 3
| 0
| false
| 3,749,270
| 0
| 0
| 0
| 1
|
I was wondering whether it would be possible to write a python script that retrieves header information from an .exe file. I tried googling but didn't really find any results that were usable.
Thanks.
Sept
|
How to copy directory permissions
| 3,754,917
| 1
| 1
| 1,862
| 0
|
python,permissions
|
Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.
| 0
| 1
| 0
| 1
|
2010-09-20T19:33:00.000
| 3
| 0.066568
| false
| 3,754,848
| 0
| 0
| 0
| 1
|
I'm curious how to copy the permission from directory to another.
Any idea?
Thanks
|
is it possible to have keyname and an id for an entity in Appengine?
| 3,759,934
| 2
| 0
| 68
| 0
|
python,google-app-engine
|
No. An entity's Key is composed of the application ID, the Kind, the path of the parent entity (if any) and either a key name or an auto-generated ID. It's not possible to have both. The entire Key is the "primary key".
| 0
| 1
| 0
| 0
|
2010-09-21T09:39:00.000
| 1
| 1.2
| true
| 3,759,021
| 0
| 0
| 1
| 1
|
I'm building a facebook app, and my users table's keyName is set to the Uid of the facebook user. I found this to be efficient because I can use db.Key.from_path() to efficiently query the datastore for a particular user instead of doing a query (where uid = x, limit = 1). This is actually my first time using key names.
But when I did this in the sdk, the key().id() is set to None. Is there a way have an id as well?
I'd like an id for use as a primary key is because it's shorter and an integer which makes it faster when I'm storing users in a listProperty (i.e a seperate Buddies entity with a list of friends the user has in the app).
I hope this makes sense :)
thanks a ton!
|
Running python on a Windows machine vs Linux
| 3,765,219
| 15
| 17
| 63,443
| 0
|
python,windows
|
Don't tell anybody this, but I've run python/django on windows. It works all right and the performance hit isn't any worse than you would expect from windows. I used MySQL and it installed without a problem. I had to grope around to find out how to manage it (no good ol' sudo /etc/init.d/mysql restart but i eventually found a graphical interface to do what I needed.
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 1.2
| true
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
Running python on a Windows machine vs Linux
| 3,765,246
| 1
| 17
| 63,443
| 0
|
python,windows
|
Which software are you affraid will not work on windows, the actual web app or your development enviroment. If you mean the IDE, then I wouldn't worry about that there are very good python IDEs for windows, as for the webapp that's another discussion all together
The statement that "it is very easy integrating C++ libs with python" is not accurate, there are many ways of doing it and they are not all easy, I have personally only tried SWIG, but there are many other alternatives (for example Boost.Python), whoever I wouldn't believe it is as easy to get up and running with some of these tools on a windows enviromeny with out something like mingw or cygwin as at least SWIG is built with *nix in mind
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 0.033321
| false
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
Running python on a Windows machine vs Linux
| 3,765,233
| 1
| 17
| 63,443
| 0
|
python,windows
|
Shouldn't be a problem. Some people even host Python+Django on Windows.
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 0.033321
| false
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
Running python on a Windows machine vs Linux
| 3,765,227
| 1
| 17
| 63,443
| 0
|
python,windows
|
Python program is very easily portable. Most of the time your code will work on any platform that have the appropriate version of python.
One point to be aware of though, is file path handling. Linux, Windows, Macs, etc uses different path schemes, so you shouldn't be handling them as strings; instead use os.path functions to join, split, etc.
There is ultimately some slight performance difference with regard to timing, threading, processing, I/O, but they're nothing to worry about.
Integrating Python and C++ is easy; the only problem is in the C++ side, i.e. you will have to recompile the C++ code.
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 0.033321
| false
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
Running python on a Windows machine vs Linux
| 3,765,244
| 9
| 17
| 63,443
| 0
|
python,windows
|
I've been working Py on both Windows and Linux. I favor Linux because of several things:
virtualenvs - once you start working with virtualenvs, there is no turning back.
SHELL - CMD is very frustrating when executing python/management commands in django. Also, you should add python.exe every time :).
ipython works better on Linux.
GeoDjango doesn't work on Vista/7 last time i checked. I spent 3 days trying to set it up. Just for comparison, i set GeoDjango-able development environment in 20 minutes in Linux.
Linux is free :)
Although there is no visible performance impact or incompatibility when working python cross-platform, the benefits of Linux for python development outweigh Windows by a lot. It's a lot more comfortable and definitely will boost your productivity.
...
IMHO Linux is the smart choice for Python development.
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 1
| false
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
Running python on a Windows machine vs Linux
| 3,765,742
| 14
| 17
| 63,443
| 0
|
python,windows
|
but afraid the software may not work well on a windows box.
Your software will work. The Windows OS may not work as you hope. But that's Windows, not Python.
We develop 100% on Windows. We completely test: Unit test, integration test and user acceptance test on Windows. 100%.
We deploy for production 0% on Windows, 100% on Linux.
We have a few (less than 6) differences in the unit tests that are Windows-specific.
The application has no changes. It works with Apache or not. It works with SQLite or MySQL.
| 0
| 1
| 0
| 0
|
2010-09-21T23:17:00.000
| 6
| 1
| false
| 3,765,178
| 1
| 0
| 0
| 6
|
I am interested in learning python but my Linux skills suck. I would like to develop a medium to large scale web application using python and django but afraid the software may not work well on a windows box. Is there a performance difference in running python on Linux vs Windows? Is there anything that I should watch out for when developing the application. Also, I am aware that it is very easy integrating C++ libraries with python. Is this statement still true is the code is on a windows box?
|
How to serve data from UDP stream over HTTP in Python?
| 3,768,227
| 4
| 6
| 4,771
| 0
|
python,wsgi
|
The software uses UDP to send sequential updates to a given set of variables in (near) real-time (updates every 5-10 ms). thus, I do not need to capture all UDP data -- it is sufficient that the latest update is retrieved
What you must do is this.
Step 1.
Build a Python app that collects the UDP data and caches it into a file. Create the file using XML, CSV or JSON notation.
This runs independently as some kind of daemon. This is your listener or collector.
Write the file to a directory from which it can be trivially downloaded by Apache or some other web server. Choose names and directory paths wisely and you're done.
Done.
If you want fancier results, you can do more. You don't need to, since you're already done.
Step 2.
Build a web application that allows someone to request this data being accumulated by the UDP listener or collector.
Use a web framework like Django for this. Write as little as possible. Django can serve flat files created by your listener.
You're done. Again.
Some folks think relational databases are important. If so, you can do this. Even though you're already done.
Step 3.
Modify your data collection to create a database that the Django ORM can query. This requires some learning and some adjusting to get a tidy, simple ORM model.
Then write your final Django application to serve the UDP data being collected by your listener and loaded into your Django database.
| 0
| 1
| 1
| 0
|
2010-09-22T09:44:00.000
| 3
| 1.2
| true
| 3,768,019
| 0
| 0
| 0
| 1
|
I am currently working on exposing data from legacy system over the web. I have a (legacy) server application that sends and receives data over UDP. The software uses UDP to send sequential updates to a given set of variables in (near) real-time (updates every 5-10 ms). thus, I do not need to capture all UDP data -- it is sufficient that the latest update is retrieved.
In order to expose this data over the web, I am considering building a lightweight web server that reads/write UDP data and exposes this data over HTTP.
As I am experienced with Python, I am considering to use it.
The question is the following: how can I (continuously) read data from UDP and send snapshots of it over TCP/HTTP on-demand with Python? So basically, I am trying to build a kind of "UDP2HTTP" adapter to interface with the legacy app so that I wouldn't need to touch the legacy code.
A solution that is WSGI compliant would be much preferred. Of course any tips are very welcome and MUCH appreciated!
|
How to use at command to set python script execute at specified time
| 3,774,794
| 2
| 2
| 2,030
| 0
|
python,cron,package,execute,at-job
|
type man at, it will explain how to use it. Usage will slighty differ from system to system, so there's no use to tell you here exactly.
| 0
| 1
| 0
| 1
|
2010-09-23T01:21:00.000
| 4
| 0.099668
| false
| 3,774,772
| 0
| 0
| 0
| 1
|
When I try to use cron to execute my python script in a future time, I found there is a command at, AFAIK, the cron is for periodically execute, but what my scenario is only execute for once in specified time.
and my question is how to add python script to at command,
also it there some python package for control the at command
My dev os is ubuntu 10.04 lucid,and my product server is ubuntu-server 10.04 lucid version.
in fact, I want through python script add python script tasks to at command, which file's change can effect at command add or remove new jobs
|
Determining a file's path name from different working directories in python
| 3,780,153
| 0
| 0
| 165
| 0
|
python,file,relative-path
|
Put it in a well known directory (/usr/lib/yourproject/ or ~/lib or something similar), or have it in a well known relative path based on the location of your source files that are using it.
| 0
| 1
| 0
| 0
|
2010-09-23T15:47:00.000
| 4
| 0
| false
| 3,780,094
| 1
| 0
| 0
| 2
|
I have a python module that is shared among several of my projects (the projects each have a different working directory). One of the functions in this shared module, executes a script using os.spawn. The problem is, I'm not sure what pathname to give to os.spawn since I don't know what the current working directory will be when the function is called. How can I reference the file in a way that any caller can find it? Thanks!
|
Determining a file's path name from different working directories in python
| 3,780,160
| 1
| 0
| 165
| 0
|
python,file,relative-path
|
So I just learned about the __file__ variable, which will provide a solution to my problem. I can use file to get a pathname which will be constant among all projects, and use that to reference the script I need to call, since the script will always be in the same location relative to __file__. However, I'm open to other/better methods if anyone has them.
| 0
| 1
| 0
| 0
|
2010-09-23T15:47:00.000
| 4
| 1.2
| true
| 3,780,094
| 1
| 0
| 0
| 2
|
I have a python module that is shared among several of my projects (the projects each have a different working directory). One of the functions in this shared module, executes a script using os.spawn. The problem is, I'm not sure what pathname to give to os.spawn since I don't know what the current working directory will be when the function is called. How can I reference the file in a way that any caller can find it? Thanks!
|
shell script remote execution using python
| 3,786,764
| 0
| 6
| 11,566
| 0
|
python,unix,shell
|
If you don't want to use paramiko, then try telnetlib. You can use it to execute remote commands.
| 0
| 1
| 0
| 0
|
2010-09-23T17:41:00.000
| 7
| 0
| false
| 3,781,087
| 0
| 0
| 0
| 2
|
Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine?
P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()?
|
shell script remote execution using python
| 3,781,130
| 0
| 6
| 11,566
| 0
|
python,unix,shell
|
You will either need to run some sort of server on the remote machine, or ssh in and do it yourself. It would not be difficult to use one of the many pre-written Python servers to listen for a client and kick off a shell script.
Authentication may or may not be a problem for you; be aware that anyone else can follow the same steps you do and possibly get the same result. You don't want to allow anyone on the intarwubs to start your scripts!
| 0
| 1
| 0
| 0
|
2010-09-23T17:41:00.000
| 7
| 0
| false
| 3,781,087
| 0
| 0
| 0
| 2
|
Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine?
P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()?
|
pywin32 captive installation (avoid py*.dll getting installed in system32 directory)
| 3,782,055
| 0
| 2
| 573
| 0
|
python,pywin32,python-embedding
|
I previously used py2exe to freeze the application and all the DLLs. Then use Innosetup to create an installer. Work like a charm.
| 0
| 1
| 0
| 0
|
2010-09-23T19:33:00.000
| 1
| 0
| false
| 3,781,873
| 1
| 0
| 0
| 1
|
I have python as an embedded scripting environment in my application. I supply the python bits (python26.dll, DLLs & Lib folders) with my application. All this to avoid asking users to install python (you know how it goes in big corporations).
All works nice except pywin32. It installs pythoncom26.dll and pywintypes26.dll to the system32 directory. I want to keep these dlls in my Python directory. One option is to add my Python directory to the PATH env variable. But would like to avoid it for obvious reasons (windows DLL search path priorities issues).
Is there a way to tell Windows (a windows API is also fine) to look at my directories to load these pywin32 dlls? From what I understand these dlls get called by Windows COM.
Thanks.
Edit1:
Note that python is deployed embedded with my application.
|
Problems with Vim's Pydiction and Python in Ubuntu 10.4
| 44,201,882
| 0
| 1
| 2,092
| 0
|
python,vim,autocomplete
|
That's the way my same problem i solve:
before i get this problem - i was set the path only to directory and that's was wrong
After i set the path Including the filename it starts work!
| 0
| 1
| 0
| 0
|
2010-09-23T21:19:00.000
| 3
| 0
| false
| 3,782,613
| 0
| 0
| 0
| 3
|
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm.
Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing.
Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
|
Problems with Vim's Pydiction and Python in Ubuntu 10.4
| 3,788,533
| 0
| 1
| 2,092
| 0
|
python,vim,autocomplete
|
Sounds like it's having a problem with your complete-dict file. I'm using Ubuntu 10.04 and it works fine for me. Make sure your complete-dict file actually has content in it, in this case make sure it has the word 'raw' in it.
| 0
| 1
| 0
| 0
|
2010-09-23T21:19:00.000
| 3
| 0
| false
| 3,782,613
| 0
| 0
| 0
| 3
|
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm.
Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing.
Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
|
Problems with Vim's Pydiction and Python in Ubuntu 10.4
| 3,793,008
| 1
| 1
| 2,092
| 0
|
python,vim,autocomplete
|
Problem has been solved, apparently gvim did not like the fact that i put the files in a ".vim" directory even though that was exactly what the instructions told me to do. I put them in my home folder pydiction.vim and complete-dictionary and now it works ok, with no issues.
Now autocomplete works with any word I tried it with. I am abit confused with gvim , as the instructions said to create ".vim" directory but I have also found a vimfiles directory in a etc folder. Why vim structure is so confusing? Maybe the manual should clarify directory structure to avoid confusing. Now I use a source command to load pydiction.vim from my home folder and setup the vimrc properly to point to the new paths.
At least I solved my problem myself , thanks for all replies.
| 0
| 1
| 0
| 0
|
2010-09-23T21:19:00.000
| 3
| 0.066568
| false
| 3,782,613
| 0
| 0
| 0
| 3
|
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm.
Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow the readme.txt closely , I even found a webpage that describes the process on ubuntu again repeating the same things , nothing.
Each time I tab after i type "raw" while it worked in windows in ubuntu it reports "Dictionary Completion (^K^N^P) Pattern not Found". Tried other keyword , same problem. Anyone has an idea why this happens ?
|
Output a python script to text file
| 3,791,920
| 0
| 2
| 33,610
| 0
|
python
|
That seems to work fine for me in the DOS shell.
| 0
| 1
| 0
| 0
|
2010-09-25T00:27:00.000
| 4
| 0
| false
| 3,791,905
| 1
| 0
| 0
| 1
|
I'm using a script that someone else wrote in python. It's executed from the command line with 3 arguments.
example: "python script.py 1111 2222 3333"
It does it's thing and works perfectly. The results are NOT saved though, and I would really like to pipe the output to a text file. Can I simply use similar dos commands to accomplish this? ie "...333 > output.txt"
I don't really want to post the script here if possible since it's not really my work.
|
How do you stream data into the STDIN of a program from different local/remote processes in Python?
| 3,792,108
| 1
| 2
| 1,779
| 0
|
python,process,ipc,stdout,stdin
|
In most platforms (i.e., operating systems), an existing process's existing file descriptors are inviolate -- the operating system, striving to guarantee process integrity, will be designed to not allow a separate, unrelated process to alter those file descriptors.
Nevertheless, if you do specify a very specific and well-identified platform (ideally including the exact version and release of the operating system in question, since security does tend to get tightened in successive releases compared with preceding ones), it's quite possible that there will be available tricks for your purposes. For example, you may be able to exploit some of the hooks which the operating system intends to be used for "remote debuggers" attaching themselves to existing processes -- if, that is, your very specific OS does offer such hooks (not all do!).
But, if you want a cross-platform solution, no way.
So, I recommend you edit your question, and in particular replace one of the tags with the name of the "one and only" OS you really need to support (in the Q's edited text, please be as specific as possible about the exact versions and releases you absolutely do need to support -- Python has very little indeed to do with the issue, as you need to operate at specific-OS levels, so there's no real need to similarly pinpoint the Python version).
| 0
| 1
| 0
| 0
|
2010-09-25T01:26:00.000
| 2
| 0.099668
| false
| 3,792,054
| 1
| 0
| 0
| 1
|
Standard streams are associated with a program. So, suppose there
is a program already running in some way (I don't care how or in
what way). The goal is to create pipes to the STDIN of the
program from different processes (or programs) that run either
locally or remotely and stream data into it asynchronously.
Available information is (1) the host address and (2) the pid of the program only.
How does one implement both cases in Python in this case?
Edit: I should have mentioned this presupposition. The intended operating system is Linux with a (fairly) recent kernel.
|
New to google app engine ! what to do next?
| 3,805,886
| 1
| 1
| 120
| 0
|
python,google-app-engine
|
Typically when I end up doing something more than a trivial demo I need a reason. Figure out something you want to make and stumble through it, learning as you go until it's working.
I'd use the google app engine community as a place to get questions answered, they're pretty good for that.
As a first app, I'd just have a goal that you're working towards and start asking the community "how do I do this...?"
| 0
| 1
| 0
| 0
|
2010-09-27T16:28:00.000
| 2
| 0.099668
| false
| 3,805,802
| 0
| 0
| 1
| 1
|
I want to develop some web apps using Google app engine. I had deployed a guest book application which was their in "gooleappengine" folder by changing its ID.and also was successful.This is simple one.But not getting how to develop complex web apps. Can anyone please suggest me any good Tutarial or example codes Or any books to refer.
|
AMQP implementations with Celery
| 4,311,856
| 0
| 0
| 289
| 0
|
python,amqp,celery
|
After reading some docs and trying out a few options, I have found that RabbitMQ suffices for most purposes.
| 0
| 1
| 0
| 0
|
2010-09-28T03:16:00.000
| 1
| 1.2
| true
| 3,809,440
| 0
| 0
| 1
| 1
|
I wanted to get your opinions on the merits of different AMQP implementations to be used with celery. I am looking particularly at message prioritization and job queue sizes.
What are your thoughts?
|
Getting admin password while copy file using shutil.copy?
| 3,811,219
| 1
| 6
| 7,772
| 0
|
python,file-permissions
|
Start your program with a user that is allowed to write there. For example login to root first (su) or run the script with sudo myscript.py.
| 0
| 1
| 0
| 1
|
2010-09-28T09:04:00.000
| 4
| 0.049958
| false
| 3,811,197
| 0
| 0
| 0
| 1
|
I m using shutil.copy from python to copy a list of files. But when i copy the files to /usr/lib/ location, i m getting permission denied as i need to be an administrator to do that.
So How could i copy files with admin permission or
how could i get the admin password from the user to copy the files?
Ideas would be appreciated
|
Trigger an event when system locks/unlocks on Windows XP
| 49,125,177
| 0
| 1
| 3,146
| 0
|
windows,scripting,time,tracking,python-idle
|
Do check that CanHandleSessionChange property is True or not ?
This will be checked from the designer view -> Property
Then use OnSessionChange function
| 0
| 1
| 0
| 0
|
2010-09-28T11:58:00.000
| 3
| 0
| false
| 3,812,417
| 0
| 0
| 0
| 1
|
Please help me to find a way to track lock/unlock time on my WinXP machine. I've tried windows scheduler - it only logs logins, not locks. Any alternatives?
In Miranda's source code I saw implementation via IdleObject tracker, but this way is too long. May be an AutoIt script? Time tracking program (freeware)?
|
Python App Engine: Task Queues
| 3,823,052
| 2
| 1
| 284
| 0
|
python,google-app-engine
|
I've solved this in the past by keeping the status for the tasks in memcached, and polling (via Ajax) to determine when the tasks are finished.
If you go this way, it's best if you can always "manually" determine the status of the tasks without looking in memcached, since there's always the (slim) chance that memcache will go down or will get cleared or something as a task is running.
| 0
| 1
| 0
| 0
|
2010-09-29T12:41:00.000
| 1
| 1.2
| true
| 3,821,636
| 0
| 0
| 1
| 1
|
I need to import some data to show it for user but page execution time exceeds 30 second limit. So I decided to split my big code into several tasks and try Task Queues. I add about 10-20 tasks to queue and app engine executes tasks in parallel while user is waiting for data. How can I determine that my tasks are completed to show user data ASAP? Can I somehow iterate over active tasks?
|
Running Python command-line utility from Java
| 3,824,363
| 0
| 3
| 2,293
| 0
|
java,python,scripting
|
Have you considered jython? You can:
1) use it to run python scripts (allowing it to call Java classes)
2) compile python into class files, making them usable by normal Java code without jython being present at runtime
I've only used it in the first pattern, but I've seen tonnes of docs on the second.
| 0
| 1
| 0
| 0
|
2010-09-29T17:26:00.000
| 3
| 0
| false
| 3,824,249
| 0
| 0
| 1
| 1
|
I developed a command-line utility which needs to be called from a Java GUI application. The team in charge on the Java GUI would like to bind my command-line application to a button in the GUI; the Python application is such that at the time we have no time or interest in rewriting it in Java.
I have no experience whatsoever in Java, so I ask you:
What is the best way to bind a command-line based Python application to a button in a Java-based GUI application?
I am very concerned about exception management (how to tell Java that Python failed).
Thanks.
|
ensuring dynamic image urls in a web-app: use a blob store?
| 3,831,317
| 1
| 0
| 291
| 0
|
python,sqlite,web-applications,nginx,blob
|
Why so complicated?
Serve the image under the name which the user supplied (i.e. http://www.mywebapp.com/images/foo1.jpg)
Save the images in a directory using a UUID as name.
Create a map of file names to UUIDs in the session.
In the handler for /images/ look up the real file name in the map. Return 404 if no such entry exists. Otherwise serve the image.
When the session is closed, delete all files from the map.
In a cron job, delete all images that are older than one day.
This way, several users can upload the same image (same name), images get deleted as soon as possible or by the cron job (if the server crashes or something like that).
| 0
| 1
| 0
| 0
|
2010-09-30T11:59:00.000
| 3
| 1.2
| true
| 3,830,294
| 0
| 0
| 1
| 2
|
I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired.
If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out of the session) difficult to stop. Which is why I was considering placing the images in a sqlite db, and serving them from there.
It seems that using the db for image storage is considered bad practice (though apparently the GAE blob store seems to provide this functionality), so i was trying to figure out what the alternatives would be.
1)
Perhaps I do somesort of url-re-writing like so:
http://www.mywebapp.com/images/[session_id]/foo1.jpg
Thinking of using nginx, but it seems (on a first look) that this will require some hackin to accomplish?
2)
Copy the files to a physical directory on the filesystem and delete when the session expires. this seems quite messy though?
Are there any standard methods of accomplishing this dynamic image url thing?
I'm using web.py - if that helps.
Many thanks!
|
ensuring dynamic image urls in a web-app: use a blob store?
| 3,830,345
| -1
| 0
| 291
| 0
|
python,sqlite,web-applications,nginx,blob
|
A combination of your two ideas (copy to a dir, expire when session expires) could be generalized to creating a new dir (could be as simple as a symlink) every 15 minutes. When generating the new symlink, also remove the one that's an hour old by now. Always link to the newest name in your code.
| 0
| 1
| 0
| 0
|
2010-09-30T11:59:00.000
| 3
| -0.066568
| false
| 3,830,294
| 0
| 0
| 1
| 2
|
I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired.
If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out of the session) difficult to stop. Which is why I was considering placing the images in a sqlite db, and serving them from there.
It seems that using the db for image storage is considered bad practice (though apparently the GAE blob store seems to provide this functionality), so i was trying to figure out what the alternatives would be.
1)
Perhaps I do somesort of url-re-writing like so:
http://www.mywebapp.com/images/[session_id]/foo1.jpg
Thinking of using nginx, but it seems (on a first look) that this will require some hackin to accomplish?
2)
Copy the files to a physical directory on the filesystem and delete when the session expires. this seems quite messy though?
Are there any standard methods of accomplishing this dynamic image url thing?
I'm using web.py - if that helps.
Many thanks!
|
Creating an autostart application on Ubuntu Linux
| 3,839,956
| 1
| 0
| 1,095
| 0
|
python,ubuntu-10.04,autostart,wakeup
|
If you want to guarantee it's always running, have a look at man inittab.
| 0
| 1
| 0
| 0
|
2010-10-01T13:02:00.000
| 3
| 0.066568
| false
| 3,839,383
| 0
| 0
| 0
| 2
|
I'm trying to setup a Python application that should automatically start when Linux boots. It should also start (unless not already running) if the computer resumes from standby mode - which is mainly the problem.
Does anybody know where to integrate these requirements?
Thanks,
Marius
|
Creating an autostart application on Ubuntu Linux
| 3,839,444
| 0
| 0
| 1,095
| 0
|
python,ubuntu-10.04,autostart,wakeup
|
Configure a cron job every minute to detect if application running - if not start.
| 0
| 1
| 0
| 0
|
2010-10-01T13:02:00.000
| 3
| 1.2
| true
| 3,839,383
| 0
| 0
| 0
| 2
|
I'm trying to setup a Python application that should automatically start when Linux boots. It should also start (unless not already running) if the computer resumes from standby mode - which is mainly the problem.
Does anybody know where to integrate these requirements?
Thanks,
Marius
|
Learning Twisted
| 3,846,924
| 2
| 19
| 5,772
| 0
|
python,twisted
|
Look at the samples that come with twisted's documentation. Also, the documentation is not bad, but it is not very complete. Also, the API docs are quite good in fact.
When you know with which part you start, just try and play with the code until you're stuck, then google samples relating to your code and ask on stackoverflow.
| 0
| 1
| 0
| 0
|
2010-10-02T17:50:00.000
| 4
| 0.099668
| false
| 3,846,875
| 1
| 0
| 0
| 2
|
How do I begin learning Twisted? What books, documentation or tutorial do you guys recommend?
The reason I asked this question is that I think learning Twisted would help me otherwise also in learning concepts related to network programming (terminologies and how it works and stuff) I have heard that the documentation for Twisted is not that good. Is is true?
Note that I am looking for some advise that actually helped you. I am looking for your experience. PS: I am aware of the official documentation. There is also the O'Reilly Book on Twisted; is that good?
|
Learning Twisted
| 3,846,959
| 3
| 19
| 5,772
| 0
|
python,twisted
|
The way i learned twisted was by starting a small project and lots of googling around; the twisted tutorials are sometimes not very clear, its just getting used to the framework and the way it works...
EDIT:
itd also recommend trying to understand what twisted is based on, the whole idea of twisted is to provide event driven programming for python, along with some other features such as asynchronous sockets and web server classes.
A quick explanation of deferreds and callbacks, which is the whole idea behind twisted, is creating an event (deferred object), then attaching a callback to it; then at some point ur going to fire the event, and the callback is triggered with a result (it could be null) from ur event operation. A good example is, if you have a button on a form, you create an event (a deferred object) then u attach a callback, when the user clicks a button, they fire the event, and the callback function is called to handle that event.
i hope this will give u a good general idea of what twisted is and how it can be used in a python environment, there is also IronPython (.NET) which has eventing as well.
~george
| 0
| 1
| 0
| 0
|
2010-10-02T17:50:00.000
| 4
| 0.148885
| false
| 3,846,875
| 1
| 0
| 0
| 2
|
How do I begin learning Twisted? What books, documentation or tutorial do you guys recommend?
The reason I asked this question is that I think learning Twisted would help me otherwise also in learning concepts related to network programming (terminologies and how it works and stuff) I have heard that the documentation for Twisted is not that good. Is is true?
Note that I am looking for some advise that actually helped you. I am looking for your experience. PS: I am aware of the official documentation. There is also the O'Reilly Book on Twisted; is that good?
|
Google App Engine or Django?
| 13,424,917
| 0
| 13
| 5,657
| 0
|
python,django,google-app-engine
|
If you plan to use Django on app engine, then chances are you will want to use Djangos ORM. Which means.. you will probably be looking at Django non-rel. However there are a few things to consider:
Django non-rel runs a few versions behind the latest django release, so some modern features (such as advanced timezone support) are not supported, as of the moment, you will just have to wait.
Django non-rel does not support some features such as Django's transactions API and none of the native app engine transaction modules work ether.
so all in all, fine for a small simple projects, but when things get more complicated, django non-rel falls short.
| 0
| 1
| 0
| 0
|
2010-10-02T19:29:00.000
| 4
| 0
| false
| 3,847,202
| 0
| 0
| 1
| 2
|
I've been learning Python and now I'd like to learn a Python-based web framework. I'm considering Google App Engine and Django. Which one should I choose? What are their unique features and learning curves?
|
Google App Engine or Django?
| 14,967,904
| 1
| 13
| 5,657
| 0
|
python,django,google-app-engine
|
I believe that Django is better because it gives more flexibility with features and also with hosts. Djangobook.com has a very good tutorial.
| 0
| 1
| 0
| 0
|
2010-10-02T19:29:00.000
| 4
| 0.049958
| false
| 3,847,202
| 0
| 0
| 1
| 2
|
I've been learning Python and now I'd like to learn a Python-based web framework. I'm considering Google App Engine and Django. Which one should I choose? What are their unique features and learning curves?
|
Deciding on RESTful Architecture for my Python code API
| 3,881,996
| 0
| 1
| 643
| 0
|
java,python,rest
|
Hmm, if you're into Python and open to a Java element, you might want to consider using the Java framework Restlet with Python code running in Jython. I'm a big fan of Restlet; its API embodies RESTful principles, so it encourages one to structure one's code and thinking according to those principles. It's also just a really high-quality, easy to use, well supported, and lightweight -- it's a framework, but in practice it can feel like a library.
If you want to stick with pure Python, then I haven't been able to find any libraries or frameworks which directly embrace and encourage RESTful principles. However, there are some very good WSGI microframeworks which make it easy to implement RESTful applications -- you just need to devise your own approach to structuring your code -- not too big a deal. In particular I'd recommend Bottle and web.py, both of which can be used with more or less finagling with the excellent mimerender library for solid content negotiation.
| 0
| 1
| 0
| 0
|
2010-10-02T22:41:00.000
| 1
| 0
| false
| 3,847,803
| 0
| 0
| 1
| 1
|
I would like to build something like this
Datastore | mycode.py | RESTful API | mywebapp.py(Django or Tornado)
I checked Piston for Django but it seems that this way I am going to be tied to Django, I would rather have a RESTful API for mycode.py that is consumable by more than one REST client and also can consume it from a REST client api inside my django app.
I checked stuff like Apache CFX, ApacheMQ, RabbitMQ, etc. with no real luck.
Any thoughts? thnx
|
Retrieving YAML parameters during runtime in App Engine (Python)
| 3,849,039
| 5
| 3
| 1,038
| 0
|
python,google-app-engine,runtime,yaml
|
No, but some of the data is available from os.environ - for example, os.environ['APPLICATION_ID'], and os.environ['CURRENT_VERSION_ID'].
| 0
| 1
| 0
| 0
|
2010-10-03T05:05:00.000
| 3
| 1.2
| true
| 3,848,671
| 0
| 0
| 1
| 1
|
Is it possible to programmatically retrieve any of the YAML parameters during run-time? Are they stored in the environment somewhere?
Good example would be to automatically find the application version and to add it as a comment in the landing HTML page.
|
Run a python script and a compiled c code without terminal or dock item in Mac OS X
| 3,853,095
| 0
| 2
| 1,064
| 0
|
python,macos,command-line
|
have you tried using the nohup? lets say you have a launch script to start your program:
launch.sh:
nohup your_program &
exit
| 0
| 1
| 0
| 0
|
2010-10-04T05:22:00.000
| 2
| 0
| false
| 3,853,038
| 0
| 0
| 0
| 1
|
For great help from stackoverflow, the development for the Mac version of my program is done.
Now I need to deploy my program, and I was wondering if there is any way to "hide" my running Python code (it also runs .so library and it seems it makes a dock item to appear).
The program is supposed to be running in the background and it would be great if I can hide any terminal or dock items. In Windows or linux, it was easy, but I am still not that used to Mac and could not figure out how to do this.
Thank you,
Joon
|
checking when all data is sent using non-blocking open
| 3,859,933
| 4
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
You have a misunderstanding of what non-blocking means. It does not imply asynchronous operation - you can have any combination of asynchronous/synchronous and blocking/non-blocking.
A write() just hands data off to the kernel to take care of. When write() returns successfully, the kernel has now taken care of the data - this is true regardless of whether the file descriptor is blocking or non-blocking. Whether or not the kernel has actually finished writing it at this point is a separate matter (usually, the answer is "no" - most file descriptors are asynchronous).
A write() cannot complete if the kernel has no more room to buffer the data you want to write, and this is the case that is affected by non-blocking versus blocking - in the blocking case, the write() will block until space is available. In the non-blocking case, write() will return an error (EAGAIN), and it is up to you to retry it later.
If you wish to wait until all data written to a terminal device has actually been sent to the hardware, use tcdrain() - but this is likely to be unnecessary. Alternatively, if you wish write() to block until your data is accepted by the kernel, then you can use fcntl() to temporarily set the file descriptor to blocking.
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 1.2
| true
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
checking when all data is sent using non-blocking open
| 3,859,349
| 3
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
If you are writing to a tty (as you are in your example), you can use termios.tcdrain to wait until all written bytes have been transmitted.
Your write systems calls will still be non-blocking, so you will need to handle EWOULDBLOCK/EAGAIN errors, and use select(2), poll(2) or epoll(7) to know when you can write to the file descriptor. These are designed to be used with non-blocking file descriptors.
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 0.099668
| false
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
checking when all data is sent using non-blocking open
| 3,858,262
| 0
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
Open two file descriptors to the same location - one for non-blocking reads and the other for blocking writes.
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 0
| false
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
checking when all data is sent using non-blocking open
| 3,858,291
| 0
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
Have you tried os.fsync(fd)?
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 0
| false
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
checking when all data is sent using non-blocking open
| 3,858,316
| 1
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
The O_NDELAY flag always affects both reading and writing. To achieve a blocking write on a non-blocking file you can select (Python module) the file and write when it becomes writable in a loop.
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 0.033321
| false
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
checking when all data is sent using non-blocking open
| 3,858,252
| 0
| 0
| 809
| 0
|
python,c,linux,io,blocking
|
OS API write() returns count of written bytes. Checking this value against size of your input you can see when all input is sent.
| 0
| 1
| 0
| 0
|
2010-10-04T18:56:00.000
| 6
| 0
| false
| 3,858,238
| 0
| 0
| 0
| 6
|
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
|
send commands to a backgrounded jobs stdin
| 3,862,362
| 0
| 0
| 157
| 0
|
php,python
|
You could connect its stdin to a FIFO and then have another daemon also connect to the FIFO and send commands. It might be better to have the control daemon start the Java daemon though, so that the Java daemon doesn't shut down if the control daemon does for some reason.
| 0
| 1
| 0
| 0
|
2010-10-05T09:20:00.000
| 3
| 0
| false
| 3,862,332
| 0
| 0
| 1
| 1
|
I have a java server application that, when its running, you can interact with it sending commands via stdin. I want to write a web interface that can send these commands to it.
In order to do that I need some way of getting commands from php to the stdin for this backgrounded job. Is there a way to do this from console? or possibly write some kind of wrapper that controls the server job and can access its stdin ? could this be done in python?
|
Agnostic automated deployment
| 3,864,388
| 1
| 3
| 520
| 0
|
java,python,ruby,deployment
|
We use Ant or Maven for different projects we have in house (depending on the need and how old the project is too...). We tend to use Jenkins (formerly known as Hudson) as our build and deployment tool.
And then we encourage developers to write code that does not hard code to DB's, URL's, etc. We try to abstract via the container (ie, Data Sources, pure JMS API's, etc) when running within an app server. And we tend to abstract environment specifics via properties files that we look up at runtime. The path to the properties file is to be defined as a variable on the server. This way we can be flexible enough to build code once and move it through to all our environments.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.024995
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,349
| 1
| 3
| 520
| 0
|
java,python,ruby,deployment
|
you can use maven, ant, ivy along with hudson for java projects.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.024995
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,310
| 1
| 3
| 520
| 0
|
java,python,ruby,deployment
|
I think the best choice you could do is using maven. Even if maven is mostly used for Java projects, you can with the right plugins (or the one you write) deploy anything anywhere.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.024995
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,298
| 1
| 3
| 520
| 0
|
java,python,ruby,deployment
|
For Python you could use Fabric or Paver
For Ruby, there's capistrano and 'vlad the deployer'
For Java, it's the Ant.
For PHP/Python projects I also use Peritor Webistrano, a neat frontend for capistrano. It involves changing a few of the default recipes to remove the rails-specific stuff, but it's worth it once you get it setup correctly.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.024995
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,289
| 3
| 3
| 520
| 0
|
java,python,ruby,deployment
|
I use Puppet for some of the deployements / initial configuration of server. Maven and Ant for Java based projects.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 1.2
| true
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 6,336,041
| 2
| 3
| 520
| 0
|
java,python,ruby,deployment
|
Go for KWateeSDCM. It comes with a straightforward web GUI and does not require obscure scripting and integrates nicely with your build chain via a REST API.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.049958
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,283
| 1
| 3
| 520
| 0
|
java,python,ruby,deployment
|
We use Maven and pull out to the ant-plugin when required. In turn the ant-plugin very occasionally calls out to some native scripting language/application/packager/whatever but we're finding that over time we can generally find a Maven or ANT plugin/task to do the trick.
You might want to look up Continuous Deployment, it's a pretty hot topic in the build and CI space right now.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.024995
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
Agnostic automated deployment
| 3,864,269
| 2
| 3
| 520
| 0
|
java,python,ruby,deployment
|
You could use Ant, Makefile, or a batch script. Or a combination of them.
| 0
| 1
| 0
| 0
|
2010-10-05T13:47:00.000
| 8
| 0.049958
| false
| 3,864,223
| 0
| 0
| 1
| 8
|
What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)?
Here we use Python, Java and Ruby, and may use other languages as well in the future.
Update: I ended up using Puppet to manage all server setup, configs AND deploy. To trigger the deploy of newer versions I ended up using Python Fabric scripts.
|
how to make a Command Line Interface from a given data model used for GUI
| 3,867,843
| 1
| 0
| 440
| 0
|
python,user-interface,wxpython,wxwidgets,command-line-interface
|
If you can call your data model's methods from your GUI and they don't depend on anything in the GUI, then yes, you should be able to call those same methods from another GUI, be it CLI, pyGTK or whatever.
| 0
| 1
| 0
| 0
|
2010-10-05T20:34:00.000
| 2
| 0.099668
| false
| 3,867,500
| 0
| 0
| 0
| 1
|
HI, guys. I am developing a GUI to configure and call several external programs with Python and I use wxPython for the GUI toolkits. Basically, instead of typing commands and parameters in each shell for each application (one application via one shell), the GUI is visualizing these parameters and call them as subprocesses. I have built the data model and the relevant view/gui controls (mainly by using the observer pattern or try to separate model with the gui widgets), and it is OK.
Now there is a request from my colleagues and many other people (even including myself), is it possible to have a command line interface for the subprocesses, or even for the whole configuration GUI, based on the data model I already have? This is due to the fact that many people prefer CLI, CLI is better in reliability, and also needs of programmer debugging and interfacing.
As I am rather new to developing a CLI, I really need some help from you. I appreciate any advice and information from you.
to be more specific,
If I completely forget about the data model built for GUI, start from scratch. Is there some good materials or samples to have a reference?
If I still want to utilize the data model built for GUI, is it possible? If possible, what shall I do and any samples to follow? Do I need to refactor the data model?
Is it possible to have the CLI and GUI at the same time? I mean, can I take the CLI as another view of the data model? Or there is other right approach?
Thank you very much for your help!!
|
Developing with Django+Celery without running `celeryd`?
| 58,684,713
| 0
| 29
| 9,748
| 0
|
python,django,celery
|
After 5+ years of writing Celery tasks I have noticed a pattern I have developed that can help with testing and ease of development - I realised it is much better if my Celery tasks are thin wrappers around the regular Python functions that I typically put in myproject.impl package. Celery tasks may contain some strictly Celery related logic, like using distributed locking for an example, explicit retry logic, etc.
| 0
| 1
| 0
| 0
|
2010-10-06T15:54:00.000
| 4
| 0
| false
| 3,874,422
| 0
| 0
| 1
| 1
|
In development, it's a bit of a hassle to run the celeryd as well as the Django development server. Is it possible to, for example, ask celery to run tasks synchronously during development? Or something similar?
|
Set python virtualenv in vim
| 3,881,570
| 18
| 18
| 20,646
| 0
|
python,vim,virtualenv,macvim
|
Activate your virtualenv before starting vim. You will automatically get the corresponding interpreter instance.
| 0
| 1
| 0
| 0
|
2010-10-07T12:19:00.000
| 6
| 1
| false
| 3,881,534
| 1
| 0
| 0
| 1
|
I use vim for coding and for python coding in particular. Often I want to execute the current buffer with python interpreter. (for example to run unittests), usually I do this with :!python % <Enter>
This scenatio will work works fine with global python, but I want to run virtualenv python instead. How do I enable virtualenv within vim? Is it possible to switch virtualenv on the runtime?
I'm using macvim
|
How can I open a Python shell at a network path in Windows?
| 3,884,931
| 0
| 2
| 2,258
| 0
|
python,windows-xp
|
You need to map it as a drive.
| 0
| 1
| 0
| 0
|
2010-10-07T18:53:00.000
| 3
| 0
| false
| 3,884,881
| 1
| 0
| 0
| 1
|
How can I open a Python interpreter at a specific network path in Windows?
In the Explorer address bar the path is in UNC form: \\myhost\myshare\....
I can't work out how to change to this directory from the Windows command line, nor in what format I could pass it as an argument to os.chdir.
I'm running Python 2.5 on Windows XP. IDLE is installed.
Thanks!
|
Determine IP address of CONNECTED interface (linux) in python
| 3,885,255
| 0
| 1
| 2,443
| 0
|
python,linux,networking,ip-address
|
If the default gateway for the system is reliable, then grab that from the output from route -n the line that contains " UG " (note the spaces) will also contain the IP of the gateway and interface name of the active interface.
| 0
| 1
| 1
| 0
|
2010-10-07T19:24:00.000
| 2
| 0
| false
| 3,885,160
| 0
| 0
| 0
| 1
|
On my linux machine, 1 of 3 network interfaces may be actually connected to the internet. I need to get the IP address of the currently connected interface, keeping in mind that my other 2 interfaces may be assigned IP addresses, just not be connected.
I can just ping a website through each of my interfaces to determine which one has connectivity, but I'd like to get this faster than waiting for a ping time out. And I'd like to not have to rely on an external website being up.
Update:
All my interfaces may have ip addresses and gateways. This is for an embedded device. So we allow the user to choose between say eth0 and eth1. But if there's no connection on the interface that the user tells us to use, we fall back to say eth2 which (in theory) will always work.
So what I need to do is first check if the user's selection is connected and if so return that IP. Otherwise I need to get the ip of eth2. I can get the IPs of the interfaces just fine, it's just determining which one is actually connected.
|
unbuffered urllib2.urlopen
| 3,888,827
| 0
| 1
| 1,600
| 0
|
python,urllib2,urllib,buffering,urlopen
|
A quick hack that has occurred to me is to use urllib.urlopen() with threading.Timer() to emulate timeout. But that's only quick and dirty hack.
| 0
| 1
| 1
| 0
|
2010-10-08T08:20:00.000
| 2
| 1.2
| true
| 3,888,812
| 0
| 0
| 0
| 1
|
I have client for web interface to long running process. I'd like to have output from that process to be displayed as it comes. Works great with urllib.urlopen(), but it doesn't have timeout parameter. On the other hand with urllib2.urlopen() the output is buffered. Is there a easy way to disable that buffer?
|
Simple interpreter to embed and extend inside an C++ Windows application
| 3,897,041
| 1
| 3
| 739
| 0
|
c++,python,scripting,lua
|
Guile is easy to embed and extend, and scheme if powerfull programming language.
You can compile libguile and add it to the repository in lib directory or add source for guile and compile it when user compile the project.
But I don't try to use guile on Windows.
| 1
| 1
| 0
| 0
|
2010-10-09T16:04:00.000
| 4
| 0.049958
| false
| 3,896,313
| 0
| 0
| 0
| 3
|
I need a simple interpreter which will do execution (evaluation) of simple expressions/statements and also call functions from main C++ applications. At the moment I do not need scripting of the application, but it may be useful later.
It should also be strait-forward for other team members to pull my application from Source Repository and to build it, without having to install additional application, libraries, etc.
Searching reveled options like: Python (via Boost and / or Python API), Lua, Guile, TinyScheme.
I am the closest to Python, but using Boost, building Python library, complicated task of interfacing main application with Python makes this choice an overkill, maybe I am wrong.
There should be a simple solution for this request, what are your experiences and suggestions?
|
Simple interpreter to embed and extend inside an C++ Windows application
| 3,897,270
| 4
| 3
| 739
| 0
|
c++,python,scripting,lua
|
Two great options you've already listed are Python and Lua. Here are some of the tradeoffs for your consideration:
Python
A much more complete and powerful language (IMHO!) with libraries for anything and tons of support and communities everywhere you look.
Syntax is not entirely C-like
Although Python wasn't designed specifically for embedding (it's much more often used as a standalone language extended by code in C/C++), it's tot really hard to embed. The official docs contain some examples, and following Boost's examples shouldn't be much harder.
Lua
Designed from bottom up for embedding, so it should be the simplest one to embed.
Syntax more C-like than Python's
If you foresee a definite future need for scripting, building in a scripting engine early is a good idea as it may open some interesting possibilities for you as you go on developing the program. Both options listed above are good ones, you should have no problems embedding any of them without much effort.
| 1
| 1
| 0
| 0
|
2010-10-09T16:04:00.000
| 4
| 1.2
| true
| 3,896,313
| 0
| 0
| 0
| 3
|
I need a simple interpreter which will do execution (evaluation) of simple expressions/statements and also call functions from main C++ applications. At the moment I do not need scripting of the application, but it may be useful later.
It should also be strait-forward for other team members to pull my application from Source Repository and to build it, without having to install additional application, libraries, etc.
Searching reveled options like: Python (via Boost and / or Python API), Lua, Guile, TinyScheme.
I am the closest to Python, but using Boost, building Python library, complicated task of interfacing main application with Python makes this choice an overkill, maybe I am wrong.
There should be a simple solution for this request, what are your experiences and suggestions?
|
Simple interpreter to embed and extend inside an C++ Windows application
| 3,898,118
| 2
| 3
| 739
| 0
|
c++,python,scripting,lua
|
No matter which scripting language you choose (and I would probably vote for Python), you might consider using SWIG (www.swig.org) to ease the burden of interfacing to C++. While normally used to build C++ extensions for python (or ruby, lua, guile, any many others), it can be used to aid in embedding too.
You had mentioned boost::python, which is certainly a full featured option, and allows for a somewhat closer Python/C++ integration (especially where virtual functions are involved). However, in my experience, SWIG is a lot easier to integrate, works with scads of scripting languages, and for python, is natively supported by Python's distutils.
| 1
| 1
| 0
| 0
|
2010-10-09T16:04:00.000
| 4
| 0.099668
| false
| 3,896,313
| 0
| 0
| 0
| 3
|
I need a simple interpreter which will do execution (evaluation) of simple expressions/statements and also call functions from main C++ applications. At the moment I do not need scripting of the application, but it may be useful later.
It should also be strait-forward for other team members to pull my application from Source Repository and to build it, without having to install additional application, libraries, etc.
Searching reveled options like: Python (via Boost and / or Python API), Lua, Guile, TinyScheme.
I am the closest to Python, but using Boost, building Python library, complicated task of interfacing main application with Python makes this choice an overkill, maybe I am wrong.
There should be a simple solution for this request, what are your experiences and suggestions?
|
GUI development package
| 3,897,118
| 3
| 0
| 238
| 0
|
python,linux,user-interface
|
There are numerous decent GUI toolkits, the most popular being PyQt, PyGTK, wxPython and Tkinter. Personally, I prefer Qt, but that's really subjective.
| 0
| 1
| 0
| 0
|
2010-10-09T17:20:00.000
| 2
| 1.2
| true
| 3,897,101
| 1
| 0
| 0
| 2
|
I am new to GUI development. What is the best GUI development package for python on linux (ubuntu being more specific)?
|
GUI development package
| 3,897,128
| 1
| 0
| 238
| 0
|
python,linux,user-interface
|
This is much more a matter of personal taste.
I use GTK+ with Glade.
| 0
| 1
| 0
| 0
|
2010-10-09T17:20:00.000
| 2
| 0.099668
| false
| 3,897,101
| 1
| 0
| 0
| 2
|
I am new to GUI development. What is the best GUI development package for python on linux (ubuntu being more specific)?
|
URL rewriting question
| 3,898,807
| 0
| 0
| 762
| 0
|
python,apache
|
You'd need to show your apache configuration to say for certain, but it seems that Apache isn't actually using mod_cgi to serve the index.cgi script. In your configuration there should be something like 'LoadModule mod_cgi'. It should be uncommented (i.e., it shouldn't have a '#' at the beginning of the line).
If you want to test this, then write a 'Hello World' cgi script and put it (temporarily) in place of index.cgi and see if you can get that to run. Let us know the results.
| 0
| 1
| 0
| 1
|
2010-10-09T17:31:00.000
| 2
| 0
| false
| 3,897,140
| 0
| 0
| 1
| 2
|
I have a CGI script (pwyky) that I called index.cgi, put in directory wiki/, and setup Apache to call localhost/wiki/index.cgi when I access localhost/wiki.
I'm getting errors when I'm trying to use this application -- it creates a page with links like "http://localhost/wiki/@edit/index", but when I click that link, Apace is trying to serve "wiki/@edit/index" as a file. I suspect that I need to get Apache to pass /@edit/index into index.cgi.
In particular, looking through index.cgi, its looking for strings like "@edit" in REQUEST_URI environment variable.
Any idea how to fix this?
|
URL rewriting question
| 3,908,016
| 0
| 0
| 762
| 0
|
python,apache
|
I found the problem, it turned out this is done through RewriteEngine. Pwyky puts .htaccess file in the directory with all the settings for RewriteEngine, but because AllowOverride is "None" by default on MacOS, they were ignored. The solution was to change all "AllowOverride" directives to "All"
| 0
| 1
| 0
| 1
|
2010-10-09T17:31:00.000
| 2
| 1.2
| true
| 3,897,140
| 0
| 0
| 1
| 2
|
I have a CGI script (pwyky) that I called index.cgi, put in directory wiki/, and setup Apache to call localhost/wiki/index.cgi when I access localhost/wiki.
I'm getting errors when I'm trying to use this application -- it creates a page with links like "http://localhost/wiki/@edit/index", but when I click that link, Apace is trying to serve "wiki/@edit/index" as a file. I suspect that I need to get Apache to pass /@edit/index into index.cgi.
In particular, looking through index.cgi, its looking for strings like "@edit" in REQUEST_URI environment variable.
Any idea how to fix this?
|
Twisted factory protocol instance based callback
| 3,906,174
| 1
| 0
| 499
| 0
|
python,twisted,factory
|
No. Write a class that does the interaction with one user. In connectionMade you check if a instance of this class already exists, if not you make a new one and store it on the factory, ie in a { addr : handler } dict. If the connection exists alreay you get the old handler from the factory.
| 0
| 1
| 0
| 0
|
2010-10-11T11:33:00.000
| 1
| 0.197375
| false
| 3,905,791
| 0
| 0
| 1
| 1
|
Hey, I got a ReconnectingClientFactory and I wonder if I can somehow define protocol-instance-based connectionMade/connectionLost callbacks so that i can use the factory to connect to different hosts ans distinguish between each connection.
Thanks in advance.
|
Possible to do ordered dictionary in python 2.5 (due to GAE)?
| 3,911,537
| 0
| 1
| 673
| 0
|
python,google-app-engine,dictionary,python-2.5
|
you can sort a dict.items() list (of tuples) .. can't?
| 0
| 1
| 0
| 0
|
2010-10-12T03:31:00.000
| 3
| 0
| false
| 3,911,494
| 1
| 0
| 0
| 2
|
I'm new to Python, and using Google App Engine, which is currently running only Python 2.5. Are there any built-in ways of doing an ordered dictionary, or do I have to implement something custom?
|
Possible to do ordered dictionary in python 2.5 (due to GAE)?
| 3,912,743
| 0
| 1
| 673
| 0
|
python,google-app-engine,dictionary,python-2.5
|
OrderedDict is new in 2.7, so no, there's no built-in way to do this - you'll have to implement your own.
Usually, an ordered dictionary is implemented as a dictionary of linked list nodes, linked in traversal order. This should be fairly straightforward to implement yourself.
| 0
| 1
| 0
| 0
|
2010-10-12T03:31:00.000
| 3
| 0
| false
| 3,911,494
| 1
| 0
| 0
| 2
|
I'm new to Python, and using Google App Engine, which is currently running only Python 2.5. Are there any built-in ways of doing an ordered dictionary, or do I have to implement something custom?
|
How to interchange data between two python applications?
| 3,922,943
| 2
| 12
| 6,055
| 0
|
python,process,pyqt4,pid
|
While it's not related to the way of the communication, I recommend checking out the pickle/cPickle module (which can encode objects into string streams and vice versa). Very useful.
| 0
| 1
| 0
| 0
|
2010-10-13T09:02:00.000
| 3
| 0.132549
| false
| 3,922,135
| 0
| 0
| 0
| 2
|
I have two python applications. I need to send commands and data between them (between two processes).
What is the best way to do that?
One program is a daemon who should accept commands and parameters from another GUI application.
How can I make daemon to monitor comands from GUI, while making it's job?
I prefer solution would be crossplatform.
p.s. I use pyqt4 and python.
|
How to interchange data between two python applications?
| 3,922,174
| 10
| 12
| 6,055
| 0
|
python,process,pyqt4,pid
|
You can use the following methods for data interchange:
Socket Programming : In Qt you can access QtNetwork module. See qt assistant for examples
IPC : Use shared Memory implemented in QSharedMemory class.
If this application will run on unix os only, then you can try Posix based message queue etc. for data interchange
DBUS : You will find both python and Qt have DBus based support. In Case of python you need to find the relevant module.
Using Multi Processing module
Using Posix/SystemV based IPC mechanism aka pipes, queue, etc.
| 0
| 1
| 0
| 0
|
2010-10-13T09:02:00.000
| 3
| 1.2
| true
| 3,922,135
| 0
| 0
| 0
| 2
|
I have two python applications. I need to send commands and data between them (between two processes).
What is the best way to do that?
One program is a daemon who should accept commands and parameters from another GUI application.
How can I make daemon to monitor comands from GUI, while making it's job?
I prefer solution would be crossplatform.
p.s. I use pyqt4 and python.
|
Read static content from within the code of an application
| 3,926,731
| 1
| 1
| 97
| 0
|
python,google-app-engine
|
You can just open them (only read only).
| 0
| 1
| 0
| 0
|
2010-10-13T18:19:00.000
| 2
| 0.099668
| false
| 3,926,712
| 0
| 0
| 0
| 2
|
Is there a way to read the contents of a static data directory or interact with that data in any way from within the code of an application?
Edit: Please excuse me if it wasn't clear at first, I mean getting a list of the files in that directory, not reading the data in them.
|
Read static content from within the code of an application
| 3,927,648
| 3
| 1
| 97
| 0
|
python,google-app-engine
|
No. Files marked as static in app.yaml are not available to your application; they're served from separate servers.
If you just need to list them, you could build a list as part of your deploy process. If you need to actually read them, you'll need to include a second copy in your application directory (although the "copy" can be just a symlink; appcfg.py will follow symlinks and upload them.)
| 0
| 1
| 0
| 0
|
2010-10-13T18:19:00.000
| 2
| 1.2
| true
| 3,926,712
| 0
| 0
| 0
| 2
|
Is there a way to read the contents of a static data directory or interact with that data in any way from within the code of an application?
Edit: Please excuse me if it wasn't clear at first, I mean getting a list of the files in that directory, not reading the data in them.
|
python - multi line stdout refresh issue
| 3,939,511
| 1
| 2
| 1,629
| 0
|
python
|
It doesn't really answer your question, but there isn't really anything wrong with calling os.system to clear out the terminal (other than the system running on different operating systems) in which case you could use:
os.system('cls' if os.name=='nt' else 'clear')
| 0
| 1
| 0
| 0
|
2010-10-15T04:22:00.000
| 3
| 1.2
| true
| 3,939,482
| 0
| 0
| 0
| 1
|
I have a stats app written in python that on a timer refreshes the ssh screen with stats. Right now it uses os.system('clear') to clear the screen and then outputs a multi line data with the stats.
I'd like to do just do a \r instead of executing the clear but that only works with one line, is it possible to do this with multiple lines?
A classic example of what I want to do is when you execute the "top" command which lists the current processes it updates the screen without executing the "clear" and it's got many lines.
Anyone have any tips for this?
|
Python script to loop through all files in directory, delete any that are less than 200 kB in size
| 3,947,329
| -2
| 31
| 52,290
| 0
|
python
|
Generally ls -la is in bytes.
If you want it in "human readable" form, use the command ls -alh.
| 0
| 1
| 0
| 0
|
2010-10-16T01:46:00.000
| 4
| -0.099668
| false
| 3,947,313
| 0
| 0
| 0
| 1
|
I want to delete all files in a folder that are less than 200 kB in size.
Just want to be sure here, when i do a ls -la on my macbook, the file size says 171 or 143, I am assuming this is kb correct?
|
Google App Engine development server is slow to start up when using WingIDE
| 3,957,947
| 2
| 1
| 713
| 0
|
python,google-app-engine,performance,wing-ide
|
Probably because you've got a debugger hooked up - debuggers slow code down a lot by instrumenting everything, and deserializing your datastore is a lot of work.
Using the --use_sqlite flag will enable an experimental sqlite-based local datastore, which should require less startup time. Note that it'll require you to wipe your datastore when you switch to it, however.
| 0
| 1
| 0
| 0
|
2010-10-16T02:36:00.000
| 2
| 1.2
| true
| 3,947,443
| 0
| 0
| 1
| 1
|
I'm developing on Google App Engine. I am using WingIDE (a python IDE) to debug on the development server. I have several thousand entities in my datastore and I can see that when the development server starts up, it has to go through DatastoreFileStub.Read() and do something which each entity.
The problem is, when I run the development server through WingIDE it runs horrendously slow. I put some profiling logging code into the google app engine to take a peak.
When I run the development server on the command line, I get the following message:
Finished reading 10374 Entites in 10.17 seconds, 1019 per second
When I run the development server through WingIDE however, I get this:
Finished reading 10374 Entites in 52.44 seconds, 197 per second
Anyone have an idea why WingIDE would be 5 times slower?
|
What threading module should I use to prevent disk IO from blocking network IO?
| 3,950,630
| 7
| 6
| 1,332
| 0
|
python,multithreading,io,blocking,nonblocking
|
Since you're I/O bound, then use the threading module.
You should almost never need to use thread, it's a low-level interface; the threading module is a high-level interface wrapper for thread.
The multiprocessing module is different from the threading module, multiprocessing uses multiple subprocesses to execute a task; multiprocessing just happens to use the same interface as threading to reduce learning curve. multiprocessing is typically used when you have CPU bound calculation, and need to avoid the GIL (Global Interpreter Lock) in a multicore CPU.
A somewhat more esoteric alternative to multi-threading is asynchronous I/O using asyncore module. Another options includes Stackless Python and Twisted.
| 0
| 1
| 1
| 0
|
2010-10-16T20:20:00.000
| 1
| 1.2
| true
| 3,950,607
| 0
| 0
| 0
| 1
|
I have a Python application that, to be brief, receives data from a remote server, processes it, responds to the server, and occasionally saves the processed data to disk. The problem I've encountered is that there is a lot of data to write, and the save process can take upwards of half a minute. This is apparently a blocking operation, so the network IO is stalled during this time. I'd like to be able to make the save operation take place in the background, so-to-speak, so that the application can continue to communicate with the server reasonably quickly.
I know that I probably need some kind of threading module to accomplish this, but I can't tell what the differences are between thread, threading, multiprocessing, and the various other options. Does anybody know what I'm looking for?
|
How to change email account details in appcfg.py google appengine SDK
| 4,927,348
| 0
| 9
| 6,689
| 0
|
python,google-app-engine
|
Answer of Adam Bernier also can apply when you use the
appcfg.py download_app for downloading app from appengine servers.
| 0
| 1
| 0
| 0
|
2010-10-16T22:29:00.000
| 5
| 0
| false
| 3,951,089
| 0
| 0
| 1
| 1
|
I have hosted GAE apps with two different email ids! When i first time used appcfg.py to update my app then it prompted me for email id and password but later it doesnot. How to i change the saved email id and password? I tried to use --email= flag with appcfg.py, but it dint worked.
|
Reading files in GAE using python
| 3,957,752
| 2
| 2
| 613
| 0
|
python,django,google-app-engine
|
os.path.normpath() on "content_includes" is a no-op - normpath just removes double slashes and other denormalizations. What you probably want is to build a path relative to the script, in which case you should do something like os.path.join(os.path.dirname(__file__), 'content_includes', pageName + '.inc').
| 0
| 1
| 0
| 0
|
2010-10-17T21:22:00.000
| 2
| 1.2
| true
| 3,955,361
| 0
| 0
| 1
| 2
|
I created a simple python project that serves up a couple of pages. I'm using the 'webapp' framework and django. What I'm trying to do is use one template file, and load 'content files' that contain the actual page text.
When I try to read the content files using os.open, I get the following error:
pageContent = os.open(pageUrl, 'r').read()
OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc' error
If I let the django templating system to read the same file for me, everything works fine!
So the question is What am I doing wrong that django isn't??? The same 'pageUrl' is used.
The code below will give me the error, while if I comment out the first pageContent assignment, everything works fine.
Code:
pageName = "home";
pageUrl = os.path.join(os.path.normpath('content_includes'), pageName + '.inc')
pageContent = os.open(pageUrl, 'r').read()
pageContent=template.render(pageUrl, template_values, debug=True);
template_values = { 'page': pageContent,
'test': "testing my app"
}
Error:
Traceback (most recent call last):
File "/opt/apis/google_appengine/google/appengine/ext/webapp/__init__.py", line 511, in __call__
handler.get(*groups)
File "/home/odessit/Development/Python/Alpha/main.py", line 19, in get
pageContent = os.open(pageUrl, 'r').read()
File "/opt/apis/google_appengine/google/appengine/tools/dev_appserver.py", line 805, in FakeOpen
raise OSError(errno.EPERM, "Operation not permitted", filename)
OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc'
app.yaml:
handlers:
- url: /javascript
static_dir: javascript
- url: /images
static_dir: images
- url: /portfolio
static_dir: portfolio
- url: /.*
script: main.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.