~jr/global-settings/mockup

« back to all changes in this revision

Viewing changes to settings.py

  • Committer: jr
  • Date: 2008-02-01 19:26:30 UTC
  • Revision ID: jr@wido-20080201192630-0hw2vlu6e7m47k2s
it does something

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#############################################################################
22
22
 
23
23
import sys
 
24
import os
 
25
import subprocess
24
26
 
25
27
from PyQt4.QtCore import *
26
28
from PyQt4.QtGui import *
52
54
 
53
55
        uic.loadUi(APPDIR + "/" + "settings.ui", self)
54
56
        self.show()
 
57
        self.connect(self.sendButton, SIGNAL("clicked()"), self.send)
 
58
        self.connect(self.grabButton, SIGNAL("clicked()"), self.grab)
 
59
 
 
60
    def getCwd(self):
 
61
        home = os.environ.get("HOME")
 
62
        cwd = home + "/.kde/share/"
 
63
        return cwd
 
64
 
 
65
    def send(self):
 
66
        user = self.launchpadUser.text()
 
67
        if len(user) < 2:
 
68
            QMessageBox.warning(self, "No User", "Please add a launchpad user.")
 
69
            return
 
70
 
 
71
        if not QFile.exists("/usr/bin/bzr"):
 
72
            QMessageBox.warning(self, "No Bazaar", "Please install Bazaar (bzr).")
 
73
            return
 
74
 
 
75
        cwd = self.getCwd()
 
76
 
 
77
        if len(cwd) < 2+12:
 
78
            QMessageBox.warning(self, "No Home", "$HOME not set.")
 
79
 
 
80
        if not QFile.exists(cwd + ".bzr"):
 
81
            subprocess.call(["bzr", "init"], cwd=cwd)
 
82
            print "bzr init"
 
83
 
 
84
        if self.bookmarksTickbox.isChecked():
 
85
            subprocess.call(["bzr", "add", "apps/konqueror/bookmarks.xml"], cwd=cwd)
 
86
            print "bzr add apps/konqueror/bookmarks.xml"
 
87
 
 
88
        subprocess.call(["bzr", "commit", "-m", "save settings"], cwd=cwd)
 
89
        print "bzr commit"
 
90
 
 
91
        subprocess.call(["bzr", "push", "bzr+ssh://jr@bazaar.launchpad.net/~" + user + "/+junk/savedsettings"], cwd=cwd)
 
92
        print "bzr push bzr+ssh://jr@bazaar.launchpad.net/~" + user + "/+junk/savedsettings"
 
93
 
 
94
        QMessageBox.information(self, "Settings Sent", "<qt>Settings have been sent to Launchpad, run Grab on another machine to get them.<br />See them at <a href=\"https://code.launchpad.net/~" + user +"/+junk/savedsettings\">Launchpad Code</a>.</qt>")
 
95
 
 
96
    def grab(self):
 
97
        print "grabbing"
 
98
        cwd = self.getCwd()
 
99
 
 
100
        user = self.launchpadUser.text()
 
101
        if len(cwd) < 2+12:
 
102
            QMessageBox.warning(self, "No User", "Please add a launchpad user.")
 
103
            return
 
104
 
 
105
        if not QFile.exists(cwd + ".bzr"):
 
106
            subprocess.call(["bzr", "co", "bzr+ssh://jr@bazaar.launchpad.net/~" + user + "/+junk/savedsettings"], cwd=cwd)
 
107
            print "bzr co bzr+ssh://jr@bazaar.launchpad.net/~" + user + "/+junk/savedsettings"
 
108
        else:
 
109
            subprocess.call(["bzr", "update"], cwd=cwd)
 
110
            print "bzr update"
 
111
        QMessageBox.information(self, "Updated", "Settings updated, restart Konqueror for new bookmarks.")
55
112
 
56
113
if __name__ == "__main__":
57
114
    """start the application.  TODO, gtk frontend does clever things here to not start the GUI until it has to"""