# Wicd .deb packages

Posted: 2012-11-23 21:12

Hello world,

it's been a long time since I last posted something. Today, I want to let the world know about the availability of Debian packages for *wicd <https://launchpad.net/wicd>__*.

Since the release cycle of wicd is somewhat slow, I decided to provide automatically-built Debian packages for the latest revision of the upstream repository.

The automatic build process is possible thanks to Jenkins and the great jenkins-debian-glue, by Michael Prokop.

Here's the APT snippet, for those who dare:

# For the "upstream" version of wicd
deb http://jupiter.hanskalabs.net/debian/ wicd main


The repository is signed with a separate GnuPG key, which I signed with my main keys. You can download it or retrieve it from a keyserver, then you should add it to your APT keyring:

$gpg --keyserver pgp.mit.edu --recv-keys 4D00F190 # gpg --export 4D00F190 | apt-key add -  Obviously these builds are not guaranteed to work :) but, since I myself use these autobuilt packages, I usually try to fix problems as soon as I notice them. If you find bugs, or have proposals to improve wicd, please report them on launchpad! # Mappa dei bus urbani di Mazara! Posted: 2012-09-24 01:11 Oggi, giusto per sfizio, ho creato una mappa dei trasporti su bus di Mazara. Spero piaccia e sia utile! :) # Editable QComboBox with QAbstractTableModel Posted: 2012-07-22 09:56 Dear Lazyweb, I'm working on a personal PyQt4 project for my parents' office, and I need to autocomplete an editable QComboBox. I can't use a standard Qt model (I need to store python objects in it), so I subclassed QAbstractTableModel. Here it is, it's a fairly generic subclass of QAbstractTableModel, with variable number of columns: class QGenericTableModel(QAbstractTableModel): def __init__ (self, columns, parent=None, *args): super(QGenericTableModel, self).__init__(parent, *args) self.columns = columns self.headers = {} self.table = [] def rowCount(self, parent=QModelIndex()): return len(self.table) def columnCount(self, parent): return self.columns def row(self, row): return self.table[row] def setData(self, index, value, role): if index.isValid() and role == Qt.EditRole: row = index.row() t = self.table[row] if index.column() >= self.columns: return False if isinstance(value, QVariant): t[index.column()] = value.toString().simplified() else: t[index.column()] = value self.emit(SIGNAL('dataChanged'), index, index) return True return False def data(self, index, role = Qt.DisplayRole): if not index.isValid(): return QVariant() if (index.row() >= len(self.table)) or (index.row() < 0): return QVariant() if role == Qt.DisplayRole: return QVariant(self.table[index.row()][index.column()]) return QVariant() def insertRow(self, row, parent=QModelIndex()): self.insertRows(row, 1, parent) def insertRows(self, row, count, parent=QModelIndex()): self.beginInsertRows(parent, row, row+count-1) for i in xrange(count): self.table.insert(row, ['',]*self.columns) self.endInsertRows() return True def removeRow(self, row, parent=QModelIndex()): self.removeRows(row, 1, parent) def removeRows(self, row, count, parent=QModelIndex()): self.beginRemoveRows(parent, row, row+count-1) for i in reversed(xrange(count)): self.table.pop(row+i) self.endRemoveRows() return True def flags(self, index): if not index.isValid(): return Qt.ItemIsEnabled return super(QGenericTableModel, self).flags(index) | Qt.ItemIsEditable def headerData(self, column, orientation, role = Qt.DisplayRole): if role != Qt.DisplayRole: return QVariant() if orientation == Qt.Horizontal: if column >= self.columns: return QVariant() return self.headers[column] return QVariant() def setHeaderData(self, column, orientation, value, role = Qt.EditRole): self.headers[column] = value  It might not be perfect, but it works, and it's all that matters at the moment (since it's my first serious PyQt4 project). Oh, well, it worked until I tried to use it with an editable QComboBox. And here's the app code (for the full working code, insert the above class right after the imports): import sys from PyQt4.QtGui import * from PyQt4.QtCore import * app = QApplication(sys.argv) model = QStandardItemModel() for i, word in enumerate(['saluton', 'gxis la revido', 'hello', 'goodbye']): item = QStandardItem(word) model.setItem(i, 0, item) #model = QGenericTableModel(1) #for i, word in enumerate(['saluton', 'gxis la revido', 'hello', 'goodbye']): # model.insertRow(i) # index = model.index(i, 0) # model.setData(index, word, Qt.EditRole) combo = QComboBox() filterModel = QSortFilterProxyModel(combo) completer = QCompleter(combo) filterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) filterModel.setSourceModel(model) filterModel.setFilterKeyColumn(0) completer.setModel(filterModel) completer.setCompletionColumn(0) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) combo.setEditable(True) combo.setCompleter(completer) combo.setModel(model) combo.setModelColumn(0) if combo.isEditable(): app.connect(combo.lineEdit(), SIGNAL('textEdited(QString)'), filterModel.setFilterFixedString) combo.setModel(model) combo.setModelColumn(0) combo.show() sys.exit(app.exec_())  Now, try running it. It works well when I use a QStandardItemModel. Then, try decommenting the part where I use my subclassed model: it just doesn't work: clicking on any item makes the QComboBox not change its currentIndex, and this only happens if the combobox is editable. I suspect I'm forgetting to override some function in my model, but I don't know what exactly to override, and Google didn't help me. This is also backed up by the fact that the exact same behaviour shows up when, instead of a QComboBox, I try to autocomplete on a QLineEdit. So, dear readers: can anyone explain what is happening? Thanks in advance! UPDATE: it turned out that the culprit was the following bit inside data(): if role == Qt.DisplayRole: return QVariant(self.table[index.row()][index.column()])  Adding also Qt.EditRole to the list of possible choices fixed the bug. YAY! # Getting network devices with Python and udev Posted: 2012-02-23 14:07 *UPDATE* I wrote a new article based on Ben Hutching's response. Just a quick post, mainly as a reminder for when I'll try to implement this in WICD: #!/usr/bin/python import gudev client = gudev.Client(['rfkill', 'net']) for dev in client.query_by_subsystem('net'): if dev.get_sysfs_attr_as_int("type") != 1: continue driver = dev.get_driver() if not driver: parent = dev.get_parent() if parent: driver = parent.get_driver() print type, dev.get_name(), driver, dev.get_sysfs_path()  This will print all network devices with ethernet-encapsulated packets (that's what sysfs type "1" is). Here's the output on my system: eth0 e1000e /sys/devices/pci0000:00/0000:00:19.0/net/eth0 wlan0 b43 /sys/devices/pci0000:00/0000:00:1c.1/0000:10:00.0/ssb0:0/net/wlan0  I'm still missing how to reliably detect if a device is a "wired" or a "wireless" one. I suspect that checking the existence of /phy80211 would be enough, but I can't really tell, and seems like I'm not able to find an exhaustive sysfs reference manual. # Magento: Italian provinces Posted: 2012-01-05 11:23 Ok, so you have Magento, and you're located in Italy. And you'd like your customers to select a province from a dropdown select box. Unfortunately, Magento doesn't include Italian provinces in their default database: that's why I wrote a simple script to take care of that. The script is in Python, and uses SQLAlchemy. You'll also need to download the list of provinces. You should run it like this:$ ./load_provinces.py provinces

