Last active
December 23, 2015 11:39
-
-
Save initbrain/6630051 to your computer and use it in GitHub Desktop.
List changed files during the last minute (graphically in a treeview window)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# List changed files during the last minute (graphically in a treeview window) | |
import gtk, commands | |
class PyApp(gtk.Window): | |
def __init__(self): | |
super(PyApp, self).__init__() | |
self.set_size_request(400, 300) | |
self.set_position(gtk.WIN_POS_CENTER) | |
self.connect("destroy", gtk.main_quit) | |
self.set_title("Latest changes") | |
tree = gtk.TreeView() | |
column = gtk.TreeViewColumn() | |
column.set_title("Changed files") | |
cell = gtk.CellRendererText() | |
column.pack_start(cell, True) | |
column.add_attribute(cell, "text", 0) | |
treestore = gtk.TreeStore(str) | |
a=commands.getoutput("find / -type f -not -path '/sys*' -not -path '/dev*' -not -path '/proc*' -mmin -1") | |
backup={} | |
for x in a.split('\n'): | |
if not "find:" in x: | |
print x | |
i=1 | |
parent=None | |
while i <= len(x.lstrip('/').split('/')): | |
if i != len(x.lstrip('/').split('/')): | |
#print "+"+x.lstrip('/').split('/')[i-1] # column | |
if '/'+'/'.join(x.lstrip('/').split('/')[0:i]) in backup.keys(): | |
parent=backup['/'+'/'.join(x.lstrip('/').split('/')[0:i])] | |
else: | |
backup['/'+'/'.join(x.lstrip('/').split('/')[0:i])]=parent | |
parent=treestore.append(parent, [x.lstrip('/').split('/')[i-1]]) | |
else: | |
#print "-"+x.lstrip('/').split('/')[i-1] # file | |
parent=treestore.append(parent, [x.lstrip('/').split('/')[i-1]]) | |
i+=1 | |
tree.append_column(column) | |
tree.set_model(treestore) | |
self.add(tree) | |
self.show_all() | |
PyApp() | |
gtk.main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment