Plugins/VcsPlugins/vcsMercurial/HgServeDialog.py

Sat, 29 May 2010 17:52:59 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 29 May 2010 17:52:59 +0200
changeset 305
5cf9e308f342
child 307
bdc899125e39
permissions
-rw-r--r--

Added action to start a Mercurial server to the Mercurial plug-in.

305
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog for the Mercurial server.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import QProcess, Qt, QSize
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QMainWindow, QAction, QToolBar, QPlainTextEdit, \
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 QMessageBox, QTextCursor, QBrush, QSpinBox, QComboBox
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui.E5Application import e5App
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import UI.PixmapCache
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 class HgServeDialog(QMainWindow):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing a dialog for the Mercurial server.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def __init__(self, vcs, path, parent = None):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param vcs reference to the vcs object
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param path path of the repository to serve (string)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent widget (QWidget)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 QMainWindow.__init__(self, parent)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.vcs = vcs
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.__repoPath = path
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__styles = ["paper", "coal", "gitweb", "monoblue", "spartan", ]
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__startAct = QAction(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 UI.PixmapCache.getIcon(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 os.path.join("VcsPlugins", "vcsMercurial", "icons", "startServer.png")),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.trUtf8("Start Server"), self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__startAct.triggered.connect(self.__startServer)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__stopAct = QAction(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 UI.PixmapCache.getIcon(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 os.path.join("VcsPlugins", "vcsMercurial", "icons", "stopServer.png")),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.trUtf8("Stop Server"), self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__stopAct.triggered.connect(self.__stopServer)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__browserAct = QAction(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 UI.PixmapCache.getIcon("home.png"),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.trUtf8("Start Browser"), self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__browserAct.triggered.connect(self.__startBrowser)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__portSpin = QSpinBox(self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__portSpin.setMinimum(2048)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__portSpin.setMaximum(65535)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__portSpin.setToolTip(self.trUtf8("Enter the server port"))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__portSpin.setValue(self.vcs.getPlugin().getPreferences("ServerPort"))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__styleCombo = QComboBox(self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__styleCombo.addItems(self.__styles)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__styleCombo.setToolTip(self.trUtf8("Select the style to use"))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__styleCombo.setCurrentIndex(self.__styleCombo.findText(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.vcs.getPlugin().getPreferences("ServerStyle")))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__serverToolbar = QToolBar(self.trUtf8("Server"), self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__serverToolbar.addAction(self.__startAct)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__serverToolbar.addAction(self.__stopAct)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__serverToolbar.addSeparator()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__serverToolbar.addWidget(self.__portSpin)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__serverToolbar.addWidget(self.__styleCombo)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__browserToolbar = QToolBar(self.trUtf8("Browser"), self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__browserToolbar.addAction(self.__browserAct)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.addToolBar(Qt.TopToolBarArea, self.__serverToolbar)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.addToolBar(Qt.TopToolBarArea, self.__browserToolbar)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__log = QPlainTextEdit(self)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.setCentralWidget(self.__log)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 # polish up the dialog
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__startAct.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__stopAct.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__browserAct.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.__portSpin.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__styleCombo.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.resize(QSize(800, 600).expandedTo(self.minimumSizeHint()))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.process = QProcess()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.process.finished.connect(self.__procFinished)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.process.readyReadStandardOutput.connect(self.__readStdout)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.process.readyReadStandardError.connect(self.__readStderr)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.cNormalFormat = self.__log.currentCharFormat()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.cErrorFormat = self.__log.currentCharFormat()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.cErrorFormat.setForeground(QBrush(Preferences.getUI("LogStdErrColour")))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 def __startServer(self):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 Private slot to start the Mercurial server.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 port = self.__portSpin.value()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 style = self.__styleCombo.currentText()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 args = []
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 args.append("serve")
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 args.append("-v")
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 args.append("--port")
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 args.append(str(port))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 args.append("--style")
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 args.append(style)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.process.setWorkingDirectory(self.__repoPath)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.process.start('hg', args)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 procStarted = self.process.waitForStarted()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if procStarted:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.__startAct.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.__stopAct.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__browserAct.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.__portSpin.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.__styleCombo.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.vcs.getPlugin().setPreferences("ServerPort", port)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.vcs.getPlugin().setPreferences("ServerStyle", style)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 else:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 QMessageBox.critical(None,
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.trUtf8('Process Generation Error'),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.trUtf8(
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 'The process {0} could not be started. '
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 'Ensure, that it is in the search path.'
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 ).format('hg'))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 def __stopServer(self):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 Private slot to stop the Mercurial server.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if self.process is not None and \
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.process.state() != QProcess.NotRunning:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.process.terminate()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.process.waitForFinished(5000)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if self.process.state() != QProcess.NotRunning:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.process.kill()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.__startAct.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__stopAct.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__browserAct.setEnabled(False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.__portSpin.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__styleCombo.setEnabled(True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 def __startBrowser(self):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 Private slot to start a browser for the served repository.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 ui = e5App().getObject("UserInterface")
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 ui.launchHelpViewer("http://localhost:{0}".format(self.__portSpin.value()))
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 def closeEvent(self, e):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 Private slot implementing a close event handler.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @param e close event (QCloseEvent)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.__stopServer()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def __procFinished(self, exitCode, exitStatus):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot connected to the finished signal.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 @param exitCode exit code of the process (integer)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @param exitStatus exit status of the process (QProcess.ExitStatus)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.__stopServer()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 def __readStdout(self):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 Private slot to handle the readyReadStandardOutput signal.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 It reads the output of the process and inserts it into the log.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 if self.process is not None:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 s = str(self.process.readAllStandardOutput(),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 Preferences.getSystem("IOEncoding"),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 'replace')
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__appendText(s, False)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 def __readStderr(self):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 Private slot to handle the readyReadStandardError signal.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 It reads the error output of the process and inserts it into the log.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 if self.process is not None:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 s = str(self.process.readAllStandardError(),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Preferences.getSystem("IOEncoding"),
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 'replace')
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.__appendText(s, True)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 def __appendText(self, txt, error = False):
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 Public method to append text to the end.
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 @param txt text to insert (string)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @param error flag indicating to insert error text (boolean)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 tc = self.__log.textCursor()
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 tc.movePosition(QTextCursor.End)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.__log.setTextCursor(tc)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 if error:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 self.__log.setCurrentCharFormat(self.cErrorFormat)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 else:
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.__log.setCurrentCharFormat(self.cNormalFormat)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.__log.insertPlainText(txt)
5cf9e308f342 Added action to start a Mercurial server to the Mercurial plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.__log.ensureCursorVisible()

eric ide

mercurial