diff options
-rw-r--r-- | modules/inittab/main.xml | 9 | ||||
-rw-r--r-- | src/frontend/main.py | 50 |
2 files changed, 39 insertions, 20 deletions
diff --git a/modules/inittab/main.xml b/modules/inittab/main.xml new file mode 100644 index 0000000..c54fa12 --- /dev/null +++ b/modules/inittab/main.xml @@ -0,0 +1,9 @@ +<VentooModule> + <root mult="1"> + <ventoo_dynamic mult="*"> + <runlevels mult="1"/> + <action mult="1"/> + <process mult="1"/> + </ventoo_dynamic> + </root> +</VentooModule>
\ No newline at end of file diff --git a/src/frontend/main.py b/src/frontend/main.py index 4a74017..d12d8db 100644 --- a/src/frontend/main.py +++ b/src/frontend/main.py @@ -35,6 +35,10 @@ import os import re import ErrorDialog import gtkmozembed +import difflib +from pygments import highlight +from pygments.lexers import DiffLexer +from pygments.formatters import HtmlFormatter import RcUpdateWindow sandboxDir = '/' @@ -91,7 +95,10 @@ class MainWindow(gtk.Window): thisIter = model.get_iter_from_string(path) enabled = model.get_value(thisIter, 0) aug_root = a.get("/augeas/root") - augPath = osp.join('files', osp.relpath(self.currentConfigFilePath, aug_root), self.edit_tv.get_label_path(thisIter)) + if not aug_root == '/': + augPath = osp.join('files', osp.relpath(self.currentConfigFilePath, aug_root), self.edit_tv.get_label_path(thisIter)) + else: + augPath = osp.join('files', augeas_utils.stripBothSlashes(self.currentConfigFilePath), self.edit_tv.get_label_path(thisIter)) if enabled: #this row was just added, update augeas tree. indexes = path.split(':') beforeIndex = int(indexes[len(indexes)-1])-1 @@ -155,12 +162,30 @@ class MainWindow(gtk.Window): #to be sure the save worked. augeas_utils.makeDiffTree(self.a, augeas_utils.getDiffRoot()) diffFiles = [self.currentConfigFilePath, augeas_utils.getDiffLocation(self.a, self.currentConfigFilePath)] - call = "meld " + diffFiles[0] + " " + diffFiles[1] + " &" - print call if not osp.isfile(diffFiles[1]): print "Could not find a diff file...were changes made?" else: - os.system(call) + origFile = open(diffFiles[0]) + origList = file.readlines(origFile) + origFile.close() + newFile = open(diffFiles[1]) + newList = file.readlines(newFile) + newFile.close() + #now we have origList and newList that is the text for the diff + d = difflib.Differ() + thediff = list(d.compare(origList, newList)) + #TODO: append username, to avoid conflicts + outFile = open("/tmp/ventooDiff.html", 'w') + outFile.write("<html>\n") + theDiff = difflib.unified_diff(origList, newList) + text = "" + for l in theDiff: + text += l + highlight(text, DiffLexer(), HtmlFormatter(full=True, linenos=True, cssclass="source"), outFile) + outFile.write("</html>\n") + outFile.close() + self.docWindow.load_url("file:///tmp/ventooDiff.html") + def showRCUpdate(self, button, data=None): win = RcUpdateWindow.RcUpdateWindow() @@ -331,22 +356,7 @@ if __name__ == '__main__': print 'Creating window...' if sandboxDir == '/': - print """ - -You're running this program on your root directory - This program sometimes has problems with the root directory. - If you're running as root it can't display diff. - if you're not running as root it can't save the system files - (because it doesn't have the permissions to do so. - - Displaying diffs as root will be fixed as soon as I figure out the - right way to do it. - - In the meantime, consider: - cp -r /etc /tmp - python thisProgram.py /tmp - (as non-root)""" - + pass #Note, it IS possible to create mutiple windows and augeas #instances to edit multiple "roots" at the same time. window = MainWindow(a) |