python

How to make Fabric execution follow the env.hosts list order?

I have the following fabfile.py: from fabric.api import env, run host1 = '192.168.200.181' host2 = '192.168.200.182' host3 = '192.168.200.183' env.hosts = [host1, host2, host3] def df_h(): run("df -h | grep sda3") And I get the following output: [192.168.200.181] run: df -h | grep sda3 [192.168.200.181] out: /dev/sda3 ...

How to make Fabric ignore offline hosts in the env.hosts list?

This is related to my previous question, but a different one. I have the following fabfile: from fabric.api import * host1 = '192.168.200.181' offline_host2 = '192.168.200.199' host3 = '192.168.200.183' env.hosts = [host1, offline_host2, host3] env.warn_only = True def df_h(): with settings(warn_only=True): run("df -h ...

How to remove blocks surrounded by curly brackets via python

Sample text: String -> content within the rev tag (via lxml). I'm trying to remove the {{BLOCKS}} within the text. I've used the following regex to remove simple, one line blocks: p = re.compile('\{\{*.*\}\}') nonBracketedString = p.sub('', bracketedString) However this does not remove the first multi line bracketed section at the b...

[Django] How to get latest timestamp in a column?

I have a timestamp column in my t1 table. The format is as: 2009-12-24 06:17:34 There are many entries as such. How do we query from views to get the latest timestamp ...

Is it possible to compile a program written in Python?

I am new to the Python programming language. I was wondering if it is possible to compile a program written in Python. ...

why my "eval" function doesn't work ,i think it can be print 'b',but not

a='''b="ddd"''' eval(repr(a)) print str(a) print b Please try to use the code, rather than text, because my English is not very good, thank you ...

render_to_response gives TemplateDoesNotExist

I am obtaining the path of template using paymenthtml = os.path.join(os.path.dirname(__file__), 'template\\payment.html') and calling it in another application where paymenthtml gets copied to payment_template return render_to_response(self.payment_template, self.context, RequestContext(self.request)) But I get error Templ...

efficient algorithm to perform spell check on HTML document

I have a HTML document, a list of common spelling mistakes, and the correct spelling for each case. The HTML documents will be up to ~50 pages and there are ~30K spelling correction entries. What is an efficient way to correct all spelling mistakes in this HTML document? (Note: my implementation will be in Python, in case you know of an...

How to make read-only data accessible by diff requests while the server is running (apache, mod_python)

Hello, I am using Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 and I would like to preload the data I work with. Currently I read the data from a file on disk every time I get a request, then parse it and store it in an object. The data file is relatively large and I would like to parse/preload it ahead of time. I was thinking...

frames per seconds

I want to limit the calculation-speed. There was a command for rate per second. Could anybody help me? doesn't rate() work in the newer version of Python? Thanks ...

Why python super does not accept only instance ?

In python 2.x, super accepts the following cases class super(object) | super(type) -> unbound super object | super(type, obj) -> bound super object; requires isinstance(obj, type) | super(type, type2) -> bound super object; requires issubclass(type2, type) | Typical use to call a cooperative superclass method: as far as I see,...

Why do all twisted/wokkel xmpp examples ignore the proper usage of JID in the xmpp protocol?

Okay, this isn't a question. All the examples of wokkel and twisted I have seen do not properly observe generated resources in the JID. Google talk clients built using wokkel/twisted generally break because they do not set the full JID on responses, resulting in (very hidden, low level) errors like: <message to="[email protected]" from...

How do I generate a random string (of length X, a-z only) in Python?

How do i generate it? The string ...

i don't know why iter(not __iter__) function use in this place,what is the mean of iter in this code.

i don't know "self._iterator = iter(self._container)"in next code. in django.http : class HttpResponse(object): def __iter__(self): self._iterator = iter(self._container) return self def next(self): chunk = self._iterator.next() if isinstance(chunk, unicode): chunk = chunk.encode(sel...

why dict objects are unhashable in python?

I mean why cant we put key of dict as dict? that means we can't have dictionary having key as another dictionary... ...

why my extjs combobox is not filled dynamically?

Here is my Extjs onReady function var store = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: '/loginjson.json' }), reader: new Ext.data.JsonReader( {root: '...

GUI runner in Eclipse for Python/IronPython

As much as the console runner is nice, I enjoy the instant red/green view of a graphical runner such as NUnit or MSTest for quickly glancing at broken tests. Does such a tool exist for Eclipse? I've tried Google but only found some awful standalone versions. ...

Python: Overloading the [] opeartor

Hi, I have been looking for the function name to override to overload the [] operator. Could anyone help? Thanks ...

Python2.4 and 2.6 behaves differently for os.path.getmtime() on Windows

Getting two different modification time when calculated from different Python versions on Windows XP. Python2.4 C:\Copy of elisp>c:\python24\python Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.getmtime("aut...

char to keycode in python

Hello, I want to be able to translate a string to keycode to write it with Xlib (to simulate user action on linux). The keycode are not the ascii but the code you get when you do use xev on linuxKeyPress event, serial 33, synthetic NO, window 0x6400001, root 0x13c, subw 0x0, time 51212100, (259,9), root:(262,81), state 0x0, ke...