I wrote this simple Munin plugin to graph average fan speed and I want to redo it to OOP - strictly as a learning exercise. Don't have a clue where to start though. Anyone feel like offering some guidance or even an example of what this script should look like when done. I will use it to redo some other scripts into an OOP style as well;...
i used mutagen to read the mp3 metadata, since the id3 tag is read in as unicode but in fact it is GBK encoded. how to correct this in python?
audio = EasyID3(name)
title = audio["title"][0]
print title
print repr(title)
produces
µ±Äã¹Âµ¥Äã»áÏëÆðË
u'\xb5\xb1\xc4\xe3\xb9\xc2\xb5\xa5\xc4\xe3\xbb\xe1\xcf\xeb\xc6\xf0\xcb\xad'
but in ...
Hello all,
I am a beginner in jquery so please bear with me.
I have a jquery function that allows me to select multiple checkboxes and create a string as follows:
function getSelectedVals(){
var tmp =[];
$("input[name='checks']").each(function() {
if ($(this).attr('checked'))
{
checked = ($(this).val());
...
Can any one tell me how to use tagging auto-complete in django templates?
I have done this in django admin interface but i am confused to how to do it in the template.
Thanks in advance
...
Hello,
I have a string which has a version number. I want to read the version number from this code so I can compare it with other code I am using. I have code done below but cannot get it working, can anyone see the problem?
print results
r = re.compile(r'(version\s*\s*)(\S+)')
for l in results:
m1 = r.match(l)
...
I'm adding two icons to a gtk.Entry in PyGTK. The icons signals are handled by the following method
def entry_icon_event(self, widget, position, event)
I'm trying to differentiate between the two of them:
<enum GTK_ENTRY_ICON_PRIMARY of type GtkEntryIconPosition>
<enum GTK_ENTRY_ICON_SECONDARY of type GtkEntryIconPosition>
How can ...
Hi, I'm doing a real silly mistake in Python but unable to find what it is
I'm doing something like this in python
filename="file1"
if name == 'file1'
print 1
I'm getting an invalid syntax error
...
Python is creating a folder in my directory every time I call this method. The method is in one of my Django applications that requires access to the server's local area.
def filepath(filename, foldername='', envar='MYAPPDIR'):
if envar is not None and envar is os.environ:
dirpath = os.environ[envar]
else:
dirp...
I want to keep a dictionary of (all, non-immediate included) subclasses in a base class, so that I can instantiate them from a string. I'm doing this because the CLSID is sent through a web form, so I want to restrict the choices to the ones set from the subclasses. (I don't want to eval()/globals() the classname).
class BaseClass(obje...
Guys,
could you please advice how to verify in python if provided string correspond to provided pattern and return result.
For example the provided pattern is following:
< [prefix]-[id]> separated by ','>|< log >"
where prefix is any number of alphabetic characters,
id is only numbers but not exceeding 5 digits,
log is any number of ...
I would like some feedback on my first Python script that makes use of OOP style. This is a Munin plugin that graphs average fan speed or average chassis temp depending on the name of the plugin (dell_fans, dell_temps).
An hour or so ago I submitted a procedural version of the fan speed plugin to stackoverflow to get help converting it ...
I am using python with networkx package. I need to find the nodes connected to out edges of a given node.
I know there is a function networkx.DiGraph.out_edges but it returns out edges for the entire graph.
...
I'd like to make sure that my message was delivered to a queue.
To do so I'm adding the mandatory param to the basic_publish.
What else should I do to receive the basic.return message if my message wasn't successfully delivered?
I can't use channel.wait() to listen for the basic.return because when my message is successfully delivered...
I have a list 'a'
a= [(1,2),(1,4),(3,5),(5,7)]
I need to find all the tuples for a particular number. say for 1 it will be
result = [(1,2),(1,4)]
How do I do that.
PS - This is not homework
...
How do I force Latin-1 (which I guess means iso-8859-1?) file output in Python?
Here's my code at the moment. It works, but trying to import the resulting output file into a Latin-1 MySQL table produces weird encoding errors.
outputFile = file( "textbase.tab", "w" )
for k, v in textData.iteritems():
complete_line = k + '~~~~~' + v ...
Hi All
do you know if Python supports some keyword or expression like in C++ to return values based on if condition, all in the same line (The C++ if expressed with the question mark ?)
// C++
value = ( a > 10 ? b : c )
...
When creating Active Directory users from a script, I also need to set the option that they can't change their passwords. Via the administrative GUI this is easily accomplished, by checking "User cannot change password". Programmatically however, it's another story. I've found a recipe which involves interacting with the ADSI COM API, bu...
I'm trying to convert lines in an RTF file to a series of unicode strings, and then do a regex match on the lines. (I need them to be unicode so that I can output them to another file.)
However, my regex match isn't working - I think because they aren't being converted into unicode properly.
Here's my code:
usefulLines = []
textData =...
I've just upgraded from Python 2.6.1 to 2.6.4 on my development machine and upon starting a python script was presented with the following message:
Can't extract file(s) to egg cache
The following error occurred while
trying to extract file(s) to the
Python egg cache:
[Errno 13] Permission denied:
'/var/www/.python-e...
Is there a good reason why there isn't a do while flow control statement in python?
Why do pepole have to write while and break explicitly?
...