title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
How to write a function that takes a string and prints the letters in decreasing order of frequency? | 665,942 | <p>I got this far:</p>
<pre><code>def most_frequent(string):
d = dict()
for key in string:
if key not in d:
d[key] = 1
else:
d[key] += 1
return d
print most_frequent('aabbbc')
</code></pre>
<p>Returning:</p>
<pre><code>{'a': 2, 'c': 1, 'b': 3}
</code></pre>
<p>No... | 4 | 2009-03-20T12:32:19Z | 673,064 | <p>Here's the code for your <code>most_frequent</code> function:</p>
<pre><code>>>> a = 'aabbbc'
>>> {i: a.count(i) for i in set(a)}
{'a': 2, 'c': 1, 'b': 3}
</code></pre>
<p>this particular syntax is for py3k, but it's easy to write something similar using syntax of previous versions. it seems to m... | 0 | 2009-03-23T11:36:23Z | [
"python"
] |
How to write a function that takes a string and prints the letters in decreasing order of frequency? | 665,942 | <p>I got this far:</p>
<pre><code>def most_frequent(string):
d = dict()
for key in string:
if key not in d:
d[key] = 1
else:
d[key] += 1
return d
print most_frequent('aabbbc')
</code></pre>
<p>Returning:</p>
<pre><code>{'a': 2, 'c': 1, 'b': 3}
</code></pre>
<p>No... | 4 | 2009-03-20T12:32:19Z | 8,117,915 | <p>Python 2.7 supports this use case directly:</p>
<pre><code>>>> from collections import Counter
>>> Counter('abracadabra').most_common()
[('a', 5), ('r', 2), ('b', 2), ('c', 1), ('d', 1)]
</code></pre>
| 3 | 2011-11-14T06:06:40Z | [
"python"
] |
What errors/exceptions do I need to handle with urllib2.Request / urlopen? | 666,022 | <p>I have the following code to do a postback to a remote URL:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except url... | 43 | 2009-03-20T12:56:21Z | 666,037 | <p>You can catch all exceptions and log what's get caught:</p>
<pre><code> import sys
import traceback
def formatExceptionInfo(maxTBlevel=5):
cla, exc, trbk = sys.exc_info()
excName = cla.__name__
try:
excArgs = exc.__dict__["args"]
except KeyError:
excArgs = "<no args>"
... | 1 | 2009-03-20T13:00:38Z | [
"python"
] |
What errors/exceptions do I need to handle with urllib2.Request / urlopen? | 666,022 | <p>I have the following code to do a postback to a remote URL:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except url... | 43 | 2009-03-20T12:56:21Z | 666,052 | <p>From the <a href="http://docs.python.org/library/urllib2.html">docs page</a> <code>urlopen</code> entry, it looks like you just need to catch <a href="http://docs.python.org/library/urllib2.html#urllib2.URLError">URLError</a>. If you really want to hedge your bets against problems within the urllib code, you can al... | 12 | 2009-03-20T13:06:01Z | [
"python"
] |
What errors/exceptions do I need to handle with urllib2.Request / urlopen? | 666,022 | <p>I have the following code to do a postback to a remote URL:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except url... | 43 | 2009-03-20T12:56:21Z | 666,071 | <pre><code>$ grep "raise" /usr/lib64/python/urllib2.py
IOError); for HTTP errors, raises an HTTPError, which can also be
raise AttributeError, attr
raise ValueError, "unknown url type: %s" % self.__original
# XXX raise an exception if no one else should try to handle
raise HTTPEr... | 10 | 2009-03-20T13:11:27Z | [
"python"
] |
What errors/exceptions do I need to handle with urllib2.Request / urlopen? | 666,022 | <p>I have the following code to do a postback to a remote URL:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except url... | 43 | 2009-03-20T12:56:21Z | 666,075 | <p>Add generic exception handler:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except urllib2.URLError, e:
checksL... | 40 | 2009-03-20T13:12:45Z | [
"python"
] |
What errors/exceptions do I need to handle with urllib2.Request / urlopen? | 666,022 | <p>I have the following code to do a postback to a remote URL:</p>
<pre><code>request = urllib2.Request('http://www.example.com', postBackData, { 'User-Agent' : 'My User Agent' })
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except url... | 43 | 2009-03-20T12:56:21Z | 666,393 | <p>I catch:<br />
<br />
httplib.HTTPException<br />
urllib2.HTTPError<br />
urllib2.URLError<br />
<br />
I believe this covers everything including socket errors.</p>
| 0 | 2009-03-20T14:30:09Z | [
"python"
] |
PyObjC + Python 3.0 Questions | 666,148 | <p>By default, a Cocoa-Python application uses the default Python runtime which is version 2.5. How can I configure my Xcode project so that it would use the newer Python 3.0 runtime? I tried replacing the Python.framework included in the project with the newer version but it did not work.</p>
<p>And another thing, ar... | 10 | 2009-03-20T13:30:08Z | 667,584 | <p>PyObjC does not yet work with Python 3.0. According to Ronald Oussoren, a (the?) PyObjC developer, Python 3.0 support is possible, but not yet implemented:</p>
<blockquote>
<p>Support for Python 3.x is on my todo
list but is non-trivial to achieve.
PyObjC contains a large amount of
pretty low-level C code, ... | 9 | 2009-03-20T19:20:56Z | [
"python",
"cocoa",
"xcode",
"pyobjc"
] |
PyObjC + Python 3.0 Questions | 666,148 | <p>By default, a Cocoa-Python application uses the default Python runtime which is version 2.5. How can I configure my Xcode project so that it would use the newer Python 3.0 runtime? I tried replacing the Python.framework included in the project with the newer version but it did not work.</p>
<p>And another thing, ar... | 10 | 2009-03-20T13:30:08Z | 4,464,084 | <p>PyObjC 2.3 added initial support for Python 3.1:</p>
<blockquote>
<p>This version requires Python 2.6 or later, and also supports
Python 3.1 or later.</p>
</blockquote>
<p>but also</p>
<blockquote>
<p>NOTE: Python 3 support is pre-alpha at this time: the code compiles
but does not pass tests yet. The code... | 2 | 2010-12-16T18:23:49Z | [
"python",
"cocoa",
"xcode",
"pyobjc"
] |
Decorator classes in Python | 666,216 | <p>I want to construct classes for use as decorators with the following principles intact:</p>
<ol>
<li>It should be possible to stack multiple such class decorators on top off 1 function.</li>
<li>The resulting function name pointer should be indistinguishable from the same function without a decorator, save maybe fo... | 29 | 2009-03-20T13:48:00Z | 666,230 | <p>A do-nothing decorator class would look like this:</p>
<pre><code>class NullDecl (object):
def __init__ (self, func):
self.func = func
for name in set(dir(func)) - set(dir(self)):
setattr(self, name, getattr(func, name))
def __call__ (self, *args):
return self.func (*args)
</code></... | 18 | 2009-03-20T13:52:14Z | [
"python",
"decorator"
] |
Decorator classes in Python | 666,216 | <p>I want to construct classes for use as decorators with the following principles intact:</p>
<ol>
<li>It should be possible to stack multiple such class decorators on top off 1 function.</li>
<li>The resulting function name pointer should be indistinguishable from the same function without a decorator, save maybe fo... | 29 | 2009-03-20T13:48:00Z | 666,258 | <p>The <a href="http://pypi.python.org/pypi/decorator">decorator module</a> helps you writing signature-preserving decorators.</p>
<p>And the <a href="http://wiki.python.org/moin/PythonDecoratorLibrary">PythonDecoratorLibrary</a> might provide useful examples for decorators.</p>
| 10 | 2009-03-20T13:59:10Z | [
"python",
"decorator"
] |
Decorator classes in Python | 666,216 | <p>I want to construct classes for use as decorators with the following principles intact:</p>
<ol>
<li>It should be possible to stack multiple such class decorators on top off 1 function.</li>
<li>The resulting function name pointer should be indistinguishable from the same function without a decorator, save maybe fo... | 29 | 2009-03-20T13:48:00Z | 666,302 | <p>To create a decorator that wraps functions in a matter that make them indistinguishable from the original function, use <code>functools.wraps</code>.</p>
<p>Example:</p>
<pre><code>
def mydecorator(func):
@functools.wraps(func):
def _mydecorator(*args, **kwargs):
do_something()
try:
... | 7 | 2009-03-20T14:10:41Z | [
"python",
"decorator"
] |
Unable to decode unicode string in Python 2.4 | 666,417 | <p>This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it returns str. I then attempt to run .decode('utf-8'), and I get an error ('utf8' codec can't decode bytes in position 1-4). </p>
<p>Really my goal here is just t... | 3 | 2009-03-20T14:36:31Z | 666,430 | <p>You need to use "ISO-8859-1":</p>
<pre><code>Name = 'w\xf6rner'.decode('iso-8859-1')
file.write('Name: %s - %s\n' %(Name, type(Name)))
</code></pre>
<p>utf-8 uses 2 bytes for escaping anything outside ascii, but here it's just 1 byte, so iso-8859-1 is probably correct.</p>
| 2 | 2009-03-20T14:41:06Z | [
"python",
"unicode",
"decode"
] |
Unable to decode unicode string in Python 2.4 | 666,417 | <p>This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it returns str. I then attempt to run .decode('utf-8'), and I get an error ('utf8' codec can't decode bytes in position 1-4). </p>
<p>Really my goal here is just t... | 3 | 2009-03-20T14:36:31Z | 666,440 | <p>Your string <strong>is not</strong> in UTF8 encoding. If you want to 'decode' string to unicode, your string must be in encoding you specified by parameter. I tried this and it works perfectly:</p>
<pre><code>print 'w\xf6rner'.decode('cp1250')
</code></pre>
<p><strong>EDIT</strong></p>
<p>For writing unicode str... | 7 | 2009-03-20T14:43:51Z | [
"python",
"unicode",
"decode"
] |
Unable to decode unicode string in Python 2.4 | 666,417 | <p>This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it returns str. I then attempt to run .decode('utf-8'), and I get an error ('utf8' codec can't decode bytes in position 1-4). </p>
<p>Really my goal here is just t... | 3 | 2009-03-20T14:36:31Z | 666,489 | <p>It's obviously 1-byte encoding. 'ö' in UTF-8 is '\xc3\xb6'.</p>
<p>The encoding might be:</p>
<ul>
<li>ISO-8859-1</li>
<li>ISO-8859-2</li>
<li>ISO-8859-13</li>
<li>ISO-8859-15</li>
<li>Win-1250</li>
<li>Win-1252</li>
</ul>
| 4 | 2009-03-20T14:55:11Z | [
"python",
"unicode",
"decode"
] |
Unable to decode unicode string in Python 2.4 | 666,417 | <p>This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it returns str. I then attempt to run .decode('utf-8'), and I get an error ('utf8' codec can't decode bytes in position 1-4). </p>
<p>Really my goal here is just t... | 3 | 2009-03-20T14:36:31Z | 666,789 | <blockquote>
<p>So in my code to reproduce I changed '\xf6' to '\xc3\xb6', and the failure still occurs</p>
</blockquote>
<p>Not in the first line it doesn't:</p>
<pre><code>>>> 'w\xc3\xb6rner'.decode('utf-8')
u'w\xf6rner'
</code></pre>
<p>The second line will error out though:</p>
<pre><code>>>>... | 2 | 2009-03-20T16:01:34Z | [
"python",
"unicode",
"decode"
] |
qt design issue | 666,712 | <p>i'm trying to design interface like this one
<a href="http://www.softpedia.com/screenshots/FlashFXP_2.png" rel="nofollow">http://www.softpedia.com/screenshots/FlashFXP_2.png</a></p>
<p>i'm using the QT design and programming with python
well on the left it's a treeWidget
but what is on the right side ? as everytime... | 2 | 2009-03-20T15:43:31Z | 666,739 | <p>Use <a href="http://doc.trolltech.com/4.5/qstackedwidget.html" rel="nofollow">QStackedWidget</a>. You insert several widgets which correspond to the <strong>pages</strong>. Changing the active item in tree should switch the active widget/page inside the stacked widget.</p>
| 8 | 2009-03-20T15:48:42Z | [
"python",
"user-interface",
"qt"
] |
How to get whole text of an Element in xml.minidom? | 666,724 | <p>I want to get the whole text of an Element to parse some xhtml:</p>
<pre><code><div id='asd'>
<pre>skdsk</pre>
</div>
</code></pre>
<p>begin E = div element on the above example, I want to get </p>
<pre><code><pre>skdsk</pre>
</code></pre>
<p>How?</p>
| 0 | 2009-03-20T15:44:37Z | 666,764 | <p>Strictly speaking:</p>
<pre><code>from xml.dom.minidom import parse, parseString
tree = parseString("<div id='asd'><pre>skdsk</pre></div>")
root = tree.firstChild
node = root.childNodes[0]
print node.toxml()
</code></pre>
<p>In practice, though, I'd recommend looking at the <a href="http://... | 2 | 2009-03-20T15:54:51Z | [
"python",
"minidom"
] |
How can I blue-box an image? | 667,016 | <p>I have a scanned image which is basically black print on some weird (non-gray) background, say, green or yellow (think old paper).</p>
<p>How can I get rid of the green/yellow and receive a gray picture with as much of the gray structure of the original image intact? I.e. I want to keep the gray around the letters ... | 0 | 2009-03-20T16:54:22Z | 667,108 | <p>I am more of C++ than python programmer, so I can't give you a code sample. But the general algorithm is something like this:</p>
<p>Finding the background color:
You make a histogram of the image. The histogram should have two peaks representing the background and foreground colors. Because you know that the backg... | 1 | 2009-03-20T17:18:03Z | [
"python",
"python-imaging-library"
] |
How can I blue-box an image? | 667,016 | <p>I have a scanned image which is basically black print on some weird (non-gray) background, say, green or yellow (think old paper).</p>
<p>How can I get rid of the green/yellow and receive a gray picture with as much of the gray structure of the original image intact? I.e. I want to keep the gray around the letters ... | 0 | 2009-03-20T16:54:22Z | 930,580 | <p>I was looking to make an arbitrary background color transparent a while ago and developed this script. It takes the most popular (background) color in an image and creates an alpha mask where the transparency is proportional to the distance from the background color. Taking RGB colorspace distances is an expensiv... | 1 | 2009-05-30T20:50:00Z | [
"python",
"python-imaging-library"
] |
How can I blue-box an image? | 667,016 | <p>I have a scanned image which is basically black print on some weird (non-gray) background, say, green or yellow (think old paper).</p>
<p>How can I get rid of the green/yellow and receive a gray picture with as much of the gray structure of the original image intact? I.e. I want to keep the gray around the letters ... | 0 | 2009-03-20T16:54:22Z | 25,145,104 | <p>I know the question is old, but I was playing around with ImageMagick trying to do something similar, and came up with this:</p>
<pre><code>convert text.jpg -fill white -fuzz 50% +opaque black out.jpg
</code></pre>
<p>which converts this:</p>
<p><img src="http://i.stack.imgur.com/yNBpO.jpg" alt="enter image descr... | 1 | 2014-08-05T17:42:54Z | [
"python",
"python-imaging-library"
] |
Finding the static attributes of a class in Python | 667,166 | <p>This is an unusual question, but I'd like to dynamically generate the <code>__slots__</code> attribute of the class based on whatever attributes I happened to have added to the class.</p>
<p>For example, if I have a class:</p>
<pre><code>class A(object):
one = 1
two = 2
__slots__ = ['one', 'two']
</co... | 3 | 2009-03-20T17:33:12Z | 667,195 | <p>At the point you're trying to define <strong>slots</strong>, the class hasn't been built yet, so you cannot define it dynamically from within the A class.</p>
<p>To get the behaviour you want, use a metaclass to introspect the definition of A and add a slots attribute.</p>
<pre><code>class MakeSlots(type):
de... | 3 | 2009-03-20T17:41:24Z | [
"python",
"class-design"
] |
Finding the static attributes of a class in Python | 667,166 | <p>This is an unusual question, but I'd like to dynamically generate the <code>__slots__</code> attribute of the class based on whatever attributes I happened to have added to the class.</p>
<p>For example, if I have a class:</p>
<pre><code>class A(object):
one = 1
two = 2
__slots__ = ['one', 'two']
</co... | 3 | 2009-03-20T17:33:12Z | 7,950,908 | <p>One very important thing to be aware of -- if those attributes stay in the class, the <code>__slots__</code> generation will be useless... okay, maybe not <em>useless</em> -- it will make the class attributes read-only; probably not what you want.</p>
<p>The easy way is to say, "Okay, I'll initialize them to None,... | 1 | 2011-10-31T07:25:51Z | [
"python",
"class-design"
] |
Crunching xml with python | 667,359 | <p>I need to remove white spaces between xml tags, e.g. if the original xml looks like:</p>
<pre><code><node1>
<node2>
<node3>foo</node3>
</node2>
</node1>
</code></pre>
<p>I'd like the end-result to be <em>crunched</em> down to single line:</p>
<pre><code><node... | 5 | 2009-03-20T18:22:30Z | 667,393 | <p>I'd use XSLT:</p>
<pre><code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:copy>
<x... | 5 | 2009-03-20T18:33:18Z | [
"python",
"xml"
] |
Crunching xml with python | 667,359 | <p>I need to remove white spaces between xml tags, e.g. if the original xml looks like:</p>
<pre><code><node1>
<node2>
<node3>foo</node3>
</node2>
</node1>
</code></pre>
<p>I'd like the end-result to be <em>crunched</em> down to single line:</p>
<pre><code><node... | 5 | 2009-03-20T18:22:30Z | 667,394 | <p>Not a solution really but since you asked for recommendations: I'd advise against doing your own parsing (unless you want to learn how to write a complex parser) because, as you say, not all spaces should be removed. There are not only CDATA blocks but also elements with the "xml:space=preserve" attribute, which co... | 2 | 2009-03-20T18:34:09Z | [
"python",
"xml"
] |
Crunching xml with python | 667,359 | <p>I need to remove white spaces between xml tags, e.g. if the original xml looks like:</p>
<pre><code><node1>
<node2>
<node3>foo</node3>
</node2>
</node1>
</code></pre>
<p>I'd like the end-result to be <em>crunched</em> down to single line:</p>
<pre><code><node... | 5 | 2009-03-20T18:22:30Z | 667,466 | <p>This is pretty easily handled with lxml (note: this particular feature isn't in ElementTree):</p>
<pre><code>from lxml import etree
parser = etree.XMLParser(remove_blank_text=True)
foo = """<node1>
<node2>
<node3>foo </node3>
</node2>
</node1>"""
bar = etree.X... | 8 | 2009-03-20T18:52:01Z | [
"python",
"xml"
] |
Crunching xml with python | 667,359 | <p>I need to remove white spaces between xml tags, e.g. if the original xml looks like:</p>
<pre><code><node1>
<node2>
<node3>foo</node3>
</node2>
</node1>
</code></pre>
<p>I'd like the end-result to be <em>crunched</em> down to single line:</p>
<pre><code><node... | 5 | 2009-03-20T18:22:30Z | 667,488 | <p><strong>Pretty straightforward with BeautifulSoup.</strong></p>
<p>This solution assumes it is ok to strip whitespace from the tail ends of character data.<br />
Example: <code><foo> bar </foo></code> becomes <code><foo>bar</foo></code></p>
<p>It will correctly ignore comments and CDATA.</p... | 4 | 2009-03-20T18:59:55Z | [
"python",
"xml"
] |
How to debug a weird threaded open fifo issue? | 667,500 | <p>A web service is configured to expose some of its data when receiving a USR1 signal. The signal will be sent by a xinetd server when it receives a request from a remote client, e.g. nc myserver 50666. When the web server receives USR1 signal, it opens a dedicated fifo pipe, writes its data to the pipe, and then clos... | 0 | 2009-03-20T19:01:14Z | 667,670 | <p>If you get two copies of splitter.py running at the same time, there will be trouble and almost anything that happens to you is legal. Try adding a process id value to webserver.py, ie:</p>
<p>pipe.write(str(os.getpid()) + i + '\n')</p>
<p>That might be illuminating.</p>
| 0 | 2009-03-20T19:40:18Z | [
"python",
"multithreading",
"stream",
"fifo",
"inetd"
] |
How to debug a weird threaded open fifo issue? | 667,500 | <p>A web service is configured to expose some of its data when receiving a USR1 signal. The signal will be sent by a xinetd server when it receives a request from a remote client, e.g. nc myserver 50666. When the web server receives USR1 signal, it opens a dedicated fifo pipe, writes its data to the pipe, and then clos... | 0 | 2009-03-20T19:01:14Z | 699,049 | <p>There isn't enough to debug here. You don't show how the server handles signals, or opens the pipe.</p>
<p>If at all possible I would recommend not using signals. They're hairy enough in C, nevermind with python's own peculiarities added on top.</p>
| 0 | 2009-03-30T21:13:25Z | [
"python",
"multithreading",
"stream",
"fifo",
"inetd"
] |
How to debug a weird threaded open fifo issue? | 667,500 | <p>A web service is configured to expose some of its data when receiving a USR1 signal. The signal will be sent by a xinetd server when it receives a request from a remote client, e.g. nc myserver 50666. When the web server receives USR1 signal, it opens a dedicated fifo pipe, writes its data to the pipe, and then clos... | 0 | 2009-03-20T19:01:14Z | 860,215 | <p>So the real problem is that there are multiple clients exist. The server has been queried/abused from other unknown clients which weren't initially being agreed with customers and sure it will break under the current design. A fix has been deployed to address the issue. So Andy's suspicion is right. Thanks guys! </p... | 0 | 2009-05-13T20:23:02Z | [
"python",
"multithreading",
"stream",
"fifo",
"inetd"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 667,520 | <p>A Token Bucket is fairly simple to implement.</p>
<p>Start with a bucket with 5 tokens.</p>
<p>Every 5/8 seconds: If the bucket has less than 5 tokens, add one.</p>
<p>Each time you want to send a message: If the bucket has â¥1 token, take one token out and send the message. Otherwise, wait/drop the message/what... | 19 | 2009-03-20T19:04:30Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 667,528 | <p>One solution is to attach a timestamp to each queue item and to discard the item after 8 seconds have passed. You can perform this check each time the queue is added to.</p>
<p>This only works if you limit the queue size to 5 and discard any additions whilst the queue is full.</p>
| 1 | 2009-03-20T19:07:15Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 667,568 | <p>Keep the time that the last five lines were sent. Hold the queued messages until the time the fifth-most-recent message (if it exists) is a least 8 seconds in the past (with last_five as an array of times):</p>
<pre><code>now = time.time()
if len(last_five) == 0 or (now - last_five[-1]) >= 8.0:
last_five.in... | 2 | 2009-03-20T19:18:10Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 667,706 | <p>Use this decorator @RateLimited(ratepersec) before your function that enqueues.</p>
<p>Basically, this checks if 1/rate secs have passed since the last time and if not, waits the remainder of the time, otherwise it doesn't wait. This effectively limits you to rate/sec. The decorator can be applied to any function y... | 34 | 2009-03-20T19:51:44Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 668,327 | <p>Here the <a href="http://en.wikipedia.org/wiki/Token_bucket">simplest algorithm</a>, if you want just to drop messages when they arrive too quickly (instead of queuing them, which makes sense because the queue might get arbitrarily large):</p>
<pre><code>rate = 5.0; // unit: messages
per = 8.0; // unit: seconds
al... | 152 | 2009-03-20T23:15:27Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 937,220 | <p>How about this:</p>
<pre><code>long check_time = System.currentTimeMillis();
int msgs_sent_count = 0;
private boolean isRateLimited(int msgs_per_sec) {
if (System.currentTimeMillis() - check_time > 1000) {
check_time = System.currentTimeMillis();
msgs_sent_count = 0;
}
if (msgs_sent... | 0 | 2009-06-01T22:58:49Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 6,415,181 | <p>to block processing until the message can be sent, thus queuing up further messages, antti's beautiful solution may also be modified like this:</p>
<pre><code>rate = 5.0; // unit: messages
per = 8.0; // unit: seconds
allowance = rate; // unit: messages
last_check = now(); // floating-point, e.g. usec accuracy. Un... | 8 | 2011-06-20T17:39:35Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 17,031,239 | <p>If someone still interested, I use this simple callable class in conjunction with a timed LRU key value storage to limit request rate per IP. Uses a deque, but can rewritten to be used with a list instead.</p>
<pre><code>from collections import deque
import time
class RateLimiter:
def __init__(self, maxRate=5... | 1 | 2013-06-10T19:23:38Z | [
"python",
"algorithm",
"message-queue"
] |
What's a good rate limiting algorithm? | 667,508 | <p>I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 second... | 93 | 2009-03-20T19:02:27Z | 40,034,562 | <p>I needed a variation in Scala. Here it is:</p>
<pre><code>case class Limiter[-A, +B](callsPerSecond: (Double, Double), f: A â B) extends (A â B) {
import Thread.sleep
private def now = System.currentTimeMillis / 1000.0
private val (calls, sec) = callsPerSecond
private var allowance = 1.0
private var... | 0 | 2016-10-14T03:39:42Z | [
"python",
"algorithm",
"message-queue"
] |
Is there a way to manually register a user with a py-transport server-side? | 667,510 | <p>I'm trying to write some scripts to migrate my users to ejabberd, but
the only way that's been suggested for me to register a user with a
transport is to have them use their client and discover the service.
Certainly there is a way, right? </p>
| 1 | 2009-03-20T19:02:48Z | 1,703,042 | <ol>
<li>Go through once for each transport
and register yourself. Capture the
XMPP packets. </li>
<li>Dump the transport
registration data from your current
system into a csv file, xml file, or
something else you can know the
structure.</li>
<li>Write a script
using jabberpy, xmpppy, pyxmpp, or
whatever, and emulate ... | 0 | 2009-11-09T19:02:43Z | [
"python",
"xmpp",
"ejabberd"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 667,554 | <p>In a unix environment, this is not generally possible...the best you can hope for is the command line as passed to your process.</p>
<p>Because the shell (essentially <em>any</em> shell) may munge the typed command line in several ways before handing it to the OS to for execution.</p>
| 11 | 2009-03-20T19:15:42Z | [
"python",
"command-line"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 667,556 | <p>You're too late. By the time that the typed command gets to Python your shell has already worked its magic. For example, quotes get consumed (as you've noticed), variables get interpolated, etc.</p>
| 22 | 2009-03-20T19:16:07Z | [
"python",
"command-line"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 667,754 | <h2>*nix</h2>
<p>Look at <a href="http://asm.sourceforge.net/articles/startup.html#st" rel="nofollow">the initial stack layout (Linux on i386) that provides access to command line and environment of a program</a>: the process sees only separate arguments.</p>
<p>You can't get the command-line <em>as it was typed</em>... | 4 | 2009-03-20T20:04:36Z | [
"python",
"command-line"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 667,889 | <p>As mentioned, this probably cannot be done, at least not reliably. In a few cases, you might be able to find a history file for the shell (e.g. - "bash", but not "tcsh") and get the user's typing from that. I don't know how much, if any, control you have over the user's environment.</p>
| 5 | 2009-03-20T20:40:46Z | [
"python",
"command-line"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 668,016 | <p>If you're on linux, I'd suggest monkeying with the ~/.bash_history or the shell history command, although I believe the command must finish executing before it's added to the shell history.</p>
<p>I started playing with:</p>
<pre><code>import popen2
x,y = popen2.popen4("tail ~/.bash_history")
print x.readlines()
<... | 1 | 2009-03-20T21:10:35Z | [
"python",
"command-line"
] |
Full command line as it was typed | 667,540 | <p>I want to get the full command line as it was typed. </p>
<p>This: </p>
<p><code>" ".join(sys.argv[:])</code> </p>
<p>doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and splited.</p>
<p>Any ideas? </p>
<p>Thank you in advance.</p>
| 13 | 2009-03-20T19:11:34Z | 668,518 | <p>On linux there is <code>/proc/<pid>/cmdline</code> that is in format of <code>argv[]</code> (ie. there is 0x00 between all the lines and you can't really know how many strings there are since you don't get the argc; though you will know it when the file runs out of data ;).</p>
<p>You can be sure that that co... | 0 | 2009-03-21T01:09:36Z | [
"python",
"command-line"
] |
How to tell if a connection is dead in python | 667,640 | <p>I want my python application to be able to tell when the socket on the other side has been dropped. Is there a method for this?</p>
| 27 | 2009-03-20T19:31:50Z | 667,666 | <p>If I'm not mistaken this is usually handled via a <a href="http://docs.python.org/library/socket.html" rel="nofollow">timeout</a>.</p>
| 3 | 2009-03-20T19:39:31Z | [
"python",
"sockets"
] |
How to tell if a connection is dead in python | 667,640 | <p>I want my python application to be able to tell when the socket on the other side has been dropped. Is there a method for this?</p>
| 27 | 2009-03-20T19:31:50Z | 667,702 | <p>From the link Jweede posted:</p>
<blockquote>
<p>exception socket.timeout:</p>
<pre><code>This exception is raised when a timeout occurs on a socket
which has had timeouts enabled via a prior call to settimeout().
The accompanying value is a string whose value is currently
always âtimed outâ.
</code></pre>
<... | 8 | 2009-03-20T19:50:20Z | [
"python",
"sockets"
] |
How to tell if a connection is dead in python | 667,640 | <p>I want my python application to be able to tell when the socket on the other side has been dropped. Is there a method for this?</p>
| 27 | 2009-03-20T19:31:50Z | 667,710 | <p>It depends on what you mean by "dropped". For TCP sockets, if the other end closes the connection either through
close() or the process terminating, you'll find out by reading an end of file, or getting a read error, usually the errno being set to whatever 'connection reset by peer' is by your operating system. ... | 17 | 2009-03-20T19:52:41Z | [
"python",
"sockets"
] |
How to tell if a connection is dead in python | 667,640 | <p>I want my python application to be able to tell when the socket on the other side has been dropped. Is there a method for this?</p>
| 27 | 2009-03-20T19:31:50Z | 15,175,067 | <p>Short answer:</p>
<blockquote>
<p>use a non-blocking recv(), or a blocking recv() / select() with a very
short timeout.</p>
</blockquote>
<p>Long answer:</p>
<p>The way to handle socket connections is to read or write as you need to, and be prepared to handle connection errors.</p>
<p>TCP distinguishes betwe... | 17 | 2013-03-02T13:35:25Z | [
"python",
"sockets"
] |
How do I create a D-Bus service that dynamically creates multiple objects? | 667,760 | <p>I'm new to D-Bus (and to Python, double whammy!) and I am trying to figure out the best way to do something that was discussed in the tutorial.</p>
<blockquote>
<p>However, a text editor application
could as easily own multiple bus names
(for example, org.kde.KWrite in
addition to generic TextEditor), have
... | 2 | 2009-03-20T20:05:24Z | 671,553 | <p>1) Mostly yes, I would only change one thing in the connect method as I explain in 2). </p>
<p>2) D-Bus connections are not persistent, everything is done with request/response messages, no connection state is stored unless you implement this in third objects as you do with your <code>flickerObject</code>. The d-bu... | 2 | 2009-03-22T20:17:20Z | [
"python",
"dbus"
] |
Can someone explain Gtk2 packing? | 668,226 | <p>I need to use Gtk2 for a project. I will be using python/ruby for it. The problem is that packing seems kind of mystical to me. I tried using a VBox so that I could have the following widgets in my window ( in the following order ):</p>
<ul>
<li>menubar</li>
<li>toolbar</li>
<li>text view/editor control</li>
</ul>
... | 2 | 2009-03-20T22:24:32Z | 669,033 | <p>Box packing is <em>really</em> simple, so perhaps your failure to understand it is because you imagine it is more complicated than it is.</p>
<p>Layout is either Vertical (like a pile of bricks) or horizontal (like a queue of people). Each element in that layout can expand or it can not expand.</p>
<p>Horizontal (... | 14 | 2009-03-21T09:29:09Z | [
"python",
"ruby",
"pygtk",
"packing",
"gtk2"
] |
Alternatives to ffmpeg as a cli tools for video still extraction? | 668,240 | <p>I need to extract stills from video files. Currently I am using ffmpeg, but I am looking for a simpler tool and for a tool that my collegues can just install. No need to compile it from a svn checkout.</p>
<p>Any hints? A python interface would be nice.</p>
| 1 | 2009-03-20T22:31:43Z | 668,582 | <p>Your requirements "cli tool" and "python interface" aren't entirely compatible. Which do you want?</p>
<p>The following media libraries all have Python bindings: <a href="http://www.gstreamer.org/" rel="nofollow">GStreamer</a>, <a href="http://www.videolan.org/" rel="nofollow">libVLC</a> (<a href="http://code.goog... | 1 | 2009-03-21T01:58:31Z | [
"python"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,486 | <p>I'm not sure I'm understanding your question, so I'll give multiple partial answers to start with.</p>
<ul>
<li>If your concern is that web.py is having to download data from somewhere and analyze the results before responding, and you fear the request may time out before the results are ready, you could use ajax t... | 0 | 2009-03-21T00:39:24Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,495 | <p>I don't know if this will exactly work, but it looks like it might: <a href="http://code.google.com/p/evserver/" rel="nofollow">EvServer: Python Asynchronous WSGI Server</a> has a <a href="http://code.google.com/p/evserver/source/browse/trunk/evserver/examples/framework%5Fwebpy.py" rel="nofollow">web.py interface</a... | 0 | 2009-03-21T00:53:59Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,665 | <p>Along the lines of MarkusQ's answer, <a href="http://mochikit.com/" rel="nofollow">MochiKit</a> is a nice JavaScript library, with robust async methods inspired by Twisted.</p>
| 0 | 2009-03-21T03:08:26Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,723 | <p>Actually you can integrate twisted with web.py. I'm not really sure how as I've only done it with django (used twisted with it).</p>
| 0 | 2009-03-21T04:09:41Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,765 | <p>One option would be to post the work onto a queue of some sort (you could use something Enterprisey like <a href="http://activemq.apache.org/" rel="nofollow">ActiveMQ</a> with <a href="http://code.google.com/p/pyactivemq/" rel="nofollow">pyactivemq</a> or <a href="http://stomp.codehaus.org/" rel="nofollow">STOMP</a>... | 4 | 2009-03-21T05:02:48Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 668,772 | <p>I'd just build a service in twisted that did that concurrent fetch and analysis and access that from web.py as a simple http request.</p>
| 2 | 2009-03-21T05:11:00Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 2,697,141 | <p>Use the async http client which uses asynchat and asyncore.
<a href="http://sourceforge.net/projects/asynchttp/files/asynchttp-production/asynchttp.py-1.0/asynchttp.py/download" rel="nofollow">http://sourceforge.net/projects/asynchttp/files/asynchttp-production/asynchttp.py-1.0/asynchttp.py/download</a></p>
| 2 | 2010-04-23T08:24:40Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 2,697,314 | <p>You might be able to use <a href="http://docs.python.org/library/urllib.html" rel="nofollow"><code>urllib</code></a> to download the files and the <a href="http://docs.python.org/library/queue.html" rel="nofollow"><code>Queue</code></a> module to manage a number of worker threads. e.g:</p>
<pre><code>import urllib
... | 3 | 2010-04-23T08:56:24Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 4,483,862 | <p>Here is an interesting piece of code. I didn't use it myself, but it looks nice ;)</p>
<p><a href="https://github.com/facebook/tornado/blob/master/tornado/httpclient.py">https://github.com/facebook/tornado/blob/master/tornado/httpclient.py</a></p>
<p>Low level AsyncHTTPClient:</p>
<p>"An non-blocking HTTP client ... | 6 | 2010-12-19T16:31:56Z | [
"python",
"asynchronous"
] |
Python: simple async download of url content? | 668,257 | <p>I have a web.py server that responds to various user requests. One of these requests involves downloading and analyzing a series of web pages. </p>
<p>Is there a simple way to setup an async / callback based url download mechanism in web.py? Low resource usage is particularly important as each user initiated reques... | 9 | 2009-03-20T22:40:42Z | 9,017,195 | <p>Nowadays there are excellent Python libs you might want to use - <a href="http://urllib3.readthedocs.org/" rel="nofollow">urllib3</a> (uses thread pools) and <a href="http://docs.python-requests.org/" rel="nofollow">requests</a> (uses thread pools through urllib3 or non blocking IO through <a href="http://www.gevent... | 2 | 2012-01-26T11:05:13Z | [
"python",
"asynchronous"
] |
Programmatic login and use of non-api-supported Google services | 668,350 | <p>Google provides APIs for a number of their services and bindings for several languages. However, not everything is supported. So this question comes from my incomplete understanding of things like wget, curl, and the various web programming libraries.</p>
<ol>
<li><p>How can I authenticate programmatically to Googl... | 4 | 2009-03-20T23:25:41Z | 668,381 | <p>You can use something like mechanize, or even urllib to achieve this sort of thing. As a tutorial, you can check out my article <a href="http://ssscripting.wordpress.com/2009/03/17/how-to-submit-a-form-programmatically/" rel="nofollow">here</a> about programmatically submitting a form .
Once you authenticate, you ca... | 1 | 2009-03-20T23:46:27Z | [
"python",
"curl",
"gdata-api"
] |
Programmatic login and use of non-api-supported Google services | 668,350 | <p>Google provides APIs for a number of their services and bindings for several languages. However, not everything is supported. So this question comes from my incomplete understanding of things like wget, curl, and the various web programming libraries.</p>
<ol>
<li><p>How can I authenticate programmatically to Googl... | 4 | 2009-03-20T23:25:41Z | 668,872 | <p>You can get the auth tokens by authenticating a particular service against https://www.google.com/accounts/ClientLogin</p>
<p>E.g.</p>
<pre><code>curl -d "Email=youremail" -d "Passwd=yourpassword" -d "service=blogger" "https://www.google.com/accounts/ClientLogin"
</code></pre>
<p>Then you can just pass the auth t... | 1 | 2009-03-21T06:44:20Z | [
"python",
"curl",
"gdata-api"
] |
Programmatic login and use of non-api-supported Google services | 668,350 | <p>Google provides APIs for a number of their services and bindings for several languages. However, not everything is supported. So this question comes from my incomplete understanding of things like wget, curl, and the various web programming libraries.</p>
<ol>
<li><p>How can I authenticate programmatically to Googl... | 4 | 2009-03-20T23:25:41Z | 10,834,881 | <p>CLientLogin is now deprecated: <a href="https://developers.google.com/accounts/docs/AuthForInstalledApps" rel="nofollow">https://developers.google.com/accounts/docs/AuthForInstalledApps</a></p>
<p>How can we authenticate programmatically to Google with OAuth2?</p>
<p>I can't find an expample of request with user a... | 0 | 2012-05-31T13:43:46Z | [
"python",
"curl",
"gdata-api"
] |
Unicode fonts in PyGame | 668,359 | <p>How can I display Chinese characters in PyGame? And what's a good free/libre font to use for this purpose?</p>
| 8 | 2009-03-20T23:33:33Z | 668,592 | <p>As far as I'm awareâââand I haven't tried it myselfâââPyGame should Just Work when you pass it a Unicode string containing Chinese characters, eg. u'\u4e2d\u56fd'.</p>
<p>See âEast Asiaâ under <a href="http://www.unifont.org/fontguide/" rel="nofollow">http://www.unifont.org/fontguide/</a> for quite ... | 0 | 2009-03-21T02:08:56Z | [
"python",
"unicode",
"pygame",
"cjk"
] |
Unicode fonts in PyGame | 668,359 | <p>How can I display Chinese characters in PyGame? And what's a good free/libre font to use for this purpose?</p>
| 8 | 2009-03-20T23:33:33Z | 668,596 | <p>pygame uses SDL_ttf for rendering, so you should be in fine shape as rendering goes.</p>
<p><a href="http://www.unifont.org/fontguide/" rel="nofollow">unifont.org</a> appears to have some extensive resources on Open-Source fonts for a range of scripts.</p>
<p>I grabbed the Cyberbit pan-unicode font and extracted t... | 7 | 2009-03-21T02:10:27Z | [
"python",
"unicode",
"pygame",
"cjk"
] |
Why is Beautiful Soup truncating this page? | 668,591 | <p>I am trying to pull at list of resource/database names and IDs from a listing of resources that my school library has subscriptions to. There are pages listing the different resources, and I can use urllib2 to get the pages, but when I pass the page to BeautifulSoup, it truncates its tree just before the end of the... | 2 | 2009-03-21T02:08:30Z | 668,717 | <p>If I remember correctly, BeautifulSoup uses "name" in it's tree as the name of the tag. In this case "a" would be the "name" of the anchor tag.</p>
<p>That doesn't seem like it should break it though. What version of Python and BS are you using?</p>
| 0 | 2009-03-21T03:59:26Z | [
"python",
"screen-scraping",
"beautifulsoup"
] |
Why is Beautiful Soup truncating this page? | 668,591 | <p>I am trying to pull at list of resource/database names and IDs from a listing of resources that my school library has subscriptions to. There are pages listing the different resources, and I can use urllib2 to get the pages, but when I pass the page to BeautifulSoup, it truncates its tree just before the end of the... | 2 | 2009-03-21T02:08:30Z | 668,867 | <p>I was using Firefox's "view selection source", which apparently cleans up the HTML for me. When I viewed the original source, this is what I saw</p>
<pre><code><img name="myImageXYZ00618" id="myImageXYZ00618" src='http://www2.lib.myschool.edu:7017/INS01/icon_eng/v-add_favorite.png' alt='Add to My Sets' title='A... | 2 | 2009-03-21T06:34:15Z | [
"python",
"screen-scraping",
"beautifulsoup"
] |
Why is Beautiful Soup truncating this page? | 668,591 | <p>I am trying to pull at list of resource/database names and IDs from a listing of resources that my school library has subscriptions to. There are pages listing the different resources, and I can use urllib2 to get the pages, but when I pass the page to BeautifulSoup, it truncates its tree just before the end of the... | 2 | 2009-03-21T02:08:30Z | 674,849 | <p>I strongly recommend using html5lib + lxml instead of beautiful soup. It uses a real HTML parser (very similar to the one in Firefox) and lxml provides a very flexible way to query the resulting tree (css-selectors or xpath).</p>
<p>There are tons of bugs or strange behavior in BeautifulSoup which makes it not the... | 2 | 2009-03-23T19:19:48Z | [
"python",
"screen-scraping",
"beautifulsoup"
] |
Why is Beautiful Soup truncating this page? | 668,591 | <p>I am trying to pull at list of resource/database names and IDs from a listing of resources that my school library has subscriptions to. There are pages listing the different resources, and I can use urllib2 to get the pages, but when I pass the page to BeautifulSoup, it truncates its tree just before the end of the... | 2 | 2009-03-21T02:08:30Z | 19,749,734 | <p>You can try beautiful soup with html5lib rather than the built-in parser.</p>
<pre><code>BeautifulSoup(markup, "html5lib")
</code></pre>
<p>html5lib is more lenient and often parses pages that the built-in parser truncates. See the docs at <a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/#searching-th... | 2 | 2013-11-03T04:09:12Z | [
"python",
"screen-scraping",
"beautifulsoup"
] |
Problem Extending Python(Linking Error )? | 668,971 | <p>I have installed Python 3k(C:\Python30) and Visual Studio Professional Edition 2008.</p>
<p>I'm studying <strong><a href="http://en.wikibooks.org/wiki/Python%5FProgramming/Extending%5Fwith%5FC" rel="nofollow">this</a>.</strong></p>
<p>Here is a problem:</p>
<pre><code>C:\hello>dir
Volume in drive C has no lab... | 1 | 2009-03-21T08:23:00Z | 668,974 | <p>If Python is installed in <code>c:\python30</code>, why are you searching for the libraries in <code>c:\Python24\libs\python30</code>?</p>
<p>And now that you've changed the question to fix this :-),</p>
<p>I don't think <code>Py_InitModule</code> is available any more, you have to use <code>PyModule_Create</code>... | 2 | 2009-03-21T08:27:59Z | [
"python",
"c",
"visual-studio",
"visual-studio-2008",
"linker"
] |
Why GQL Query does not match? | 669,043 | <p>What I want to do is build some mini cms which hold pages with a uri.</p>
<p>The last route in my urls.py points to a function in my views.py, which checks in the datastore if there's a page available with the same uri of the current request, and if so show the page.</p>
<p>I have a model: </p>
<pre><code>class P... | 1 | 2009-03-21T09:37:24Z | 669,062 | <p>If you use named keyword arguments ("uri=:uri"), you have to explicitly bind your parameters to the named keyword. Instead of:</p>
<pre><code># incorrect named parameter
GqlQuery('SELECT * FROM Page WHERE uri=:uri', request.path).get()
</code></pre>
<p>you want</p>
<pre><code># correct named parameter
GqlQuery('S... | 2 | 2009-03-21T09:59:51Z | [
"python",
"google-app-engine",
"gae-datastore"
] |
Why GQL Query does not match? | 669,043 | <p>What I want to do is build some mini cms which hold pages with a uri.</p>
<p>The last route in my urls.py points to a function in my views.py, which checks in the datastore if there's a page available with the same uri of the current request, and if so show the page.</p>
<p>I have a model: </p>
<pre><code>class P... | 1 | 2009-03-21T09:37:24Z | 669,704 | <p>I've found the solution!</p>
<p>The problem lies in the model. </p>
<p>App engines datastore does not index a TextProperty. Using that type was wrong from the beginning, so i changed it to StringProperty, which does get indexed, and thus which datastore allows us to use in a WHERE clause.</p>
<p>Example of workin... | 4 | 2009-03-21T18:16:25Z | [
"python",
"google-app-engine",
"gae-datastore"
] |
How can I change the display text of a MenuItem in Gtk2? | 669,152 | <p>I need to change the display text of a MenuItem. Is there any way of doing this without removing the MenuItem and then adding another one with a different text?</p>
| 2 | 2009-03-21T11:28:47Z | 669,426 | <p>It somewhat depends how you created the menu item, since a MenuItem is a container that can contain anything. If you created it like:</p>
<pre><code>menuitem = gtk.MenuItem('This is the label')
</code></pre>
<p>Then you can access the label widget in the menu item with:</p>
<pre><code>label = menuitem.child
</cod... | 3 | 2009-03-21T15:03:39Z | [
"python",
"gtk",
"pygtk"
] |
Encoding of string returned by GetUserName() | 669,770 | <p>How do I get the encoding that is used for the string returned by <code>GetUserName</code> from the win32 API? I'm using pywin32 and it returns an 8-bit string. On my German XP, this string is obviously encoded using Latin-1, but this might not be the case for other Windows installations.</p>
<p>I could use <code>G... | 1 | 2009-03-21T18:51:08Z | 669,789 | <p>From the API docs, GetUserNameA will return the name in ANSI and GetUserNameW returns the name in Unicode. You will have to use GetUserNameW.</p>
| 0 | 2009-03-21T19:09:16Z | [
"python",
"winapi",
"encoding",
"pywin32"
] |
Encoding of string returned by GetUserName() | 669,770 | <p>How do I get the encoding that is used for the string returned by <code>GetUserName</code> from the win32 API? I'm using pywin32 and it returns an 8-bit string. On my German XP, this string is obviously encoded using Latin-1, but this might not be the case for other Windows installations.</p>
<p>I could use <code>G... | 1 | 2009-03-21T18:51:08Z | 669,790 | <p>You can call <a href="http://msdn.microsoft.com/en-us/library/dd318070%28VS.85%29.aspx">GetACP</a> to find the current ANSI codepage, which is what non-Unicode APIs use. You can also use <a href="http://msdn.microsoft.com/en-us/library/bb202786.aspx">MultiByteToWideChar</a>, and pass zero as the codepage (CP_ACP is ... | 5 | 2009-03-21T19:09:41Z | [
"python",
"winapi",
"encoding",
"pywin32"
] |
Encoding of string returned by GetUserName() | 669,770 | <p>How do I get the encoding that is used for the string returned by <code>GetUserName</code> from the win32 API? I'm using pywin32 and it returns an 8-bit string. On my German XP, this string is obviously encoded using Latin-1, but this might not be the case for other Windows installations.</p>
<p>I could use <code>G... | 1 | 2009-03-21T18:51:08Z | 669,791 | <p>I realize this isn't answering your question directly, but I <em>strongly</em> recommend you go through the trouble of using the Unicode-clean <code>GetUserNameW</code> as you mentioned.</p>
<p>The non-wide commands work differently on different Windows editions (e.g. ME, although I admit that example is old!), so ... | 4 | 2009-03-21T19:09:53Z | [
"python",
"winapi",
"encoding",
"pywin32"
] |
Encoding of string returned by GetUserName() | 669,770 | <p>How do I get the encoding that is used for the string returned by <code>GetUserName</code> from the win32 API? I'm using pywin32 and it returns an 8-bit string. On my German XP, this string is obviously encoded using Latin-1, but this might not be the case for other Windows installations.</p>
<p>I could use <code>G... | 1 | 2009-03-21T18:51:08Z | 670,979 | <p>Okay, here's what I'm using right now:</p>
<pre><code>>>> import win32api
>>> u = unicode(win32api.GetUserName(), "mbcs")
>>> type(u)
<type 'unicode'>
</code></pre>
<p><code>mbcs</code> is a special <a href="http://docs.python.org/dev/2.5/lib/standard-encodings.html" rel="nofollow"... | 3 | 2009-03-22T13:05:37Z | [
"python",
"winapi",
"encoding",
"pywin32"
] |
Pagination of Date-Based Generic Views in Django | 669,903 | <p>I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?</p>
| 3 | 2009-03-21T20:08:56Z | 670,763 | <p>Date based generic views don't have pagination. It seems you can't add pagination via wrapping them as well since they return rendered result.</p>
<p>I would simply write my own view in this case. You can check out generic views' code as well, but most of it will probably be unneeded in your case.</p>
<p>Since you... | 1 | 2009-03-22T09:35:00Z | [
"python",
"django",
"pagination"
] |
Pagination of Date-Based Generic Views in Django | 669,903 | <p>I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?</p>
| 3 | 2009-03-21T20:08:56Z | 905,480 | <p>I created a template tag to do template-based pagination on collections passed to the templates that aren't already paginated. Copy the following code to an <code>app/templatetags/pagify.py</code> file.</p>
<pre><code>from django.template import Library, Node, Variable
from django.core.paginator import Paginator
i... | 3 | 2009-05-25T05:50:15Z | [
"python",
"django",
"pagination"
] |
Pagination of Date-Based Generic Views in Django | 669,903 | <p>I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?</p>
| 3 | 2009-03-21T20:08:56Z | 905,880 | <p>I was working on a problem similar to this yesterday, and I found the best solution for me personally was to use the object_list generic view for all date-based pages, but pass a filtered queryset, as follows:</p>
<pre><code>import datetime, time
def post_archive_month(request, year, month, page=0, template_name='... | 1 | 2009-05-25T08:33:50Z | [
"python",
"django",
"pagination"
] |
Pagination of Date-Based Generic Views in Django | 669,903 | <p>I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?</p>
| 3 | 2009-03-21T20:08:56Z | 1,416,244 | <p>Django date-based generic views do not support pagination. There is an <a href="http://code.djangoproject.com/ticket/2367" rel="nofollow">open ticket from 2006</a> on this. If you want, you can try out the code patches supplied to implement this feature. I am not sure why the patches have not been applied to the cod... | 0 | 2009-09-12T21:50:22Z | [
"python",
"django",
"pagination"
] |
Pagination of Date-Based Generic Views in Django | 669,903 | <p>I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?</p>
| 3 | 2009-03-21T20:08:56Z | 2,798,212 | <p>There is also excellent <a href="http://code.google.com/p/django-pagination/" rel="nofollow">django-pagination</a> add-on, which is completely independent of underlying view.</p>
| 1 | 2010-05-09T15:55:12Z | [
"python",
"django",
"pagination"
] |
How to create a class that doesn't re-create an object with identical input parameters | 669,932 | <p>I am trying to create a class that doesn't re-create an object with the same input parameters. When I try to instantiate a class with the same parameters that were used to create an already-existing object, I just want my new class to return a pointer to the already-created (expensively-created) object. This is wh... | 2 | 2009-03-21T20:24:02Z | 669,941 | <p>First, use Upper Case Class Names in Python.</p>
<p>Second, use a <strong>Factory</strong> design pattern to solve this problem.</p>
<pre><code>class MyObject( object ):
def __init__( self, args ):
pass # Something Expensive
class MyObjectFactory( object ):
def __init__( self ):
self.pool ... | 8 | 2009-03-21T20:31:15Z | [
"python",
"multiton"
] |
How to create a class that doesn't re-create an object with identical input parameters | 669,932 | <p>I am trying to create a class that doesn't re-create an object with the same input parameters. When I try to instantiate a class with the same parameters that were used to create an already-existing object, I just want my new class to return a pointer to the already-created (expensively-created) object. This is wh... | 2 | 2009-03-21T20:24:02Z | 7,493,603 | <p>Here's a class decorator to make a class a multiton:</p>
<pre><code>def multiton(cls):
instances = {}
def getinstance(id):
if id not in instances:
instances[id] = cls(id)
return instances[id]
return getinstance
</code></pre>
<p>(This is a slight variant of the singleton decorator fr... | 10 | 2011-09-21T01:27:16Z | [
"python",
"multiton"
] |
Partial Upload With storbinary in python | 670,084 | <p>I've written some python code to download an image using </p>
<pre><code>urllib.urlopen().read()
</code></pre>
<p>and then upload it to an FTP site using </p>
<pre><code>ftplib.FTP().storbinary()
</code></pre>
<p>but I'm having a problem. Sometimes the image file is only partially uploaded, so I get images with ... | 1 | 2009-03-21T22:02:27Z | 670,567 | <p>It turns out I was not closing the downloaded file correctly. Let's all pretend this never happened.</p>
| 0 | 2009-03-22T04:52:53Z | [
"python",
"ftp",
"ftplib"
] |
Partial Upload With storbinary in python | 670,084 | <p>I've written some python code to download an image using </p>
<pre><code>urllib.urlopen().read()
</code></pre>
<p>and then upload it to an FTP site using </p>
<pre><code>ftplib.FTP().storbinary()
</code></pre>
<p>but I'm having a problem. Sometimes the image file is only partially uploaded, so I get images with ... | 1 | 2009-03-21T22:02:27Z | 4,589,462 | <p>It's been a while since I looked at this code, but I remember the crux of it was that I was not closing the downloaded file correctly. I have the working code though, so just in case it was a problem with the upload and not the download, here are both snippets:</p>
<p>Here is the working code to download the image:... | 0 | 2011-01-03T23:47:05Z | [
"python",
"ftp",
"ftplib"
] |
Unable to find files/folders with permissions 777 by AWK/SED/Python | 670,269 | <p><strong>Problems</strong></p>
<ol>
<li><p>to get permissions
of each file in every folder</p></li>
<li><p>to find files
which have 777 permissions, and then
print the filenames with their paths
to a list</p></li>
</ol>
<p>We can get permissions for files in one folder by </p>
<pre><code>ls -ls
</code></pre>
<p>I... | 0 | 2009-03-21T23:55:39Z | 670,283 | <p>Are you looking for <code>find</code>?</p>
<pre><code>find /some/path -perm 0777
</code></pre>
| 6 | 2009-03-22T00:05:57Z | [
"python",
"sed",
"awk"
] |
Unable to find files/folders with permissions 777 by AWK/SED/Python | 670,269 | <p><strong>Problems</strong></p>
<ol>
<li><p>to get permissions
of each file in every folder</p></li>
<li><p>to find files
which have 777 permissions, and then
print the filenames with their paths
to a list</p></li>
</ol>
<p>We can get permissions for files in one folder by </p>
<pre><code>ls -ls
</code></pre>
<p>I... | 0 | 2009-03-21T23:55:39Z | 671,191 | <p>find /some/path -perm 0777 -type f</p>
| 4 | 2009-03-22T15:43:47Z | [
"python",
"sed",
"awk"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 670,402 | <p>This may help you:</p>
<p><a href="http://www.marcworrell.com/article-2990-en.html" rel="nofollow">http://www.marcworrell.com/article-2990-en.html</a></p>
<p>It's php so should be pretty straightforward to set up on your dev server.</p>
<p>I've tried this one once:</p>
<p><a href="http://term.ie/oauth/example/" ... | 1 | 2009-03-22T01:42:42Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 670,608 | <p>Two things:</p>
<ol>
<li><p>The OAuth Service Provider in question is violating the OAuth spec if it's giving you an error if you don't specify a callback URL. callback_url is <a href="http://oauth.net/core/1.0/#auth%5Fstep2">spec'd to be an OPTIONAL parameter</a>.</p></li>
<li><p>But, pedantry aside, you probably ... | 16 | 2009-03-22T06:15:23Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 2,953,681 | <p>localtunnel [port] and voila</p>
<p><a href="http://blogrium.wordpress.com/2010/05/11/making-a-local-web-server-public-with-localtunnel/" rel="nofollow">http://blogrium.wordpress.com/2010/05/11/making-a-local-web-server-public-with-localtunnel/</a></p>
<p><a href="http://github.com/progrium/localtunnel" rel="nofol... | 0 | 2010-06-01T21:59:59Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 3,117,885 | <p>You could create 2 applications? 1 for deployment and the other for testing. </p>
<p>Alternatively, you can also include an oauth_callback parameter when you requesting for a request token. Some providers will redirect to the url specified by oauth_callback (eg. Twitter, Google) but some will ignore this callback u... | 0 | 2010-06-25T12:17:48Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 7,971,246 | <p>This was with the Facebook OAuth - I actually <em>was</em> able to specify 'http://127.0.0.1:8080' as the Site URL and the callback URL. It took several minutes for the changes to the Facebook app to propagate, but then it worked.</p>
| 2 | 2011-11-01T18:40:58Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 12,107,449 | <p>In case you are using *nix style system, create a alias like <code>127.0.0.1 mywebsite.dev</code> in <code>/etc/hosts</code> (you need have the line which is similar to above mentioned in the file, Use <code>http://website.dev/callbackurl/for/app</code> in call back URL and during local testing. </p>
| 8 | 2012-08-24T10:16:18Z | [
"python",
"oauth"
] |
How do I develop against OAuth locally? | 670,398 | <p>I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?</p>
| 32 | 2009-03-22T01:37:13Z | 15,788,200 | <p>So how I solved this issue (using BitBucket's OAuth interface) was by specifying the callback URL to localhost (or whatever the hell you want really), and then following the authorisation URL with curl, but with the twist of only returning the HTTP header. Example:</p>
<pre><code>curl --user BitbucketUsername:Bitbu... | 0 | 2013-04-03T13:06:46Z | [
"python",
"oauth"
] |
Asynchronous File Upload to Amazon S3 with Django | 670,442 | <p>I am using this file storage engine to store files to Amazon S3 when they are uploaded:</p>
<p><a href="http://code.welldev.org/django-storages/wiki/Home">http://code.welldev.org/django-storages/wiki/Home</a></p>
<p>It takes quite a long time to upload because the file must first be uploaded from client to web ser... | 32 | 2009-03-22T02:29:32Z | 671,047 | <p>You could decouple the process:</p>
<ul>
<li>the user selects file to upload and sends it to your server. After this he sees a page "Thank you for uploading foofile.txt, it is now stored in our storage backend"</li>
<li>When the users has uploaded the file it is stored temporary directory on your server and, if nee... | 6 | 2009-03-22T14:01:38Z | [
"python",
"django",
"amazon-s3"
] |
Asynchronous File Upload to Amazon S3 with Django | 670,442 | <p>I am using this file storage engine to store files to Amazon S3 when they are uploaded:</p>
<p><a href="http://code.welldev.org/django-storages/wiki/Home">http://code.welldev.org/django-storages/wiki/Home</a></p>
<p>It takes quite a long time to upload because the file must first be uploaded from client to web ser... | 32 | 2009-03-22T02:29:32Z | 671,255 | <p>I've taken another approach to this problem.</p>
<p>My models have 2 file fields, one uses the standard file storage backend and the other one uses the s3 file storage backend. When the user uploads a file it get's stored localy.</p>
<p>I have a management command in my application that uploads all the localy stor... | 23 | 2009-03-22T16:35:38Z | [
"python",
"django",
"amazon-s3"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.