I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like to make them editable. Something similar to what happens in WordPress.
Is this possible...
I'm trying to overwrite a directory with another directory that contains the same files.
I've tried using distutils.dir_util.copy_tree(src, dst) but it tried to make a directory for dst instead.
The objective is to overwrite the directory and its contents silently.
Is there any other way to do so?
...
My work place has imposed a rules for no use of exception (catching is allowed). If I have code like this
def f1()
if bad_thing_happen():
raise Exception('bad stuff')
...
return something
I could change it to
def f1()
if bad_thing_happen():
return [-1, None]
...
return [0, something]
f1 caller would be like this
d...
I read many files from my system. I want to read them faster, maybe like this:
results=[]
for file in open("filenames.txt").readlines():
results.append(open(file,"r").read())
I don't want to use threading. Any advice is appreciated.
the reason why i don't want to use threads is because it will make my code unreadable,i want to fi...
I just installed and configured Celery with RabbitMQ for a Django project and I was having an issue running tasks when I imported them like so:
from someapp.tasks import SomeTask
It worked when I added the project name:
from myproject.someapp.tasks import SomeTask
I tried adding this into the settings.py file but it doesn't change ...
so I have a handler below:
class PublishHandler(BaseHandler):
def post(self):
message = self.get_argument("message")
some_function(message)
self.write("success")
The problem that I'm facing is that some_function() takes some time to execute and I would like the post request to return straight away when cal...
If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.
...
I have a = [1,2,3,4] and I want d = {1:0, 2:0, 3:0, 4:0}
d = dict(zip(q,[0 for x in range(0,len(q))]))
works but is ugly. what's a cleaner way?
...
What I'm trying to do:
I want to give the user the ability to upload a picture that is any size. This image is then resized if it is over 1024 wide or over 768 high. It then resizes the image to be within those bounds, but keeping proportions. Then it adds a semi-transparent watermark to the lower right corner, and saves the file.
Befo...
I'm trying to use a proxy with Python's mechanize automated browser library but it doesn't seem to be working. I am trying the following and checking the output and its not getting the page. I have made sure I am testing with proxies that work as I test the proxy manually in my browser first. Any advice on proper syntax is appreciated as...
I have a linux application that runs interactively from commandline using stdin to accept commands. I've written a wrapper using subprocess to access stdin while the application is backgrounded. I can now send commands to it using p.stdin.write(command) but how do I go about monitoring its responses?
...
I needed a simple HTTP proxy server written in Python so I began googling around and found this page. Not all the proxies were working and so I settled for this or this.
..but neither of them support authentication. Has anyone come across a HTTP Proxy Server written in Python that supports authentication?
Thanks.
...
Hi,
I have not used matplotlib, but looks like it is main library for drawing plots. I want to draw CPU usage plot. I have background processes each minute making record (date, min_load, avg_load, max_load). date could be timestamp or nice formatted date.
I want to draw diagram which show min_load, avg_load and max_load on the same plo...
I've got a QListWidget in my PyQt4 app. It contains folders paths.
I want to save its contents to QSettings and load them later.
I used this code to do this:
def foldersSave(self):
folders = {} '''create dict to store data'''
foldersnum = self.configDialog.FolderLIST.count() '''get number of items'''
if foldersnum:
f...
I have a string say s = 'Chocolate Moelleux-M\xe8re' When i am doing:
In [14]: unicode(s)
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 20: ordinal not in range(1...
I have a html form with <textarea name="message"></textarea> and I get the value by message = self.request.get('message').
Then I do mail api
message = mail.EmailMessage(sender="[email protected]", subject="Testing")
message.to = '[email protected]'
message.html = """The Message: %s """ % (message)
message.send()
The problem is I can only...
In my project I have to stick to Python 2.5 (Google App Engine). Somewhere in the application (actually a framework), I have to keep track which variables are defined and in which order they are defined, in other words I would like to intercept whenever an assignment operator is processed.
Using Python 3, I would define a metaclass M wi...
Basically, I have an application that is loaded using
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
I can send it commands using p.stdin.write() without any trouble, but I need to monitor stdout for server responses. this whole thing is running inside a tcp server, so I need to know ...
What is the best way of using C++ standard std::string from cython? The last cython distribution should make it easy anyway, but I wonder why there are wrappers for std::vector and not for std::string...
...
Hello, In python, I wrote this:
bvar=mht.get_value()
temp=self.treemodel.insert(iter,0,(mht,False,*bvar))
I'm trying to expand bvar to the funtion call as arguments.
But then it return,
File "./unobsoluttreemodel.py", line 65
temp=self.treemodel.insert(iter,0,(mht,False,*bvar))
^
...