Be sure to run it only *once*, otherwise you'll get duplicated provinces in the database.

There is some commented code you should decomment if you want to test the script before actually touching the Magento database.

Also, you need to change the "user", "psw" and "dbname" parameters, and might need to change the "host" and "port" too.

Now, I need to understand how to require address input at the registration page. ARGH.

Posted: 2011-06-17 00:17
Tags:  planet english

# free -m -bash: fork: Cannot allocate memory

Something's definitely wrong.

# View a specific SVN revision on web

Posted: 2011-06-17 00:17
Tags:  tips planet english svn

I just found this out, so I'm posting it, since it might be useful both as a reminder, and for others to read.

Suppose you have a "classical" Subversion web interface, like svn.openstreetmap.org. This will show you the last revision by default.

What if you want to see a particular revision? I found this by googling a bit:

http://<yoursvn>/!svn/bc/<revision>/<path>


So, say, using the above example, you want to see the sites/ directory of revision 20000: here you are (compare with current).

This obviously works with files too.

# Welcome Michael Gilbert!

Posted: 2011-06-17 00:17
Tags:  dkms planet english

I just approved his request for joining the DKMS team. Welcome on board!

# Optional argument with \newcommand in LaTeX

Posted: 2011-06-17 00:17

In LaTeX, it seems like you can't define a command with a really optional argument, using \newcommand. You can make commands with arguments having a default value though.

Now, I found myself in need of having such a functionality. I had to google a while, but finally found it, so I'm posting it here, both to share knowledge and to remember it in future :)

Suppose you want to do something like \mycmd{foo} and \mycmd{foo}{bla}, doing different things (in my case, I needed to add the second argument enclosed by parenthesis in the TOC and other places, but only if it was present)

Here's the code:

\def\mycmd#1{\def\tempa{#1}\futurelet\next\mycmd@i}% Save first argument
\def\mycmd@i{\ifx\next\bgroup\expandafter\mycmd@ii\else\expandafter\mycmd@end\fi}%Check brace
\def\mycmd@ii#1{...}%Two args
\def\mycmd@end{...}%Single args


In the last two lines of the code, use \tempa for your first argument, and #1 for your second optional argument. If you need spaces there (maybe as part of some text), be sure to escape them with a backslash \.

I think it's expandable for additional arguments, but I haven't tried, and I don't feel like getting my hands dirty with TeX yet ;)

# Bash-Completion 1.3-2: now with triggers!

Posted: 2011-06-17 00:17

Today I uploaded bash-completion 1:1.3-2 to the experimental branch of Debian.

This package uses dpkg triggers to achieve an overdue goal: speedup shell loading by not even looking into completions for unavailable commands.

The mechanism is simple: a trigger is activated when a package installs something in one of the usual \$PATH directories, and it creates symlinks for the appropriate completions.

This upload also features a change in the layout: completions were moved out of /etc/, so you won't be annoyed anymore during upgrades (and, let's say it, they shouldn't have been there since the beginning). However /etc/bash_completion.d/ is still around for compatibility reasons. If you want to enable a completion, just symlink it there from /usr/share/bash-completion/completions/. If there are enough requests, I might do a simple compenable/compdisable script to create them.

I'd appreciate if adventurous people could test it, and report bugs (if any, hopefully). And don't be scared by the tons of messages about removed conffiles :)

Please beware that the "detection mechanism" of appropriate completions is not entirely foolproof: it might need some hacking upstream (adding meta-headers to completion files?), so I'll try to improve it in future.