Hi there,
I saved some plots from matplotlib into a pdf format because it seems to offer a better quality. How do I include the PDF image into a PDF document using ReportLab? The convenience method Image(filepath) does not work for this format.
Thank you.
...
Edited post
I'm not able to read the configuration file sections that contain []... for e.g if any section in ini file is something like [c:\\temp\\foo[1].txt] than my script fails to read that section..
config.read(dst_bkp)
for i in config.sections():
config.get(i,'FileName')
Thanks,
Vignesh
...
I am using Pyton 2.7 as this seems to be only Python MSI downloadable at the moment from Python.org.
self.redirect(users.create_login_url(self.request.uri)) fails when running on dev_appserver
localhost:8081/_ah/login?continue=http%3A//localhost%3A8081/ returns a 500.
Although this does work: localhost:8081/_ah/admin/datastore
Stack...
Hello,
Suppose the following:
def MyFunc(a):
if a < 0:
return None
return (a+1, a+2, a+3)
v1, v2, v3 = MyFunc()
# Bad ofcourse, if the result was None
What is the best way to define a function that returns a tuple and yet can be nicely called. Currently, I could do this:
r = MyFunc()
if r:
v1, v2, v3 = r
else:
# bad!!
...
Hi guys, Django newbie here
I know that I can change the encoding of a table by writing my own south migration.
My question is, is there a way doing it by changing my model and using
./manage.py schemamigration my_app --auto
?
...
I'm attempting to get a set of list items from sharepoint via the WebService. I want to query a small subset of items to be returned. My SOAP packet appears to be ordered properly, however, it still appears that the service is ignoring my set filter(query). Any ideas why this would still be happening?
<SOAP-ENV:Envelope xmlns:ns0="ht...
Hi,
My python daemon runs fine in the foreground of my Ubuntu system using this command in the terminal:
python /opt/my-daemon.py foreground
However when I try to call the daemon using the "start" command it fails, why?
python /opt/my-daemon.py start
This is how I call the command in the /etc/rc.local file:
python /opt/my-d...
Here is the code I have thus far:
import email, imaplib
user = 'some username'
pwd = 'some password'
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user, pwd)
m.select("[Gmail]/All Mail")
resp, data = m.fetch(1, "(RFC822)")
email_body = data[0][1]
mail = email.message_from_string(email_body)
print mail
I currently receive the ...
I'm writing a custom template tag 'firstnotnone', similar to the 'firstof' template tag of Django. How to use variable length arguments? The code below results in TemplateSyntaxError, firstnotnone takes 1 arguments.
Template:
{% load library %}
{% firstnotnone 'a' 'b' 'c' %}
Custom template tag library:
@register.simple_tag
def firs...
Hi everyone,
I have this simple python expression:
fscript.write (("update %s va set %s = %s where %s = %s;") % (argv[1],argv[2],vl[0],argv[3],vl[1]))
And I would expect to receive output like this
update some_table va set active_id = 1 where id = 5;
update some_table va set active_id = 1 where id = 3;
...more lines...
However, i'...
Hi,
I am doing a text search in a rather big txt file (100k lines, 7mo)
Text is not that big but I need a lot of searches.
I want to look for a target string and return the line where it appears.
My text file is formatted so that the target can only appear in one line.
What is the most efficient way? I do a lot of searches so I want to...
I am trying to understand the Python "ctypes" module. I have put together a trivial example that -- ideally -- wraps the statvfs() function call. The code looks like this:
from ctypes import *
class struct_statvfs (Structure):
_fields_ = [
('f_bsize', c_ulong),
('f_frsize', c_ulong),
('f_blocks...
How to decode the values from request from django FW.
GET:<QueryDict: {}>,
POST:<QueryDict: {u'objarrid': [u'1035', u'1036', u'1037', u'1038', u'1039', u'1040', u'1041', u'1042']}>,
def get_data(request):
try:
if request.method == 'GET':
r_c = request.GET
elif request.method == 'POST':
r_c = request.POST
except:...
anyone using nagare framework on google app engine ?
it seems interesting, but i could not find any documentaiton on how to use it on
google app engine, as it uses stackless python.
so any chances of its running on google app engine ?
also, how stack less python differ from normal python ?
thanks.
links :
Nagare Framework
Stackl...
Writing a script to retrieve logfiles from one server to NAS i need to determine if sth is a file or a directory.
Does anybody know a simple way to determine if an element of ftp.nlst() is a file or a directory??
Thanks in advance
...
I've got the following code:
for f in fileListProtocol.files:
if f['filetype'] == '-':
filename = os.path.join(directory['filename'], f['filename'])
print 'Downloading %s...' % (filename)
newFile = open(filename, 'w+')
d = ftpClient.retrieveFile(filename, FileConsumer(newFile))
d.addCallback(c...
Surprisingly I've been unable to find anyone else really doing this, but surely someone has. I'm working on a python project currently that involves spell checking some 16 thousand words. That number of words is only going to grow unfortunately. Right now I'm pulling words from Mongo, iterating through them, and then spell checking them ...
So im working with redis in a python app. any advice on key management? i try and keep all redis calls in one location but something seems off with hardcoding keys everywhere. tips?
...
Hello,
In my Django web app, an event's status changes from 'upcoming' to 'completed' at a certain date/time. However, I want to update the database as soon as the event object's date/time has passed. Any ideas how I would code this?
My only idea so far is to have a thread constantly running that that checks to see if the event object'...
Over time I found the need to override several stdlib methods from Python in order to overcome limitation or to add some missing functionality.
In all cases I added a wrapper function and replaced the original method from the module with my wrapper (the wrapper was calling the original method).
Why I did this? Just to be sure that al...