Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
2,579,840
2010-04-05T17:26:00.000
16
0
1
0
python,getter-setter
2,579,867
8
false
0
0
No, it's unpythonic. The generally accepted way is to use normal data attribute and replace the ones that need more complex get/set logic with properties.
2
87
0
Using get/set seems to be a common practice in Java (for various reasons), but I hardly see Python code that uses this. Why do you use or avoid get/set methods in Python?
Do you use the get/set pattern (in Python)?
1
0
0
98,318
2,579,866
2010-04-05T17:31:00.000
1
0
0
0
python,sql,mysql,django-models
2,579,922
2
false
1
0
The answer is clear too. You will need not a field, but another films_actors table. This table would act as your field, but much more reliable. This is called many-to-many relation.
1
3
0
I'm writing a database of all DVDs I have at home. One of the fields, actors, I would like it to be a set of values from an other table, which is storing actors. So for every film I want to store a list of actors, all of which selected from a list of actors, taken from a different table. Is it possible? How do I do this? It would be a set of foreign keys basically. I'm using a MySQL database for a Django application (python), so any hint in SQL or Python would be much appreciated. I hope the question is clear, many thanks.
Using set with values from a table
0.099668
1
0
85
2,580,497
2010-04-05T19:10:00.000
3
0
0
0
python,sql,database,sqlite,sqlalchemy
2,580,542
7
false
0
0
CSV files are not databases--they have no indices--and any SQL simulation you imposed upon them would amount to little more than searching through the entire thing over and over again.
1
26
0
I have a set of .csv files that I want to process. It would be far easier to process it with SQL queries. I wonder if there is some way to load a .csv file and use SQL language to look into it with a scripting language like python or ruby. Loading it with something similar to ActiveRecord would be awesome. The problem is that I don't want to have to run a database somewhere prior to running my script. I souldn't have additionnal installations needed outside of the scripting language and some modules. My question is which language and what modules should I use for this task. I looked around and can't find anything that suits my need. Is it even possible?
Database on the fly with scripting languages
0.085505
1
0
12,118
2,580,648
2010-04-05T19:35:00.000
3
0
0
0
python,django,unit-testing
2,580,813
1
true
1
0
This is normal unittest behavior, though you would normally set up the test data in the setUp() method instead of __init__ (and destroy it in tearDown() perhaps). If generating your dynamic test data takes to long to perform for each test case method, then I guess the best way to go is to create a singleton test data class. In this case you would have to take care that each test method leaves the test data class in exactly the same state it found it, which is not trivial if you want your test case methods to write something in it; this is the reason why unittest try to re-generate the test environment for every test case method. One improvement might be to have the singleton test data class return a deep-copy of itself every time you request it's instance.
1
2
0
I want to generate some dynamic data and feed these data in to test cases. But I found that Django will initial the test class every time to do the test. So the data will get generated every time django test framework calls the function. Is there anyway to use something like the singleton or static variable to solve the problem? What should be the solution? Thanks!
Unittest in Django. Static variable feeded into the test case
1.2
0
0
399
2,580,955
2010-04-05T20:23:00.000
33
0
0
0
python,django,forms,autocomplete
3,672,334
5
false
1
0
Add the autocomplete="off" to the form tag, so you don't have to change the django.form instance. <form action="." method="post" autocomplete="off"> {{ form }} </form>
1
28
0
Does anyone know how you can turn off autocompletion on a textfield in Django? For example, a form that I generate from my model has an input field for a credit card number. It is bad practice to leave autocompletion on. When making the form by hand, I'd add a autocomplete="off" statement, but how do you do it in Django and still retain the form validation?
Disable autocomplete on textfield in Django?
1
0
0
19,773
2,581,687
2010-04-05T23:00:00.000
1
0
0
0
python,gtk,pygtk,gnome
2,586,546
3
false
0
1
it is not possible with gdk, i'm afraid. try cairo or opengl.
1
1
0
I want to display a gtk.Image with a high level of zoom, but scale the image to a new pixbuf with the gtk.gdk.Pixbuf methods waste a lot of memory and processor. Are there some simply way to display a zoomed image?
Zoomed PyGTK image without scale pixbuf
0.066568
0
0
822
2,581,784
2010-04-05T23:34:00.000
1
0
1
0
python,compilation,cython
50,452,413
4
false
0
1
Aftershock's answer is good, what I want to say is about run app without console. Most like Aftershock's answer, if you want your application run without console, two points are important: Replace all the main() function in the ".c" file made by cython --embed with wmain() Add /subsystem:windows /entry:wmainCRTStartup to the end of cl.exe ... command
1
53
0
I know what Cythons purpose is. It's to write compilable C extensions in a Python-like language in order to produce speedups in your code. What I would like to know (and can't seem to find using my google-fu) is if Cython can somehow compile into an executable format since it already seems to break python code down into C. I already use Py2Exe, which is just a packager, but am interested in using this to compile down to something that is a little harder to unpack (Anything packed using Py2EXE can basically just be extracted using 7zip which I do not want) It seems if this is not possible my next alternative would just be to compile all my code and load it as a module and then package that using py2exe at least getting most of my code into compiled form, right?
Can Cython compile to an EXE?
0.049958
0
0
37,475
2,582,627
2010-04-06T04:21:00.000
0
0
0
0
python,django,facebook,pyfacebook
2,582,677
3
false
1
0
Probably. Anything that bypassed authentication would be a fairly large privacy issue.
1
0
0
I just want to import my facebook status and photos to my personal django website but all the examples and documentation i can find are for developing facebook applications. A simple rss feed would be enough but it doesnt seem to exist in facebook. Do i really have to create a full facebook app to do this?
What's the easiest way to get my facebook status and photos using python?
0
0
0
2,103
2,582,892
2010-04-06T05:47:00.000
0
0
0
1
c++,python,search,full-text-search
2,583,480
3
true
0
0
Python is unlikely to allow you to write the most efficient server possible. However, it may just be that it will be fast enough, because for most applications it is. Therefore, one path you could take is starting with Python. It's a great language for prototyping, much better than C++ for the stage in which you're not even sure which architecture to adopt. As you finish the project, you can see if Python is efficient enough. If it isn't and there's no easy way to make it much faster (such as rewriting a small routine that takes up most of the work in C), you can rewrite it in C++ using the Python prototype as a basis.
1
1
0
I am planning to build an inverted index searching system with cassandra as its storage backend. But I need some guidances to build a highly efficient searching daemon server. I know a web server written in Python called tornado, my questions are: Is Python a good choice for developing such kind of apps? Is Nginx(or Sphinx) a good example that I can look inside to learn its architecture to implement a highly efficient server? Anything else I should learn to do this? Thank you~
Implement a server that receives and processes client request(cassandra as backend), Python or C++?
1.2
0
0
140
2,583,646
2010-04-06T08:58:00.000
0
0
0
0
python,wxpython
2,583,745
1
true
0
1
No wx.DC just draw to a device and those are all plain pixels, wx.DC doesn't track mouse events or any other events. If you want such behavior you will have to track mouse movement on your drawing area and on click check which area it may have clicked e.g. if near by the line show a msg etc.
1
0
0
A line created using the DrawLine method of wx.DC has the onClick and onMouseOver events?
Does wx.DC line has events?
1.2
0
0
81
2,584,589
2010-04-06T11:59:00.000
2
0
1
0
python,search,file
2,584,619
5
false
0
0
Use the magic module to get the MIME type, and look for image/jpeg.
1
1
0
My requirement is to search for jpeg images files in a directory using python script and list the file names. Can anyone help me on how to identify jpeg images files. Thanks in advance...
Search jpeg files using python
0.07983
0
0
16,395
2,585,091
2010-04-06T13:24:00.000
4
1
1
0
python,emacs,ssh
2,585,123
8
false
0
0
indent-region mapped to C-M-\ should do the trick.
2
139
0
Working with Python in Emacs if I want to add a try/except to a block of code, I often find that I am having to indent the whole block, line by line. In Emacs, how do you indent the whole block at once. I am not an experienced Emacs user, but just find it is the best tool for working through ssh. I am using Emacs on the command line(Ubuntu), not as a gui, if that makes any difference.
Emacs bulk indent for Python
0.099668
0
0
46,535
2,585,091
2010-04-06T13:24:00.000
10
1
1
0
python,emacs,ssh
2,585,268
8
false
0
0
In addition to indent-region, which is mapped to C-M-\ by default, the rectangle edit commands are very useful for Python. Mark a region as normal, then: C-x r t (string-rectangle): will prompt you for characters you'd like to insert into each line; great for inserting a certain number of spaces C-x r k (kill-rectangle): remove a rectangle region; great for removing indentation You can also C-x r y (yank-rectangle), but that's only rarely useful.
2
139
0
Working with Python in Emacs if I want to add a try/except to a block of code, I often find that I am having to indent the whole block, line by line. In Emacs, how do you indent the whole block at once. I am not an experienced Emacs user, but just find it is the best tool for working through ssh. I am using Emacs on the command line(Ubuntu), not as a gui, if that makes any difference.
Emacs bulk indent for Python
1
0
0
46,535
2,585,803
2010-04-06T14:52:00.000
3
0
0
0
python,getopt
2,585,839
2
true
0
1
You can catch getopt.GetoptError and check the 'opt' and 'msg' attributes yourself: try: opts, args = getopt.getopt(sys.argv[1:], "c:", ... except getopt.GetoptError, e: if e.opt == 'c' and 'requires argument' in e.msg: print >>sys.stderr, 'ERROR: You forgot to give the file name after -c option' sys.exit(-1)
2
2
0
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], "c:", ... for o,v in opts: ... elif o in ("-c", "--%s" % checkString): kCheckOnly = True clientTemp = v If I don't give the parameter after the -c, I get the error messages as follows. Traceback (most recent call last): File "niFpgaTimingViolationMain.py", line 100, in opts, args = getopt.getopt(sys.argv[1:], "hdc:t:",[helpString, debugString, checkString, twxString]) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/getopt.py", line 91, in getopt opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/getopt.py", line 195, in do_shorts opt) getopt.GetoptError: option -c requires argument Is there any way to catch this error, and process it to print something like this? It seems that just wrapping the code in try/except doesn't work. ERROR: You forgot to give the file name after -c option
How to process python generated error messages my own way?
1.2
0
0
752
2,585,803
2010-04-06T14:52:00.000
3
0
0
0
python,getopt
2,585,858
2
false
0
1
the correct answer is to use the OptionParser module instead of trying to "roll your own".
2
2
0
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], "c:", ... for o,v in opts: ... elif o in ("-c", "--%s" % checkString): kCheckOnly = True clientTemp = v If I don't give the parameter after the -c, I get the error messages as follows. Traceback (most recent call last): File "niFpgaTimingViolationMain.py", line 100, in opts, args = getopt.getopt(sys.argv[1:], "hdc:t:",[helpString, debugString, checkString, twxString]) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/getopt.py", line 91, in getopt opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/getopt.py", line 195, in do_shorts opt) getopt.GetoptError: option -c requires argument Is there any way to catch this error, and process it to print something like this? It seems that just wrapping the code in try/except doesn't work. ERROR: You forgot to give the file name after -c option
How to process python generated error messages my own way?
0.291313
0
0
752
2,586,274
2010-04-06T15:58:00.000
2
0
1
1
python,ide,import,libraries,code-completion
2,586,371
6
false
0
0
I've just downloaded the preview of netbeans and it seems to have done quite well so far. It has detected inherited methods & properties. I haven't had to add a single library reference in my project, so this seems to be the most fluid so far.
2
0
0
I'm looking for a Python IDE that can help me easily locate and manage and use the libraries on my system (Ubuntu). Specifically Twisted. Code completion is important including the symbols I import. (I've so far had a look at PyDev as well as OpenKomodo, but while both offer code completion for default Python concepts, I wasn't able to get either to import Twisted into my project and was thus getting reference errors.) Usual disclaimer: I don't like EMACS or vi, please, nothing regarding those.
Looking for a Python IDE with good support for libraries (Twisted)
0.066568
0
0
1,587
2,586,274
2010-04-06T15:58:00.000
2
0
1
1
python,ide,import,libraries,code-completion
2,586,619
6
false
0
0
eclipse + pydev seems to work well for me. Just remember to right-click on the project and select Properties and make sure that your libraries are on the path. Sometimes this doesn't happen for easy_installed libraries.
2
0
0
I'm looking for a Python IDE that can help me easily locate and manage and use the libraries on my system (Ubuntu). Specifically Twisted. Code completion is important including the symbols I import. (I've so far had a look at PyDev as well as OpenKomodo, but while both offer code completion for default Python concepts, I wasn't able to get either to import Twisted into my project and was thus getting reference errors.) Usual disclaimer: I don't like EMACS or vi, please, nothing regarding those.
Looking for a Python IDE with good support for libraries (Twisted)
0.066568
0
0
1,587
2,586,959
2010-04-06T17:34:00.000
0
1
1
0
python,methods,code-analysis
2,586,977
1
false
0
0
For me, this sounds like special case of coverage. Thus I'd take a look at coverage.py or figleaf and modify it to ignore inter-module calls.
1
1
0
I've got a Codebase of around 5,3k LOC with around 30 different classe. The code is already very well formatted and I want to improve it further by prefixing methods that are only called in the module that were defined in with a "_", in order to indicate that. Yes it would have been a good idea to do that from the beginning on but now it's too late :D Basically I'm searching for a tool that will tell me if a method is not called outside of the module it was defined in, I'm not looking for stuff that will automatically convert the whole thing to use underscores, just a "simple" thing that tells me where I have to look for prefixing stuff. I'd took a look at the AST module, but there's no easy way to get a list of method definitions and calls, also parsing the plain text yields just too many false positives. I don't insist in spending day(s) on reinventing the wheel when there might be an already existing solution to my problem.
Python analyze method calls from other classes/modules
0
0
0
194
2,590,328
2010-04-07T06:05:00.000
0
0
1
0
python,matplotlib,histogram
2,590,381
2
false
0
0
You can't directly tell matplotlib to make a histogram from an input file - you'll need to open the file yourself and get the data from it. How you'd do that depends on the format of the file - if it's just a file with a number on each line, you can just go through each line, strip() spaces and newlines, and use float() to convert it to a number.
1
5
1
I wish to make a Histogram in Matplotlib from an input file containing the raw data (.txt). I am facing issues in referring to the input file. I guess it should be a rather small program. Any Matplotlib gurus, any help ? I am not asking for the code, some inputs should put me on the right way !
Histogram in Matplotlib with input file
0
0
0
14,040
2,590,435
2010-04-07T06:29:00.000
0
1
0
0
python,eclipse,pydev,twython
2,594,323
2
false
0
0
Daniel is right. As long as twython went into site-packages then Pydev will find it.
2
2
0
I recently installed twython, a really sleek and awesome twitter API wrapper for Python. I installed it and it works fine from the interpreter, but when I try to import it via Eclipse, it says that twython is an invalid import. How do I "tell" eclipse where twython is so that it will let me import and use it?
Eclipse + PyDev: Eclipse telling me that this is an invalid import?
0
0
1
941
2,590,435
2010-04-07T06:29:00.000
3
1
0
0
python,eclipse,pydev,twython
2,590,469
2
true
0
0
I believe I have had this problem before - try going into the menu: Window_Preferences and then select Pydev and Interpreter-Python. Then try to click Auto-config - it should update its search paths to include everything installed in Python. If that doesn't work, you should at least be able to manually add the folder by clicking "New Folder" in the bottom part of that screen and navigating to the location where you have twython installed.
2
2
0
I recently installed twython, a really sleek and awesome twitter API wrapper for Python. I installed it and it works fine from the interpreter, but when I try to import it via Eclipse, it says that twython is an invalid import. How do I "tell" eclipse where twython is so that it will let me import and use it?
Eclipse + PyDev: Eclipse telling me that this is an invalid import?
1.2
0
1
941
2,592,540
2010-04-07T12:54:00.000
0
0
0
1
python,google-app-engine,url
5,877,046
2
true
1
0
Issue816 has now been fixed, semi-colons are usable with appengine.
1
2
0
Using the local dev server, I can use ';' in urls, but as soon as I try the live version hosted by Google, it looks like the ';' and everything afterward is stripped (at least according to request.path_qs). (I would prefer not to encode them if possible, it's much less user friendly if the url cannot be constructed by copy-pasting, especially since other characters works fine, e.g. ':').
How to use ';' (semicolon) in urls, using Google Appengine
1.2
0
0
336
2,593,519
2010-04-07T15:02:00.000
7
0
1
0
java,.net,python,ruby,perl
2,593,537
4
true
1
0
Do you want to run programs in these languages inside the .NET platform? You'd need IronPython or IronRuby (I don't think anything like IronPerl exists). If you want to run "normal" Python/Ruby/Perl/Java programs, then yes, you'll need to install a Python interpreter, a Ruby interpreter, a Perl interpreter and a Java VM.
3
0
0
I've .NET framework 3.5 installed in my laptop. Just .NET alone, no Visual Studio. How can I run Java, Python, Ruby and Perl programs from the console? Do I need to install something else also, for running these language files? In case there is a need for something extra to be installed and after i have all of them, what are the commands that I need to type in the console to run these programs?
Running Java, Python, Ruby and Perl programs in .NET
1.2
0
0
421
2,593,519
2010-04-07T15:02:00.000
3
0
1
0
java,.net,python,ruby,perl
2,593,551
4
false
1
0
None of those languages are supported natively with .NET. You can try IronPython or IronRuby for those languages, but to run Java or Perl I think you'll actually need to download and install a Java VM and a perl interpreter.
3
0
0
I've .NET framework 3.5 installed in my laptop. Just .NET alone, no Visual Studio. How can I run Java, Python, Ruby and Perl programs from the console? Do I need to install something else also, for running these language files? In case there is a need for something extra to be installed and after i have all of them, what are the commands that I need to type in the console to run these programs?
Running Java, Python, Ruby and Perl programs in .NET
0.148885
0
0
421
2,593,519
2010-04-07T15:02:00.000
1
0
1
0
java,.net,python,ruby,perl
2,593,556
4
false
1
0
There's no practical common virtual machine or binary for the options you list. You will require a separate install for each of these (note that all are unrelated to .NET)
3
0
0
I've .NET framework 3.5 installed in my laptop. Just .NET alone, no Visual Studio. How can I run Java, Python, Ruby and Perl programs from the console? Do I need to install something else also, for running these language files? In case there is a need for something extra to be installed and after i have all of them, what are the commands that I need to type in the console to run these programs?
Running Java, Python, Ruby and Perl programs in .NET
0.049958
0
0
421
2,593,756
2010-04-07T15:31:00.000
2
0
0
1
python,google-app-engine,blobstore
2,594,009
1
false
1
0
In Java, you would instantiate a BlobInfoFactory and use BlobInfoFactory.queryBlobInfos. Then for each blob, you would run BlobstoreService.serve(...) with the BlobKeys returned from the BlobInfos. You still might end up with broken entity relationships - there's no way to guarantee each blob will end up with the same key it was originally loaded with. You'll have to account for this in your application.
1
3
0
bulkloader.py is very handy. But as far as I can tell it doesn't appear to fetch items from the blobstore, so you can be left with broken entity relationships if you needed to dump/restore your application. Does anyone know a method for completely backing up their data from app-engine including blobstore data?
Is there a way to backup everything in an app-engine blobstore?
0.379949
0
0
645
2,594,190
2010-04-07T16:33:00.000
2
0
1
1
python,windows,path,batch-file
2,594,277
4
false
0
0
Looks like you almost had it; just replace the double-slashes with single slashes. If you're ever unsure and need a reminder of the right format. Try using the tab key to automatically complete your folder or filename. For example, at your command prompt just type: C:\docu then hit the tab key and it will automatically complete your folder name. From there you just type in the rest. Whenever you want to automatically complete the rest of the folder or filename, just hit the tab key. This will always produce a properly specified path that is runnable.
1
3
0
The batch file is something like this, I put the python in some directory that has SPACE character in its path. C:\"Documents and Settings"\Administrator\Desktop\bracket\python\python C:\\"Documents and Settings"\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py When I run this one, I get this error. C:\Documents and Settings\Administrator\Desktop\bracket\python\python: can't ope n file 'C:\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\bra ckettest.py': [Errno 2] No such file or directory C:\Documents and Settings\Administrator\Desktop\bracket> What might be wrong? Wrapping the path doesn't solve this problem. "C:\\Documents and Settings\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py" Are the brackets ('[]') cause of the problem? On Mac, python works well with bracket character.
Running python batch file that has a path with SPACE character
0.099668
0
0
12,337
2,597,444
2010-04-08T03:41:00.000
4
0
1
0
python,random
2,597,749
2
false
0
0
No doubt you have a bounded amount of memory, and address space, on your machine; for example, for a good 64-bit machine, 64 GB of RAM [[about 2**36 bytes]] and a couple of TB of disk (usable as swap space for virtual memory) [[about 2**41 bytes]]. So, the "upper bound" of a Python long integer will be the largest one representable in the available memory -- a bit less than 256**(2**40) if you are in absolutely no hurry and can swap like crazy, a bit more than 256**(2*36) (with just a little swapping but not too much) in practical terms. Unfortunately it would take quite a bit of time and space to represent these ridiculously humongous numbers in decimal, so, instead of showing them, let me check back with you -- why would you even care about such a ridiculous succession of digits as to constitute the "upper bound" you're inquiring about? I think it's more practical to put it this way: especially on a 64-bit machine with decent amounts of RAM and disk, upper bounds of long integers are way bigger than anything you'll ever compute. Technically, a mathematician would insist, they're not infinity, of course... but practically, they might as well be!-)
1
9
1
Most of us know that the command random.randint(1,n) in Python (2.X.X) would generate a number in random (pseudo-random) between 1 and n. I am interested in knowing what is the upper limit for n ?
random.randint(1,n) in Python
0.379949
0
0
19,740
2,597,501
2010-04-08T04:03:00.000
0
0
0
1
python,directory
2,597,538
2
false
0
0
you can use os.rmdir() to remove a directory. To remove a directory tree recursively, you can use shutil.rmtree. If you know that you already have empty directory nodes, you can also check out os.removedirs()
1
0
0
how can i delete a folder using python script?and what are the return values??
deletion of folders
0
0
0
120
2,600,212
2010-04-08T13:32:00.000
0
1
0
0
python,django,logging,crash,lighttpd
2,664,142
3
false
1
0
Have had the same problems. Not only do they die without warning or reason they leak like crazy too with threads being stuck without a master process. We solved this problem by having a cronjob run every 5 minutes that checks if the port number is up and running and if not restart. By the way, we've now (slowly migrating) given up on fcgi and moved over to uwsgi.
2
6
0
I'm running Django on Linux using fcgi and Lighttpd. Every now and again (about once a day) the server just dies. I'm using the latest stable release of Django, Python and Lighttpd. The only thing I can think of is that my program is opening a lot of files and executing a lot of external processes, but I'm fairly sure that side of things is watertight. Looking at the error and access logs, there's nothing exceptional happening (i.e. load isn't above normal). On those occasions where I have had exceptions from Python, these have shown up in the error.log, but when this crash happens I get nothing. Is there any way of finding out why the process died? Short of putting logging statements on every single line? Obviously I can't reproduce this so I don't know exactly where to look. Edit It's the django process that's dying. I'm running the server with manage.py runfcgi daemonize=true method=threaded host=127.0.0.1 port=12345
Why would Django fcgi just die? How can I find out?
0
0
0
916
2,600,212
2010-04-08T13:32:00.000
0
1
0
0
python,django,logging,crash,lighttpd
2,653,742
3
false
1
0
Is this on your server? (do you own the box?). I've had that problem on shared hosting, and the host was just killing long processes. Do you know if your fcgi is receiving a SIGTERM?
2
6
0
I'm running Django on Linux using fcgi and Lighttpd. Every now and again (about once a day) the server just dies. I'm using the latest stable release of Django, Python and Lighttpd. The only thing I can think of is that my program is opening a lot of files and executing a lot of external processes, but I'm fairly sure that side of things is watertight. Looking at the error and access logs, there's nothing exceptional happening (i.e. load isn't above normal). On those occasions where I have had exceptions from Python, these have shown up in the error.log, but when this crash happens I get nothing. Is there any way of finding out why the process died? Short of putting logging statements on every single line? Obviously I can't reproduce this so I don't know exactly where to look. Edit It's the django process that's dying. I'm running the server with manage.py runfcgi daemonize=true method=threaded host=127.0.0.1 port=12345
Why would Django fcgi just die? How can I find out?
0
0
0
916
2,601,269
2010-04-08T15:39:00.000
2
0
1
0
python,coding-style
2,602,117
4
false
0
0
It is usually obvious in python which variables are local and which are global, since to modify a global variable you have to declare it using the the global keyword at the start of a function. However I sometimes add a global declaration even if it is not necessary for python to compile it, in order to emphasize that an object is global - e.g. modifying a mutable global data-structure. Arguments should be obvious because they are in the function declaration. As others have said constants should be in UPPER_CASE_WITH_UNDERSCORES, which is a convention shared by many languages. If you find that you are having trouble keeping track of which are global, local and parameter variables I suggest that the problem may be your functions are too long and doing too much. Functions & methods should be short and do exactly one thing. I start to get the refactoring itch if my functions go over about 10-20 lines of code. I recommend reading the book Clean Code by Robert Martin. The examples are in Java, but the principles apply to all languages.
2
5
0
In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as Global variables start with _ and capital letter arguments end with with _ _Gvariable = 10 def hello(x_, y_): z = x_ + y_ Is this a Pythonian way to go? I mean, is there well established/agreed coding-standards to differentiate them in python? === ADDED === I just want to discriminate between arguments and local variables. As arguments are given from outside, and more like a ROM in the sense that it is not assumed to be read only. C++ provides the const keyword to prevent the arguments from changing, but not for python. I thought appending _ can be one of a way to mimic this feature in python.
Arguments, local variables, and global variables coding convention in Python
0.099668
0
0
7,418
2,601,269
2010-04-08T15:39:00.000
0
0
1
0
python,coding-style
2,601,829
4
false
0
0
That's absolutly awful. There is no reason whatsoever to use a special naming scheme for global and local objects. Also you should avoid having global objects unless they are functions, classes or constants. Names for constants should be uppercase and seperated with underscores LIKE_THIS, class names look LikeThis and functions and method names should look like any other name. Names for objects which are implementation specific, can be changed/removed at any time or can not be relied on for any other good reasons should be prefixed with an underscore. You should also read the Python styleguide PEP 8 which covers these and more style-related rules you should follow as long as it doesn't make your code less readable. Most Python projects follow this or at least a compatible version of this style guide.
2
5
0
In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as Global variables start with _ and capital letter arguments end with with _ _Gvariable = 10 def hello(x_, y_): z = x_ + y_ Is this a Pythonian way to go? I mean, is there well established/agreed coding-standards to differentiate them in python? === ADDED === I just want to discriminate between arguments and local variables. As arguments are given from outside, and more like a ROM in the sense that it is not assumed to be read only. C++ provides the const keyword to prevent the arguments from changing, but not for python. I thought appending _ can be one of a way to mimic this feature in python.
Arguments, local variables, and global variables coding convention in Python
0
0
0
7,418
2,603,951
2010-04-08T22:43:00.000
6
0
0
1
python,linux,performance,guid,uuid
2,603,967
3
false
0
0
Are you certain that the uuid module would in fact be too slow to handle the requests you expect in a timely manner? I would be very surprised if UUID generation accounted for a bottleneck in your application. I would first build the application to simply use the uuid module and then if you find that this module is in fact slowing things down you should investigate a way to keep a pre-generated list of UUIDs around.
1
2
0
I have a python program that needs to generate several guids and hand them back with some other data to a client over the network. It may be hit with a lot of requests in a short time period and I would like the latency to be as low as reasonably possible. Ideally, rather than generating new guids on the fly as the client waits for a response, I would rather be bulk-generating a list of guids in the background that is continually replenished so that I always have pre-generated ones ready to hand out. I am using the uuid module in python on linux. I understand that this is using the uuidd daemon to get uuids. Does uuidd already take care of pre-genreating uuids so that it always has some ready? From the documentation it appears that it does not. Is there some setting in python or with uuidd to get it to do this automatically? Is there a more elegant approach then manually creating a background thread in my program that maintains a list of uuids?
Pre-generating GUIDs for use in python?
1
0
0
1,247
2,604,600
2010-04-09T01:45:00.000
5
1
1
1
python,egg
2,604,612
2
false
0
0
I can't explain why some eggs are zipped (the files) and some are directories, but I can offer this: if you hate zipped eggs (like I do) put this in the [easy_install] section of your ~/.pydistutils.cfg: zip_ok = false
1
19
0
Looking in my /usr/local/lib/python.../dist-package directory, I have .egg directories and .egg files. Why does the installer choose to extra packages to the .egg directory, yet leave other files with .egg extensions?
Why does easy_install extract some python eggs and not others?
0.462117
0
0
8,363
2,604,740
2010-04-09T02:24:00.000
1
0
0
1
python,sockets,tcp,portforwarding
2,609,442
3
false
0
0
Perhaps the application you're proxying is poorly written. For instance, if I call recv(fd, buf, 4096, 0); I'm not promised 4096 bytes. The system makes a best-effort to provide it. If 1k isn't a multiple of your application's recv or send sizes, and the application is broken, then grouping the data sent into 1k blocks will break the app.
2
4
0
I'm trying to write some Python code that will establish an invisible relay between two TCP sockets. My current technique is to set up two threads, each one reading and subsequently writing 1kb of data at a time in a particular direction (i.e. 1 thread for A to B, 1 thread for B to A). This works for some applications and protocols, but it isn't foolproof - sometimes particular applications will behave differently when running through this Python-based relay. Some even crash. I think that this is because when I finish performing a read on socket A, the program running there considers its data to have already arrived at B, when in fact I - the devious man in the middle - have yet to send it to B. In a situation where B isn't ready to receive the data (whereby send() blocks for a while), we are now in a state where A believes it has successfully sent data to B, yet I am still holding the data, waiting for the send() call to execute. I think this is the cause of the difference in behaviour that I've found in some applications, while using my current relaying code. Have I missed something, or does that sound correct? If so, my real question is: is there a way around this problem? Is it possible to only read from socket A when we know that B is ready to receive data? Or is there another technique that I can use to establish a truly 'invisible' two-way relay between [already open & established] TCP sockets?
How to correctly relay TCP traffic between sockets?
0.066568
0
1
3,528
2,604,740
2010-04-09T02:24:00.000
1
0
0
1
python,sockets,tcp,portforwarding
2,604,794
3
false
0
0
I don't think that's likely to be your problem. In general, the sending application can't tell when the receiving application actually calls recv() to read the data: the sender's send() may have completed, but the TCP implementations in the source & destination OS will be doing buffering, flow control, retransmission, etc. Even without your relay in the middle, the only way for A to "consider its data to have already arrived at B" is to receive a response from B saying "yep, I got it".
2
4
0
I'm trying to write some Python code that will establish an invisible relay between two TCP sockets. My current technique is to set up two threads, each one reading and subsequently writing 1kb of data at a time in a particular direction (i.e. 1 thread for A to B, 1 thread for B to A). This works for some applications and protocols, but it isn't foolproof - sometimes particular applications will behave differently when running through this Python-based relay. Some even crash. I think that this is because when I finish performing a read on socket A, the program running there considers its data to have already arrived at B, when in fact I - the devious man in the middle - have yet to send it to B. In a situation where B isn't ready to receive the data (whereby send() blocks for a while), we are now in a state where A believes it has successfully sent data to B, yet I am still holding the data, waiting for the send() call to execute. I think this is the cause of the difference in behaviour that I've found in some applications, while using my current relaying code. Have I missed something, or does that sound correct? If so, my real question is: is there a way around this problem? Is it possible to only read from socket A when we know that B is ready to receive data? Or is there another technique that I can use to establish a truly 'invisible' two-way relay between [already open & established] TCP sockets?
How to correctly relay TCP traffic between sockets?
0.066568
0
1
3,528
2,604,841
2010-04-09T02:53:00.000
5
0
1
0
python,unix
5,645,465
5
false
0
0
On Ubuntu/Debian, you can install it with apt-get install python-simplejson
1
45
0
I'm trying to run a command to install bespinclient on my Windows laptop but every time I execute the command python bootstrap.py --no-site-packages, I get an error saying: ImportError: No module named simplejson I'm using Mozilla build tools to run these Linux commands.
ImportError: No Module named simplejson
0.197375
0
1
111,229
2,606,018
2010-04-09T08:39:00.000
0
0
0
0
python,networkx,igraph
2,606,124
3
false
0
0
Dijkstra's algorithm will find the shortest path in a manner similar to a breadth first search (it substitutes a priority queue weighted by depth into the graph for the naive queue of a BFS). You could fairly trivially extend it to produce the 'N' shortest paths if you need some number of alternatives, although if you need the paths to be substantially different (e.g. scheduling the routes of security vans) you might need to be more clever about selecting paths that are significantly different from each other.
1
9
0
I'm using networkx to work with graphs. I have pretty large graph (it's near 200 nodes in it) and I try to find all possible paths between two nodes. But, as I understand, networkx can find only shortest path. How can I get not just shortest path, but all possible paths? UPD: path can contain each node only once. UPD2: I need something like find_all_paths() function, described here: python.org/doc/essays/graphs.html But this function doesn't work well with large number of nodes and edged =(
Path between two nodes
0
0
1
14,244
2,606,283
2010-04-09T09:29:00.000
2
0
0
0
jquery,python,django,validation
2,606,444
3
false
1
0
No, no such thing exists. Yes, you need to code it yourself. However, I imagine you could possibly create widgets which are able to deliver generic validation js routines based on the modelFields. Such as "This should be chars not more than max_length". However they could not trivially generate client-side code to validate any custom validation written in python, nor even something like "This must be the username of an existing user". But if you take this trouble to build widgets which do basic validation based on the modelFields please contribute them to open source :-D
1
9
0
I'm using jQuery validation system for client-side validation. The backend works with django. jQuery use an interesting set of rules in JSON format. Does exists something to use the same rules on django side or I need to code it myself?
How to use the validation rules on both client-side and server-side?
0.132549
0
0
926
2,610,000
2010-04-09T18:45:00.000
3
0
0
0
python,django,postgresql,isbn
2,610,094
4
false
1
0
I don't know postgres but normally ISBM would be a unique index key but not the primary. It's better to have an integer as primary/foreign key. That way you only need to add a new field EAN/ISSN as nullable.
2
2
0
I built an inventory database where ISBN numbers are the primary keys for the items. This worked great for a while as the items were books. Now I want to add non-books. some of the non-books have EANs or ISSNs, some do not. It's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published. What is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get. I couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers. should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.
ISBNs are used as primary key, now I want to add non-book things to the DB - should I migrate to EAN?
0.148885
1
0
1,516
2,610,000
2010-04-09T18:45:00.000
1
0
0
0
python,django,postgresql,isbn
2,614,029
4
false
1
0
A simple solution (although arguably whether good) would be to use (isbn,title) or (isbn,author) which should pretty much guarantee uniqueness. Ideology is great but practicality also serves a purpose.
2
2
0
I built an inventory database where ISBN numbers are the primary keys for the items. This worked great for a while as the items were books. Now I want to add non-books. some of the non-books have EANs or ISSNs, some do not. It's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published. What is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get. I couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers. should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.
ISBNs are used as primary key, now I want to add non-book things to the DB - should I migrate to EAN?
0.049958
1
0
1,516
2,610,421
2010-04-09T19:44:00.000
0
1
1
0
python,macos,gcc,distutils,shared-objects
2,611,684
5
false
0
1
You can write python extensions in many ways, including Cython, SWIG, boost.python ... You can also write a shared library and use the "ctypes" library to access it.
1
1
0
Looking at Python modules and at code in the "lib-dnyload" directory in the Python framework, I noticed whenever code is creating some kind of GUI or graphic it imports a non-Python file with a .so extension. And there are tons .so files in "lib-dnyload". From googling things I found that these files are called shared objects and are written in C or C++. I have a Mac and I use GCC. How do I make shared object files that are accessible via Python? Mainly just how to make shared objects with GCC using Mac OS X.
How to create make .so files from code written in C or C++ that are usable from Python
0
0
0
4,363
2,610,494
2010-04-09T19:54:00.000
0
0
0
0
python,wxpython
2,611,676
2
false
0
0
You can either find the right unicode symbol or just use "v"
2
0
0
I want to write a Static Text with an upside down ^ How can I do it?
How to rotate the text of a wx.StaticText?
0
0
0
836
2,610,494
2010-04-09T19:54:00.000
3
0
0
0
python,wxpython
2,612,142
2
true
0
0
There are a couple of approaches. 1) If you actually want to do the rotation, you can do it by drawing the text to a wx.GraphicsContext and then rotation it there, write this to a bitmap, and display that. 2) It might be easier to find the right unicode symbol. Having spent way too much of my time lately looking at unicode symbols, I can suggest 02C7, 032C, 2228, 2304, 1D5B, 1D65. Note, though, that not all of these will be present in all fonts. As far as I know, wx.StaticText doesn't rotate text.
2
0
0
I want to write a Static Text with an upside down ^ How can I do it?
How to rotate the text of a wx.StaticText?
1.2
0
0
836
2,610,727
2010-04-09T20:35:00.000
6
0
0
0
python,django,django-models
2,610,788
3
false
1
0
Django models can only reside in applications, not in project itself. By default manage.py inspectdb outputs content of the models.py file and it's up to you to put it in the right place. In your case it would be easier to put whole thing in one app and later split it in the places where it would make sense. I'm not sure what's the state with the current version, but before presence of models module in package was indication that this is django application and can be put in INSTALLED_APPS list.
1
18
0
I am learning Django and I am trying to understand the use of models.py in the project versus the application. It seems from the tutorial examples that I include a model definition in the app, but when I went to apply that knowledge to my own existing database I got stuck. I took a database that I use (a copy of course) and generated the conceptual schema as a django model using inspectdb. I did this at the project level, and presumed then I could write apps using subschemas in the applications for that project. But generalizing the tutorial, they define the model in the application's model.py. If I did that, I would be repeating the model (or part of it) that's already at the project level, which seems like a mistake and a maintenance issue. So how, in Django style, do I use the project schema (or parts of it) without redefining it in the application's models.py? Thanks in advance.
Django project models.py versus app models.py
1
0
0
11,119
2,611,205
2010-04-09T21:58:00.000
0
0
1
0
python,codec,string
2,611,227
3
false
0
0
You shouldn't normally use codecs with str, except to turn them into unicodes. Perhaps you should be looking at using the latin-1 codec if you think you want "raw" data in your unicodes.
2
10
0
I've got a Python program that stores and writes data to a file. The data is raw binary data, stored internally as str. I'm writing it out through a utf-8 codec. However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to <undefined> in the cp1252.py file. This looks to me like Python is trying to interpret the data using the default code page. But it doesn't have a default code page. That's why I'm using str, not unicode. I guess my questions are: How do I represent raw binary data in memory, in Python? When I'm writing raw binary data out through a codec, how do I encode/unencode it?
How do I write raw binary data in Python?
0
0
0
24,608
2,611,205
2010-04-09T21:58:00.000
22
0
1
0
python,codec,string
2,617,930
3
true
0
0
NOTE: this was written for Python 2.x. Not sure if applicable to 3.x. Your use of str for raw binary data in memory is correct. [If you're using Python 2.6+, it's even better to use bytes which in 2.6+ is just an alias to str but expresses your intention better, and will help if one day you port the code to Python 3.] As others note, writing binary data through a codec is strange. A write codec takes unicode and outputs bytes into the file. You're trying to do it backwards, hence our confusion about your intentions... [And your diagnosis of the error looks correct: since the codec expects unicode, Python is decoding your str into unicode with the system's default encoding, which chokes.] What you want to see in the output file? If the file should contain the binary data as-is: Then you must not send it through a codec; you must write it directly to the file. A codec encodes everything and can only emit valid encodings of unicode (in your case, valid UTF-8). There is no input you can give it to make it emit arbitrary byte sequences! If you require a mixture of UTF-8 and raw binary data, you should open the file directly, and intermix writes of some_data with some_text.encode('utf8')... Note however that mixing UTF-8 with raw arbitrary data is very bad design, because such files are very inconvenient to deal with! Tools that understand unicode will choke on the binary data, leaving you with not convenient way to even view (let alone modify) the file. If you want a friendly representation of arbitrary bytes in unicode: Pass data.encode('base64') to the codec. Base64 produces only clean ascii (letters, numbers, and a little punctuation) so it can be clearly embedded in anything, it clearly looks to people as binary data, and it's reasonably compact (slightly over 33% overhead). P.S. you may note that data.encode('base64') is strange. .encode() is supposed to take unicode but I'm giving it a string?! Python has several pseudo-codecs that convert str->str such as 'base64' and 'zlib'. .encode() always returns an str but you'll feed it into a codec expecting unicode?! In this case it will only contain clean ascii, so it doesn't matter. You may write explicitly data.encode('base64').encode('utf8') if it makes you feel better. If you need a 1:1 mapping from arbitrary bytes to unicode: Pass data.decode('latin1') to the codec. latin1 maps bytes 0-255 to unicode characters 0-255, which is kinda elegant. The codec will, of course, encode your characters - 128-255 are encoded as 2 or 3 bytes in UTF-8 (surprisingly, the average overhead is 50%, more than base64!). This quite kills the "elegance" of having a 1:1 mapping. Note also that unicode characters 0-255 include nasty invisible/control characters (newline, formfeed, soft hyphen, etc.) making your binary data annoying to view in text editors. Considering these drawbacks, I do not recommend latin1 unless you understand exactly why you want it. I'm just mentioning it as the other "natural" encoding that springs to mind.
2
10
0
I've got a Python program that stores and writes data to a file. The data is raw binary data, stored internally as str. I'm writing it out through a utf-8 codec. However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to <undefined> in the cp1252.py file. This looks to me like Python is trying to interpret the data using the default code page. But it doesn't have a default code page. That's why I'm using str, not unicode. I guess my questions are: How do I represent raw binary data in memory, in Python? When I'm writing raw binary data out through a codec, how do I encode/unencode it?
How do I write raw binary data in Python?
1.2
0
0
24,608
2,611,593
2010-04-09T23:28:00.000
0
0
1
0
python,qt,module
2,611,862
1
true
0
1
That's QuickTime, nothing to do with Qt. In your question it's not really clear if you intended to use Qt or QuickTime.
1
0
0
There is a python module called "_Qt". PyQt is not what I want. I was wondering if there was any documentation for the _Qt module installed with python as a standard module. I have a mac.
How to use the _Qt python module?
1.2
0
0
232
2,611,606
2010-04-09T23:31:00.000
0
0
0
0
c++,python,geometry,cad
10,033,868
8
false
0
1
While not exactly a library, one way of doing this might be to build on top of the 2D-to-3D extrusion ability that most of these libraries do support. A tentative algorithm for doing this might be: Get bit profile as a 2D shape (you're likely to have this already). Extrude that profile along the line or arc that is the toolpath, creating a 3D solid that is the shape of the cut. At each vertex (say, where a straight path joins a curved one), do a "rotate extrude" or "revolve extrude" of the bit profile to generate the corner radius -- most libraries should support this operation as well. Repeat from 2 until done with all toolpaths. Do a CSG boolean subtraction of (workpiece - set_of_toolpaths). That algorithm seems like it might be fraught with edge cases, but I haven't been able to think of any so far. I'm wondering why, if it's this simple, there aren't more packages already doing it.
1
2
0
I'm trying to put together a simple program that will let me visualize a series of consecutive cuts on a wood panel using a router with a particular cutting head. I'm trying to find a geometry library that is capable of subtractively modifying 3D shapes or solids by sweeping other 3D solids through them. Specifically, I'd like to be able to define a rectangular solid (the wood panel) and then define a bit profile shape, and take cuts through the rectangular solid (sometimes on a straight line, sometimes on a circular arc). Does anyone know of anything that will do this?
Subtractively sweep a solid through another in python (or C++)
0
0
0
2,504
2,611,892
2010-04-10T01:32:00.000
19
1
1
0
python,oop
2,612,192
9
false
0
0
New-style classes have an mro method you can call which returns a list of parent classes in method resolution order.
1
273
0
How can I get the parent class(es) of a Python class?
How to get the parents of a Python class?
1
0
0
137,219
2,611,910
2010-04-10T01:45:00.000
2
0
0
0
python,browser,desktop,httpserver
2,611,928
5
false
1
0
There are plenty of excellent GUI tools for the way you want to do your GUI -- HTML, CSS, and Javascript. If you don't know of any, ask in a separate question with the right tags. The Python side in such an arrangement should have no GUI of its own, but just run a subclass of the Python's standard library's HTTP server, just serving the HTML, CSS, and JS files, and data via JSON on other URLs that the JS can reach with Ajax techniques, essentially implementing storage and business logi -- so it's far from obvious what "GUI tool" you could possibly want for it?! Just develop the Python side on its own (e.g. with IDLE, Wingware, SPE, or whatever you like) and the HTML / CSS / Javascript separately, with its own "GUI tool". All that Python will do with those files is statically serve them, after all. You could be thinking of using some Python side templating, such as Mojo &c, but my recommendation is to avoid that: rather, go with the "thin server architecture" all the way, make the Python side a RESTful server of business logic and storage layers, and do all the GUI work in the browser instead.
1
27
0
I want to create an application that runs on the users computer, a stand-alone application, with installation and what-not, but I want the interface to be a browser, either internal and displayed as an OS window or external accessible using the browser (i.e. some http server). The reason would be because I know a little about Python, but I think I can manage as long as I have some basic roots that I can use and manipulate, and those would be HTML, CSS, and Javascript. I've yet to find a good GUI tool which I can use, and always abandon the idea after trying to mess around and eventually not getting anything.
Python Desktop Application with the Browser as an interface?
0.07983
0
1
25,678
2,612,515
2010-04-10T06:35:00.000
0
1
0
0
python,memcached
2,614,485
3
false
0
0
Sounds like linker issues. What system is this on? How is _pylibmc.so linked to libmemcached.so? Can you provide the commands run by your build phase, and perhaps the ldd output?
3
1
0
There is a problem when I used the pylibmc. When I "import pylibmc", then I'll get some error following: ImportError: /usr/local/python2.6/lib/python2.6/site-packages/_pylibmc.so: undefined symbol: memcached_server_list. My enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5 So, how can I solve it? Thanks very much. UPDATE 1: I read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable. UPDATE 2: I test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.
pylibmc: undefined symbol: memcached_server_list
0
0
0
1,860
2,612,515
2010-04-10T06:35:00.000
0
1
0
0
python,memcached
2,620,050
3
false
0
0
I was having the same problem and I got it working by using libmemcached 0.34 and then setting the environment variable LD_LIBRARY_PATH to /usr/local/lib (where the libmemcache library was stored).
3
1
0
There is a problem when I used the pylibmc. When I "import pylibmc", then I'll get some error following: ImportError: /usr/local/python2.6/lib/python2.6/site-packages/_pylibmc.so: undefined symbol: memcached_server_list. My enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5 So, how can I solve it? Thanks very much. UPDATE 1: I read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable. UPDATE 2: I test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.
pylibmc: undefined symbol: memcached_server_list
0
0
0
1,860
2,612,515
2010-04-10T06:35:00.000
1
1
0
0
python,memcached
2,660,258
3
false
0
0
There appears to be some confusion about the symbol memcached_server_list: libmemcached 0.38 exposes it, but 0.39 does not. The symbol has even been removed from the documentation. pylibmc relies on memcached_server_list for its get_stats() method. I suspect pylibmc should be using memcached_server_cursor instead. So I think we can say that pylibmc 1.0 requires libmemcached <= 0.38.
3
1
0
There is a problem when I used the pylibmc. When I "import pylibmc", then I'll get some error following: ImportError: /usr/local/python2.6/lib/python2.6/site-packages/_pylibmc.so: undefined symbol: memcached_server_list. My enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5 So, how can I solve it? Thanks very much. UPDATE 1: I read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable. UPDATE 2: I test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.
pylibmc: undefined symbol: memcached_server_list
0.066568
0
0
1,860
2,612,583
2010-04-10T07:11:00.000
0
0
1
0
python
2,614,680
3
false
0
0
I am a bit surprised that no one seems to have written a popular "MutableString" wrapper class for Python. I would think that you'd want to have it store the string as a list, returning it via ''.join() and implement a suite of methods including those for strings (startswith, endswith, isalpha and all its ilk and so one) and those for lists. For simple operations just operating on the list and using ''.join() as necessary is fine. However, for something something like: 'foobar'.replace('oba', 'amca') when you're working with a list representation gets to be ugly. (that=list(''.join(that).replace(something, it)) ... or something like that). The constant marshaling between list and string representations is visually distracting.
1
1
0
i want to create a string S , which can be used as an array , as in each element can be used separately by accesing them as an array.
how to create a string which can be used as an array in python?
0
0
0
165
2,612,802
2010-04-10T08:49:00.000
34
0
1
0
python,list,reference,copy,clone
2,612,810
21
false
0
0
Python's idiom for doing this is newList = oldList[:]
1
3,068
0
While using new_list = my_list, any modifications to new_list changes my_list every time. Why is this, and how can I clone or copy the list to prevent it?
How do I clone a list so that it doesn't change unexpectedly after assignment?
1
0
0
2,010,060
2,613,672
2010-04-10T14:19:00.000
1
0
1
1
python,eclipse,eclipse-plugin,pydev
2,613,712
2
false
0
0
This often happens when you're using something like cherrypy/django and the process restarts after you've changed a python file while it's running. When this happens, I think the process is different but still using the same output console and thus won't be killed when you press the red button. I'm not sure there's a way of fixing it, except for disabling auto-restarting in the web framework etc.
2
1
0
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch in the background, once it's launched I have to go to task manager to kill the python process.
Eclipse PyDev doesn't shut down interpreter when you click the little red button
0.099668
0
0
437
2,613,672
2010-04-10T14:19:00.000
1
0
1
1
python,eclipse,eclipse-plugin,pydev
2,614,018
2
true
0
0
As far as I can tell when working with Django you need to add runserver --noreload to your program argument in Run > Run... menu
2
1
0
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch in the background, once it's launched I have to go to task manager to kill the python process.
Eclipse PyDev doesn't shut down interpreter when you click the little red button
1.2
0
0
437
2,614,975
2010-04-10T21:04:00.000
2
0
1
0
python,string,copy,clipboard
2,615,110
4
false
0
0
For a multi-platform solution you will need to use a cross-platform framework like wxPython or PyQt - they both have support for reading and writing to the system clipboard in a platform independent way.
1
3
0
Ok guys I imagine this is easy but I can't seem to find how to copy a string. Simply COPY to the system like CTRL+C on a text. Basically I want to copy a string so I can for example, lets say, paste(ctrl+v). Sorry for such a trivial question, haha.
Copy string - Python
0.099668
0
0
4,397
2,615,526
2010-04-11T00:05:00.000
5
0
1
0
python,absolute-path
2,615,547
3
false
0
0
It is supposed to be like that. Relative paths are relative to the process's current working directory, not the directory that your script resides in.
1
0
0
For instance, if I have: C:\42\main.py and C:\42\info.txt and I want to read info.txt from main.py, I have to input "C:\42\info.txt" instad of just "info.txt". Is it supposed to be like that? If not, how can I fix it?
(Python) Why do I always have to type absolute paths in file functions?
0.321513
0
0
559
2,615,830
2010-04-11T02:19:00.000
4
0
0
0
python,database,url,storage,web-crawler
2,615,862
6
false
1
0
It depends on the scale of the spidering you're going to be doing, and the kind of machine you're doing it on. Suppose a typical URL is a string of 60 bytes or so, an in-memory set will take a bit more than 100 bytes per URL (sets and dicts in Python are never allowed to grow beyond 60% full, for speed reasons). If you have a 64-bit machine (and Python distro) with about 16 GB of RAM available, you could surely devote over 10 GB to the crucial set in question, letting you easily spider about 100 million URLs or so; but at the other extreme, if you have a 32-bit machine with 3GB of RAM, you clearly can't devote much more than a GB to the crucial set, limiting you to about 10 million URLs. Sqlite would help around the same range of sized where a 32-bit machine couldn't make it but a generously-endowed 64-bit one could -- say 100 or 200 million URLs. Beyond those, I'd recommend PostgreSQL, which also has the advantage of being able to run on a different machine (on a fast LAN) with basically no problems, letting you devote your main machine to spidering. I guess MySQL &c would be OK for that too, but I love PostgreSQL standard compliance and robustness;-). This would allow, say, a few billion URLs with no problems (just a fast disk, or better a RAID arrangement, and as much RAM as you can afford to speed things up, of course). Trying to save memory/storage by using a fixed-length hash in lieu of URLs that might be quite long is fine if you're OK with an occasional false positive that will stop you from crawling what's actually a new URL. Such "collisions" need not be at all likely: even if you only use 8 bytes for the hash, you should only have a substantial risk of some collision when you're looking at billions of URLs (the "square root heuristic" for this well-known problem). With 8-bytes strings to represent the URLs, the in-memory set architecture should easily support a billion URLs or more on a well-endowed machine as above outlined. So, roughly how many URLs do you want to spider, and how much RAM can you spare?-)
3
7
0
I created a little web spider in Python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So what's the best way to keep track of my visited URLs? Should I use a database? which one? MySQL, SQLite, PostgreSQL? how should I save the URLs? As a primary key trying to insert every URL before visiting it? Or should I write them to a file? one file? multiple files? how should I design the file-structure? I'm sure there are books and a lot of papers on this or similar topics. Can you give me some advice what I should read?
Storing URLs while Spidering
0.132549
0
0
1,194
2,615,830
2010-04-11T02:19:00.000
7
0
0
0
python,database,url,storage,web-crawler
2,615,836
6
true
1
0
These seem to be the important aspects to me: You can't keep the URLs in memory as RAM will get too high You need fast existence lookups at least O(logn) You need fast insertions There are many ways to do this and it depends on how big your database will get. I think an SQL database can provide a good model for your problem. Probably all you need is an SQLite database. Typically string lookups for existence check is a slow operation. To speed this up you can create a CRC hash of the URL and store both the CRC and URL in your database. You would have an index on that CRC field. When you insert: You insert the URL and the hash When you want to do an existance lookup: You take the CRC of the potentially new URL and check if it is in your database already. There is of course a chance of collision on the URL hashes, but if 100% spanning is not important to you then you can take the hit of not having a URL in your DB when there is a collision. You could also decrease collisions in many ways. For example you can increase the size of your CRC (CRC8 instead of CRC4) and use a hashing algorithm with a bigger size. Or use CRC as well as URL length.
3
7
0
I created a little web spider in Python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So what's the best way to keep track of my visited URLs? Should I use a database? which one? MySQL, SQLite, PostgreSQL? how should I save the URLs? As a primary key trying to insert every URL before visiting it? Or should I write them to a file? one file? multiple files? how should I design the file-structure? I'm sure there are books and a lot of papers on this or similar topics. Can you give me some advice what I should read?
Storing URLs while Spidering
1.2
0
0
1,194
2,615,830
2010-04-11T02:19:00.000
9
0
0
0
python,database,url,storage,web-crawler
2,615,904
6
false
1
0
I've written a lot of spiders. To me, a bigger problem than running out of memory is the potential of losing all the URLs you've spidered already if the code or machine crashes or you decide you need to tweak the code. If you run out of RAM most machines and OSes these days will page so you'll slow down but still function. Having to rebuild a set of URLs gathered over hours and hours of run-time because its no longer available can be a real blow to productivity. Keeping information in RAM that you do NOT want to lose is bad. Obviously a database is the way to go at that point because you need fast random access to see if you've already found a URL. Of course in-memory lookups are faster but the trade-off of figuring out WHICH urls to keep in memory adds overhead. Rather than try writing code to determine which URLs I need/don't-need, I keep it in the database and concentrate on making my code clean and maintainable and my SQL queries and schemas sensible. Make your URL field a unique index and the DBM will be able to find them in no time while automatically avoiding redundant links. Your connection to the internet and sites you're accessing will probably be a lot slower than your connection to a database on a machine on your internal network. A SQLite database on the same machine might be the fastest, though the DBM itself isn't as sophisticated as Postgres, which is my favorite. I found that putting the database on another machine on the same switch as my spidering machine to be extremely fast; Making one machine handle the spidering, parsing, and then the database reads/writes is pretty intensive so if you have an old box throw Linux on it, install Postgres, and go to town. Throw some extra RAM in the box if you need more speed. Having that separate box for database use can be very nice.
3
7
0
I created a little web spider in Python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So what's the best way to keep track of my visited URLs? Should I use a database? which one? MySQL, SQLite, PostgreSQL? how should I save the URLs? As a primary key trying to insert every URL before visiting it? Or should I write them to a file? one file? multiple files? how should I design the file-structure? I'm sure there are books and a lot of papers on this or similar topics. Can you give me some advice what I should read?
Storing URLs while Spidering
1
0
0
1,194
2,615,923
2010-04-11T03:15:00.000
0
0
1
0
python,ci-server
2,615,976
5
false
0
0
While this is certainly not a complete answer to your question, I would like to recommend very highly the learning of the tool 'make'. I find myself using it on a VERY regular basis, for a wide variety of tasks, including (but by no means limited to) building, testing, and deploying software.
2
6
0
What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated. Please tell me how do one start learning to set up a build process for his project. If this is too abstract to make any sense, I would add that I use Python and do web programming with Django. Thanks in advance.
How can I learn to set up a build process?
0
0
0
354
2,615,923
2010-04-11T03:15:00.000
1
0
1
0
python,ci-server
2,616,079
5
false
0
0
For Python projects you should use setuptools. Setuptools has all the stuff to pack things up into .eggs, compile C modules, run unit tests, etc... If you've ever done "python setup.py [build|install|test]" then you've used setuptools.
2
6
0
What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated. Please tell me how do one start learning to set up a build process for his project. If this is too abstract to make any sense, I would add that I use Python and do web programming with Django. Thanks in advance.
How can I learn to set up a build process?
0.039979
0
0
354
2,615,968
2010-04-11T03:42:00.000
11
0
1
1
python,windows,virtualenv,virtualenvwrapper
2,616,482
6
true
0
0
mkvirtualenv is a bash script so you need to run bash shell to make use of it. mkvirtualenv is a bash function in the mkvirtualenv_bashrc script You will need to run this from cygwin under Windows. (You can call a native python from this and not need a cygwin python)
2
39
0
I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea?
Installing virtualenvwrapper on Windows
1.2
0
0
34,056
2,615,968
2010-04-11T03:42:00.000
5
0
1
1
python,windows,virtualenv,virtualenvwrapper
49,574,221
6
false
0
0
In windows we need to use virtualenv not mkvirtualenv while creating virtual environments
2
39
0
I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea?
Installing virtualenvwrapper on Windows
0.16514
0
0
34,056
2,616,190
2010-04-11T06:01:00.000
1
1
1
1
python,installation,metadata
2,616,194
2
false
0
0
You want the sys module: >>> print sys.executable /usr/bin/python >>> print sys.path ['', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
1
2
0
e.g., how can I find out that the executable has been installed in "/usr/bin/python" and the library files in "/usr/lib/python2.6"?
Python: what package contains the installation metadata?
0.099668
0
0
91
2,616,610
2010-04-11T09:45:00.000
2
0
0
0
python,django,memcached,python-memcached,consistent-hashing
2,616,824
6
true
1
0
Looking at the _get_server method on python-memcached v1.45, it seems it doesn't use consistent hashing, but a simple hash % len(buckets). Same goes for binary protocol, python-memcache uses, as far as I can see in the source, only text commands.
1
4
0
Python-memcached is the official supported memcached driver for Django. Does it support Consistent hashing Binary protocol If it does, how do I use those features within Django? I couldn't find any documentation.
Does python-memcached support consistent hashing & binary protocol?
1.2
0
0
2,396
2,617,007
2010-04-11T12:38:00.000
13
0
1
0
python,.net,ironpython,cpython,python.net
2,617,936
6
true
0
1
IronPython is NOT equivalent to "other languages that run on .NET", as the language has support for substantially fewer CLR runtime features. IronPython classes are not "real" .NET classes, and DLR APIs need to be used when calling IronPython code from traditional CLR-based languages; this means that if you want genuinely easy interoperability, you're stuck writing glue to "hide" the DLR. Boo is a much more complete Pythonically-inspired language targeting the CLR. Its (dynamically inferrable) static typing (which can be replaced with duck typing on a variable-by-variable basis) also allows libraries written in Boo to be natively used from C# and other CLR-based languages, without needing to make any allowances for the language in use.
4
12
0
I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use CPython every day, I love the Zen :) but my current task is a Windows-only application with a complex GUI and some other features which I would like to implement using .NET.
Can I treat IronPython as a Pythonic replacement to C#?
1.2
0
0
1,073
2,617,007
2010-04-11T12:38:00.000
1
0
1
0
python,.net,ironpython,cpython,python.net
2,617,900
6
false
0
1
The question "Can I treat IronPython as a Pythonic replacement for C#?" has been answered pretty well by jalf. If the question were "Is IronPython a Pythonic .NET Language?" though, then the answer would absolutely be yes. The principles of Zen - esp. least surprise - absolutely apply to IronPython's integration with the CLR as well.
4
12
0
I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use CPython every day, I love the Zen :) but my current task is a Windows-only application with a complex GUI and some other features which I would like to implement using .NET.
Can I treat IronPython as a Pythonic replacement to C#?
0.033321
0
0
1,073
2,617,007
2010-04-11T12:38:00.000
0
0
1
0
python,.net,ironpython,cpython,python.net
3,042,636
6
false
0
1
"Complex" UI usually entails not "writing" it but building it within Visual Studio with point and click. All the callbacks and eventing code is inserted by itself. There is almost nothing like that on python side. I'd say go for C# straight out. There is one nagging thing though. If you are true Pythonista, the static typing will get to you very very quickly and you will want to start throwing heavy objects at random people. If that point comes think about building out the UI with C# and embedding IronPython as a scripting engine for implementing your business logic. That could be a tolerable middle ground.
4
12
0
I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use CPython every day, I love the Zen :) but my current task is a Windows-only application with a complex GUI and some other features which I would like to implement using .NET.
Can I treat IronPython as a Pythonic replacement to C#?
0
0
0
1,073
2,617,007
2010-04-11T12:38:00.000
10
0
1
0
python,.net,ironpython,cpython,python.net
2,617,019
6
false
0
1
That depends on what it is about C# that you need, and which needs replacing. If the reason you use C# is that you need a reasonably high performance statically typed language then no, IronPython is likely not going to be a replacement. If the reason you use it is simply "I need something that runs on .NET and can access .NET libraries", then yes, any language that runs on .NET can be used to replace it. If you use C# because you're working with a team of programmers who only know C-like languages, C# might also be difficult to replace with IronPython. It depends on what characteristics about C# it is that you care about, and need to find replacements for.
4
12
0
I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use CPython every day, I love the Zen :) but my current task is a Windows-only application with a complex GUI and some other features which I would like to implement using .NET.
Can I treat IronPython as a Pythonic replacement to C#?
1
0
0
1,073
2,617,684
2010-04-11T16:16:00.000
0
0
0
0
python,selenium,selenium-rc,selenium-ide
2,620,931
2
false
1
0
No there isn't a way but in theory it shouldn't be too difficult to do as all you need to do is have something that uses the python-rc.js to convert the file.
1
6
0
How would I convert test cases made by Selenium IDE to Python without exporting every test case by hand? Is there any command line converter for that job? In the end I want to use Selenium RC and Pythons build in unittest to test my websites. Thanks a lot. Update: I started to write a converter but its too much work to implement all the commands. Is there any better way? from xml.dom.minidom import parse class SeleneseParser: def __init__(self,selFile): self.dom = parse(selFile) def getTestName(self): return self.dom.getElementsByTagName('title')[0].firstChild.data def getBaseUrl(self): return self.dom.getElementsByTagName('link')[0].getAttribute('href') def getNodes(self): cmds = [] nodes = self.dom.getElementsByTagName('tbody')[0].childNodes for node in nodes: if node.nodeType == node.TEXT_NODE and "\n" in node.data: continue if node.nodeType == node.COMMENT_NODE: cmds.append(node.data) if node.nodeType == node.ELEMENT_NODE: cmd = [] for c in node.childNodes: if c.nodeType == node.ELEMENT_NODE: if len(c.childNodes) == 1: cmd.append(c.childNodes[0].data) else: cmd.append("") cmds.append(cmd) return cmds class PythonConverter: def __init__(self,sourceFile): self.parser = SeleneseParser(sourceFile) self.dest = u'# -*- coding: utf-8 -*-\n\nfrom selenium import selenium\nimport unittest, time, re\n' def getHeader(self): self.dest += u'\nclass %s(unittest.TestCase):\n' % self.parser.getTestName() self.dest += u'\tdef setUp(self):\n\t\tself.verificationErrors = []\n' self.dest += u'\t\tself.selenium = selenium("localhost", 4444, "*chrome", "%s")\n' % self.parser.getBaseUrl() self.dest += u'\t\tself.selenium.start()\n' def getContent(self): self.dest += u'\n\tdef test_%s(self):\n\t\tsel = self.selenium\n' % self.parser.getTestName() nodes = self.parser.getNodes() for node in nodes: if type(node) is list: cmd,target,value = node[0],node[1],node[2] if cmd == 'store': self.dest += u'\t\t%s = "%s"\n' % (value,target) elif cmd == 'clickAndWait': self.dest += u'\t\tsel.click(u"%s")\n\t\tsel.wait_for_page_to_load("30000")\n' % (target) elif cmd == 'type': self.dest += u'\t\tsel.%s(u"%s", u"%s")\n' % (cmd,target,value) elif cmd == 'select': self.dest += u'\t\tsel.select(u"%s", u"%s")\n' % (target,value) elif cmd == 'verifyTextPresent': self.dest += u'\t\ttry: self.failUnless(sel.is_text_present(u"%s"))\n\t\texcept AssertionError, e: self.verificationErrors.append(str(e))\n' % target elif cmd == 'verifySelectedLabel': self.dest += u'\t\ttry: self.assertEqual(u"%s", sel.get_selected_label(u"%s"))\n\t\texcept AssertionError, e: self.verificationErrors.append(str(e))\n' % (value,target) elif cmd == 'verifyValue': self.dest += u'\t\ttry: self.assertEqual(u"%s", sel.get_value(u"%s"))\n\t\texcept AssertionError, e: self.verificationErrors.append(str(e))\n' % (value,target) elif cmd == 'verifyText': self.dest += u'\t\ttry: self.assertEqual(u"%s", sel.get_text(u"%s"))\n\t\texcept AssertionError, e: self.verificationErrors.append(str(e))\n' % (value,target) elif cmd == 'verifyElementPresent': self.dest += u'\t\ttry: self.failUnless(sel.is_element_present(u"%s"))\n\t\texcept AssertionError, e: self.verificationErrors.append(str(e))\n' % (target) else: self.dest += u'\t\tsel.%s(u"%s")\n' % (cmd,target) #print cmd,target,value else: self.dest += u'\t\t#%s\n' % node def getFooter(self): self.dest += u'\n\tdef tearDown(self):\n\t\tself.selenium.stop()\n\t\tself.assertEqual([], self.verificationErrors)\n' self.dest += u'\nif __name__ == "__main__":\n\tunittest.main()' def convert(self): self.getHeader() self.getContent() self.getFooter() return self.dest p = PythonConverter('test_case.html') print p.convert()
How to convert Selenese (html) to Python programmatically?
0
0
1
2,514
2,618,862
2010-04-11T21:59:00.000
0
1
0
0
python,system
2,619,276
3
false
0
0
In general, python is not the best language choice if you want to allow the execution of untrusted code. The JVM and .NET have much better support for sandboxing, so Jython and IronPython would be better choices.
1
5
0
How can I protect my web server, if I run custom users code on server. If any user can submit his python source on my server and run it. Maybe some modules or linux tools for close any network and hardware activity for this script. Thank's all for help!
Safest python code running
0
0
1
620
2,618,921
2010-04-11T22:18:00.000
3
0
0
0
python,mmap,shelve,dbm
2,618,963
2
false
0
0
I'm not sure what you're trying to learn by asking this question, since you already seem to know the answer: it depends on the actual dbm store being used. Some of them will use mmap -- I expect everything but dumbdbm to use mmap -- but so what? The overhead in shelve is almost certainly not in the mmap-versus-fileIO choice, but in the pickling operation. You can't mmap the dbm file sensibly yourself in either case, as the dbm module may have its own fancy locking (and it may not be a single file anyway, like when it uses bsddb.) If you're just looking for inspiration for your own datastore, well, don't look at shelve, since all it does is pickle-and-pass-along to another datastore.
2
2
0
Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses mmap? I'm prototyping a datastore, and while I realize premature optimization is generally frowned upon, this could really help me understand the trade-offs involved in my design.
Does Python's shelve module use memory-mapped IO?
0.291313
1
0
902
2,618,921
2010-04-11T22:18:00.000
4
0
0
0
python,mmap,shelve,dbm
2,618,981
2
true
0
0
Existing dbm implementations in the Python standard library all use "normal" I/O, not memory mapping. You'll need to code your own dbmish implementation with memory mapping, and integrate it with shelve (directly, or, more productively, through anydbm).
2
2
0
Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses mmap? I'm prototyping a datastore, and while I realize premature optimization is generally frowned upon, this could really help me understand the trade-offs involved in my design.
Does Python's shelve module use memory-mapped IO?
1.2
1
0
902
2,619,446
2010-04-12T01:43:00.000
3
0
0
0
python,pyqt4
2,619,472
1
true
0
1
These signals on cells are not sharply documented (that I can find) but I'd interpret them by analogy with the pressed, clicked, and released signals on buttons: pressed means the mouse's left button's been pressed down inside the widget, released means the mouse's left button's been released (let up) inside the widget, clicked means the mouse's left button's been pressed, then released (let up), both inside the widget So if you press the button down inside the widget, hold it down, move the mouse elsewhere, and only then release the mouse's button, then you should only see the pressed signal, but neither of the other two; while any clicked signal always implies both pressed and released have also been signaled. I believe that normal UI behavior should be to respond to clicked only, unless you want to do something special if the button's pressed and not released for a certain time (i.e., held down for a prolonged time).
1
1
0
The PyQt4 QTableWidget has both cellPressed and cellClicked signals. From the name, and the little experimentation I did with them, they appear to do exactly the same thing. Is there a difference between the two?
Difference between cellPressed and cellClicked signals of PyQt4 QTableWidget
1.2
0
0
1,577
2,621,055
2010-04-12T09:44:00.000
11
0
1
0
python,random
2,621,082
2
false
0
0
The [ indicates that 0.0 is included in the range of valid outputs. The ) indicates 1.0 is not in the range of valid outputs.
2
4
1
In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?
random() in python
1
0
0
1,409
2,621,055
2010-04-12T09:44:00.000
13
0
1
0
python,random
2,621,096
2
true
0
0
0.0 can be generated; 1.0 cannot (since it isn't within the range, hence the ) as opposed to [). The probability of generating 0.0 is equal to the probability of generating any other number within that range, namely, 1/X where X is the number of different possible results. For a standard unsigned double-precision floating point, this usually means 53 bits of fractional component, for 2^53 possible combinations, leading to a 1/(2^53) chance of generating exactly 0.0. So while it's possible for it to return exactly 0.0, it's unlikely that you'll see it any time soon - but it's just as unlikely that you'd see exactly any other particular value you might choose in advance.
2
4
1
In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?
random() in python
1.2
0
0
1,409
2,623,156
2010-04-12T15:21:00.000
6
0
1
0
python,matlab,datetime-format
11,143,809
4
false
0
0
Dates like 733828.0 are Rata Die dates, counted from January 1, 1 A.D. (and decimal fraction of days). They may be UTC or by your timezone. Julian Dates, used mostly by astronomers, count the days (and decimal fraction of days) since January 1, 4713 BC Greenwich noon. Julian date is frequently confused with Ordinal date, which is the date count from January 1 of the current year (Feb 2 = ordinal day 33). So datetime is calling these things ordinal dates, but I think this only makes sense locally, in the world of python.
1
18
0
Python and Matlab quite often have integer date representations as follows: 733828.0 733829.0 733832.0 733833.0 733834.0 733835.0 733836.0 733839.0 733840.0 733841.0 these numbers correspond to some dates this year. Do you guys know which function can convert them back to YYYYMMDD format? thanks a million!
How to convert the integer date format into YYYYMMDD?
1
0
0
77,232
2,624,091
2010-04-12T17:41:00.000
0
0
1
0
python,movie
5,007,196
2
false
0
0
Blurring is easy, either Avisynth or openCV will do that. If you need to track the position of a moving object then avisynth requires you to manually select the position, you should be able to write a decent object tracker in openCV easily. I don't know of any free video editors that do this automatically - if you you only need to do it once you could use a trial version of something like premiere.
1
2
0
I have a movie, and I want to produce a new movie out of it with an area blurred (e.g. an object, a writing or a face). The area is moving, so I must have fine control of the current frame and move the position of the blur area accordingly. Blur is an option, but also a dark mask is fine too. Now, I have a question open at superuser on which software to use, but since I suspect I will have to buy adobe premiere to do something like this, and I don't want to shell out a kidney for something I have to do once, I am thinking about coding it myself in python. What are the best libraries available for this task ?
How to programmatically blur an area in a movie (in python)?
0
0
0
908
2,624,100
2010-04-12T17:43:00.000
-3
0
1
1
python,osx-snow-leopard,pyobjc
2,624,473
2
false
0
0
You more than likely screwed with the OS's Python installation, so you'll more than likely need to reinstall your OS.
1
0
0
on OS X 10.6.3 Snow Leopard % python Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import objc Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 22, in _update() File "/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/__init__.py", line 19, in _update import _objc ImportError: dlopen(/Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so, 2): Library not loaded: /opt/local/lib/libiconv.2.dylib Referenced from: /Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/objc/_objc.so Reason: Incompatible library version: _objc.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 >>> -- what do I need to do?
Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib?
-0.291313
0
0
410
2,624,968
2010-04-12T19:58:00.000
5
0
1
1
python,linux,shell,development-environment
2,625,082
10
true
0
0
As an intern you'll want to use the tools your mentor is most comfortable with. If you get stuck you'll be able to ask for advice quickly. Learning your way around either vi, vim, or emacs to start with will help. The basic concepts used in one will transfer to the other. You'll need to be able to open and read files, search through files, edit and save files, and learn how to apply any python formatting helpers correctly. You should also familiarize yourself with version control if you haven't already. Again any one will do, you need to focus on concepts and etiquette rather than the specific tool. The goal of the internship (and really your entire time at university) should be used to learn concepts rather than specific tools. If you learn the concepts you'll be well placed to apply those concepts using any tool. You will also "learn how to learn" a new tool, which is really valuable.
3
4
0
I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting. I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest? Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead? Thanks for taking the time.
How do I prepare myself for a summer of working on Python using Linux environment?
1.2
0
0
674
2,624,968
2010-04-12T19:58:00.000
2
0
1
1
python,linux,shell,development-environment
2,625,078
10
false
0
0
Your lack of shell scripting knowledge shouldn't matter in this case, although it won't be hard to learn. I read over some shell tutorials and put them into practice. Try doing everything from the command line, including find (grep), find/replace all (sed), finding files (find), automating things using python scripts etc. Basically, don't cheat. You'll pick up a lot this way. You'll also probably end up wondering how you ever managed with Windows. What I use depends on the project. I really like Eclipse+PyDev but that's my personal preference, I also use Vim depending on where I am/what I'm doing. Remember you can just type python from the command line and it drops you into the python environment.
3
4
0
I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting. I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest? Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead? Thanks for taking the time.
How do I prepare myself for a summer of working on Python using Linux environment?
0.039979
0
0
674
2,624,968
2010-04-12T19:58:00.000
0
0
1
1
python,linux,shell,development-environment
2,625,070
10
false
0
0
For a Python IDE, I recommend using either IDLE or Eclipse with PyDev. Keep in mind you can also just use python on the linux command-line. It supports loading code from files, and if you use two command windows then one of them will be your "REPL" where you will be running python and dynamically loading code - and the other window can run your editor. Regarding linux command line, I cannot recommend any great resources. However, you will be off to a great start if you immerse yourself in this environment and only use linux for the next 2 weeks. Just keep learning, and when you do not know how to do something, read a manpage or google it to find the answer.
3
4
0
I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting. I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest? Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead? Thanks for taking the time.
How do I prepare myself for a summer of working on Python using Linux environment?
0
0
0
674
2,625,294
2010-04-12T20:42:00.000
2
0
1
0
python,formatting
2,625,394
5
false
0
0
Some editors have an auto-format feature that does this for you. Eclipse is one example (though you would probably have to install a python plug-in). Have you checked whichever editor you use for such a feature?
1
101
0
I have some existing code which isn't formatted consistently -- sometimes two spaces are used for indent, sometimes four, and so on. The code itself is correct and well-tested, but the formatting is awful. Is there a place online where I can simply paste a snippet of Python code and have it be indented/formatted automatically for me? Alternatively, is there an X such that I can do something like X --input=*.py and have it overwrite each file with a formatted version?
How do I autoformat some Python code to be correctly formatted?
0.07983
0
0
117,870
2,626,512
2010-04-13T01:55:00.000
1
0
0
0
python,client-server,asyncore,pysnmp
2,734,657
1
true
0
0
I solved this by adding a callback function into the asyncore loop for the receiver process. The solution was somewhat specific to the module I was experiment with (pySNMP), but here is the general idea: define a function closure that returns a callable method with a stored reference to a dict and window variable. The dict tracks the expected responses, and the window is the size of the sender buffer. pass a reference to the closure function into a customized asyncore.dispatcher instance. The callback function can be executed in the writeable method invocation. set the timeout of the dispatcher to a small value. This prevents asyncore from blocking for too long, while waiting for received packets. I used .05 seconds. The lower you go, the more response your app is, but don't go too low. update the asyncore read_handle method to remove the received responses from your global dict structure. This will allow new messages to be transmitted. now kick-off the dispatcher and every loop of the asyncore, the system will call the callback function, and send any messages, up to the defined window size.
1
1
0
I have a 3rd-party protocol module (SNMP) that is built on top of asyncore. The asyncore interface is used to process response messages. What is the proper technique to design a client that generate the request-side of the protocol, while the asyncore main loop is running. I can think of two options right now: Use the loop,timeout parameters of asyncore.loop() to allow my client program time to send the appropriate request. Create a client asyncore dispatcher that will be executed in the same asyncore processing loop as the receiver. What is the best option? I'm working on the 2nd solution, cause the protocol API does not give me direct access to the asyncore parameters. Please correct me if I've misunderstood the proper technique for utilizing asyncore.
Building an SNMP Request-Response service with Python Asyncore
1.2
0
1
625
2,626,636
2010-04-13T02:39:00.000
5
0
1
0
python,pickle
2,626,646
3
false
0
0
Alas, not directly. You can send the string form of the class statement, or a bytecode form, and "rehydrate" it with an exec on the receiving end.
1
12
0
Is there a way to pickle a class definition? What I'd like to do is pickle the definition (which may created dynamically), and then send it over a TCP connection so that an instance can be created on the other end. I understand that there may be dependencies, like modules and global variables that the class relies on. I'd like to bundle these in the pickling process as well, but I'm not concerned about automatically detecting the dependencies because it's okay if the onus is on the user to specify them.
Pickling a class definition
0.321513
0
0
5,935
2,627,135
2010-04-13T05:17:00.000
16
0
1
0
python,latex,sanitization
2,627,303
1
true
0
0
If your input is plain text and you are in a normal catcode regime, you must do the following substitutions: \ → \textbackslash{} (note the empty group!) { → \{ } → \} $ → \$ & → \& # → \# ^ → \textasciicircum{} (requires the textcomp package) _ → \_ ~ → \textasciitilde{} % → \% In addition, the following substitutions are useful at least when using the OT1 encoding (and harmless in any case): < → \textless{} > → \textgreater{} | → \textbar{} And these three disable the curly quotes: " → \textquotedbl{} ' → \textquotesingle{} ` → \textasciigrave{}
1
11
0
I'd like to take user input (sometimes this will be large paragraphs) and generate a LaTeX document. I'm considering a couple of simple regular expressions that replaces all instances of \ with \textbackslash and all instances of { or } with \} or \{. I doubt that this is sufficient. What else do I need to do? Note: In case there is a special library made for this, I'm using python. To clarify, I do not wish anything to be parsed treated as LaTeX syntax: $a$ should be replaced with \$a\$.
How do I sanitize LaTeX input?
1.2
0
0
1,952
2,627,419
2010-04-13T06:29:00.000
0
1
0
0
java,python,hp-quality-center
4,309,246
6
false
0
0
You can use a new Test and select type (VPXP_API) which allow script to run. The good thing there is that you'd have the function definition ready to be dragged from within QC instead of having to heavily rely on doc. I've done an implementation in Python running some script from within QC still using its API but via a QC test which is handy to retrieve directly the result (Output) etc.. going through some shell command which can then call any script on any server etc...
1
7
0
We have a project that uses HP Quality Center and one of the regular issues we face is people not updating comments on the defect. So I was thinkingif we could come up with a small script or tool that could be used to periodically throw up a reminder and force the user to update the comments. I came across the Open Test Architecture API and was wondering if there are any good Python or java examples for the same that I could see. Thanks Hari
Automating HP Quality Center with Python or Java
0
0
0
32,717
2,627,775
2010-04-13T07:41:00.000
0
0
1
0
python
43,765,937
5
false
0
0
there are numerous options for learning python for web. I learned python to access web data from courser.org, and the tutorial was very interesting. If you want to learn python for web then I suggest you to learn python to access web data in courser.org you can also learn python for everybody which is a specialization course with 5 courses in which each and every thing about python is given. The fun part of courser.org is that they provide assignments with due dates which means you have to complete an assessment of each week in that week itself. They also provide quiz. You have to pass all the assignments and quizzes to get the certificate which is very easy, you can easily complete the assessment and quizzes.
2
2
0
I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this? Example usages are: connecting to databases, and retrieving and storing information from forms.
How do I start learn Python for web
0
0
0
612
2,627,775
2010-04-13T07:41:00.000
0
0
1
0
python
42,923,113
5
false
0
0
There are numerous frameworks for making websites in Python. Once you are familiar with Python and the general nature of websites which would include the knowledge of HTTP, HTML you can proceed by using any of the following to make websites using Python: Webapp2 - A simple framework to get you started with making websites and using this framework you can easily make websites and cloud services and host them on the Google App Engine service. Follow these links for more information on use and hosting: Welcome to webapp2!, Google App Engine Django - As Alex Remedios has mentioned Django is also a very popular and widely used MVC web framework for Python. It is very comprehensive and follows the MVC web design principles. Various hosting options are also available for the same. You can learn more about Django here - The Web framework for perfectionists with deadlines, The Django Book (for learning the use of Django) Flask - Flask is a simplistic framework for making webapplications and websites using Python. I do not extensive experience using it but from what I have read it is similar to Webapp2 in many ways but is not as comprehensive as Django. But, it is very easy to pickup and use. Flask (A Python Microframework) As far as my knowledge goes these are the best ways to use Python in the web. To answer your second question, it is not implicitly possible to use Python in cohesion with HTML content like you would with PHP. However, there are libraries to do that too like the following: Python Wiki - Digi Developer Karrigell 3.1.1 If you are making extensive applications/websites the above two frameworks will pose major problems in doing simple tasks.
2
2
0
I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this? Example usages are: connecting to databases, and retrieving and storing information from forms.
How do I start learn Python for web
0
0
0
612
2,629,070
2010-04-13T11:26:00.000
3
1
0
0
python,django,mod-wsgi,wsgi,fapws3
2,633,716
2
false
1
0
The underlying web server is not the bottleneck, it is your application and database access. The differences between any underlying web server are going to very minimal or non existent in the context of an actual full application stack. You cannot base decisions on hello world type tests as they are pretty meaningless. Decisions should therefore be based on the quality and stability of the hosting solutions under load, as well as ease of configuration and support, including your own competence to manage a particular setup. If you have no idea how to configure and support a particular web server properly, eg., Apache, then why would you use it.
1
0
0
is there a difference between using FAPWS3 and MOD_WSGI when dealing with Django? FAPWS3 seems alot faster when serving requests toward Python scripts. I would like to know if I'm missing out anything. :) Any ideas?
Mod_wsgi versus fapws3 - Django
0.291313
0
0
853
2,629,680
2010-04-13T13:01:00.000
5
0
1
0
python,multithreading,parallel-processing
2,629,810
6
false
0
0
In a similar case I opted for separate processes and the little bit of necessary communication trough network socket. It is highly portable and quite simple to do using python, but probably not the simpler (in my case I had also another constraint: communication with other processes written in C++). In your case I would probably go for multiprocess, as python threads, at least when using CPython, are not real threads. Well, they are native system threads but C modules called from Python may or may not release the GIL and allow other threads them to run when calling blocking code.
2
123
0
I'd like to parallelize my Python program so that it can make use of multiple processors on the machine that it runs on. My parallelization is very simple, in that all the parallel "threads" of the program are independent and write their output to separate files. I don't need the threads to exchange information but it is imperative that I know when the threads finish since some steps of my pipeline depend on their output. Portability is important, in that I'd like this to run on any Python version on Mac, Linux, and Windows. Given these constraints, which is the most appropriate Python module for implementing this? I am trying to decide between thread, subprocess, and multiprocessing, which all seem to provide related functionality. Any thoughts on this? I'd like the simplest solution that's portable.
deciding among subprocess, multiprocessing, and thread in Python?
0.16514
0
0
49,808
2,629,680
2010-04-13T13:01:00.000
68
0
1
0
python,multithreading,parallel-processing
2,629,766
6
true
0
0
multiprocessing is a great Swiss-army knife type of module. It is more general than threads, as you can even perform remote computations. This is therefore the module I would suggest you use. The subprocess module would also allow you to launch multiple processes, but I found it to be less convenient to use than the new multiprocessing module. Threads are notoriously subtle, and, with CPython, you are often limited to one core, with them (even though, as noted in one of the comments, the Global Interpreter Lock (GIL) can be released in C code called from Python code). I believe that most of the functions of the three modules you cite can be used in a platform-independent way. On the portability side, note that multiprocessing only comes in standard since Python 2.6 (a version for some older versions of Python does exist, though). But it's a great module!
2
123
0
I'd like to parallelize my Python program so that it can make use of multiple processors on the machine that it runs on. My parallelization is very simple, in that all the parallel "threads" of the program are independent and write their output to separate files. I don't need the threads to exchange information but it is imperative that I know when the threads finish since some steps of my pipeline depend on their output. Portability is important, in that I'd like this to run on any Python version on Mac, Linux, and Windows. Given these constraints, which is the most appropriate Python module for implementing this? I am trying to decide between thread, subprocess, and multiprocessing, which all seem to provide related functionality. Any thoughts on this? I'd like the simplest solution that's portable.
deciding among subprocess, multiprocessing, and thread in Python?
1.2
0
0
49,808
2,629,841
2010-04-13T13:23:00.000
0
0
0
0
combobox,wxpython,wxwidgets
2,629,895
1
true
0
1
I use C++ version of wxWidget. Look up documentation on these two functions: void wxPostEvent(wxEvtHandler *dest, wxEvent& event) void AddPendingEvent(wxEvent& event)
1
1
0
As per the title, is there any way to programatically change the selected item in a ComboBox and have it raise an event? I am setting the selected item using myComboBox.SetSelection(index), but this doesn't raise the wx.EVT_COMBOBOX event.
Triggering wx.EVT_COMBOBOX after programatically changing ComboBox selection?
1.2
0
0
1,192
2,630,236
2010-04-13T14:20:00.000
14
0
1
0
python
2,630,253
2
true
0
0
Something in your program is trying to call the startswith method of an object, probably because it expects it to be a string. You'll have to pay attention to the traceback to see what it is being called on, and why that is an integer instead of a string. Did you pass along an integer where a string was expected?
1
5
0
I'm getting strange error "'int' object has no attribute 'startswith'" I haven't used the word "startswith" in my python program. ? Does any one how to fix this -- or what it refers to ?
'int' object has no attribute 'startswith'
1.2
0
0
37,853
2,631,813
2010-04-13T17:40:00.000
1
0
0
0
php,python,linux,image-processing
14,925,431
2
false
1
0
I'll never get back the time I wasted on wkhtml and Xvfb, along with the joy of embedding a monolithic binary from google onto my system. You can save yourself a lot of time and headache by abandoning wkhtml2whatever completely and installing phantom.js. Once I did that, I had five lines of shell code and beautiful images in no time. I had a single problem - using ww instead of www in a url caused the process to fail without meaningful error messages. Eventually I saw the dns lookup problem, and my faith was restored. But seriously, every other avenue of thumbnailing seemed to be out of date and/or buggy. phantom.js = it changed my life.
1
0
0
There exists numerous solutions on generating a thumbnail or an image preview of a webpage. Some of these solutions are webs-based like websnapshots, windows libraries such as PHP's imagegrabscreen (only works on windows), and KDE's wkhtml. Many more do exist. However, I'm looking for a GUI-less solution. Something I can create an API around and link it to php or python. I'm comfortable with python, php, C, and shell. This is a personal project, so I'm not interested in commercial applications as I'm aware of their existence. Any ideas?
Generate an image / thumbnail of a webpage using X/Gui-less linux
0.099668
0
0
353