コード例 #1
0
ファイル: DOHandler.py プロジェクト: ibrahimcesar/domanager
 def _request(self, method, request):
     clientId = config.value('clientId', "")
     apiKey = config.value('apiKey', "")
     request = request % (clientId, apiKey)
     try:
         conn = httplib.HTTPSConnection(self._url)
         conn.putrequest(method, request)
         conn.endheaders()
         response = conn.getresponse()
         return json.loads(response.read())
     except:
         return
コード例 #2
0
ファイル: TrayIcon.py プロジェクト: ibrahimcesar/domanager
 def _openSSH(self, idx):
     userName = config.value('userName', "root")
     ipAddress = self._dInfos[idx]['ip_address']
     sshPort = config.value('sshPort', 22)
     command = config.sshCommand
     if platform == "win32":
         command = command % (userName, ipAddress, sshPort)
         DETACHED_PROCESS = 0x00000008
         subprocess.Popen(command.split(' '), creationflags=DETACHED_PROCESS)
     else:
         command = command % (sshPort, userName, ipAddress)
         os.system(command)
コード例 #3
0
ファイル: TrayIcon.py プロジェクト: ibrahimcesar/domanager
    def __init__(self, mWindow):
        super(TrayIcon, self).__init__(mWindow)
        self.setIcon(self._icon(config.mainIcon))
        self.setVisible(True)

        self._mainWindow = mWindow
        self._mainWindow.setWindowIcon(self._icon("main_logo_color.png"))

        self._doHandler = DOHandler()
        self._updateChecker = UpdateChecker(self._mainWindow)
        self._updateChecker.quitProgram.connect(self._quit)

        self._data = []
        self._dInfos = []
        self._menu = None

        self._quitAction = QtWidgets.QAction("Quit", self)
        self._quitAction.setIcon(self._icon("quit.png"))
        self._quitAction.triggered.connect(self._quit)

        self._aboutAction = QtWidgets.QAction("About", self)
        self._aboutAction.setIcon(self._icon("about.png"))
        self._aboutAction.triggered.connect(self._about)

        self._settingsAction = QtWidgets.QAction("Preferences", self)
        self._settingsAction.setIcon(self._icon("settings.png"))
        self._settingsAction.triggered.connect(self._settings)

        self._createAction = QtWidgets.QAction("Create droplet (web)", self)
        self._createAction.setIcon(self._icon("create.png"))
        self._createAction.triggered.connect(self._createDroplet)

        self._bugAction = QtWidgets.QAction("Report bug/request", self)
        self._bugAction.setIcon(self._icon("bug.png"))
        self._bugAction.triggered.connect(self._report)

        self._updateAction = QtWidgets.QAction("Check for update", self)
        self._updateAction.setIcon(self._icon("update.png"))
        self._updateAction.triggered.connect(self.update)

        self._helpMenu = QtWidgets.QMenu(self._mainWindow)
        self._helpMenu.addAction(self._updateAction)
        self._helpMenu.addAction(self._bugAction)
        self._helpMenu.addAction(self._aboutAction)

        self._helpAction = QtWidgets.QAction("Help", self)
        self._helpAction.setIcon(self._icon("help.png"))
        self._helpAction.setMenu(self._helpMenu)

        self._updateThread = UpdateThread(self)
        self._updateThread.updated.connect(self._updateData)
        self._updateThread.start()

        clientId = config.value('clientId', "")
        apiKey = config.value('apiKey', "")

        self.activated.connect(self._popupMenu)

        if not clientId or not apiKey:
            self._settings()

        self._updateMenu()
コード例 #4
0
    def __init__(self, parent=None):
        super(PreferencesDialog, self).__init__(parent)
        self.setWindowIcon(self._icon("settings.png"))
        self.setWindowTitle("DO Manager: Preferences")
        self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)

        self._layout = QtWidgets.QVBoxLayout(self)
        self._layout.setContentsMargins(5, 15, 5, 5)

        self._clientIDBox = QtWidgets.QLineEdit(self)
        clientId = config.value('clientId', "")
        self._clientIDBox.setText(clientId)
        self._clientIDBox.setMinimumWidth(250)

        self._apiKeyBox = QtWidgets.QLineEdit(self)
        self._apiKeyBox.setEchoMode(QtWidgets.QLineEdit.Password)
        apiKey = config.value('apiKey', "")
        self._apiKeyBox.setText(apiKey)
        self._apiKeyBox.setMinimumWidth(250)

        self._sshUserNameBox = QtWidgets.QLineEdit(self)
        userName = config.value('userName', "root")
        validator = QtGui.QRegExpValidator(QtCore.QRegExp("[ -~]*"), self._sshUserNameBox)
        self._sshUserNameBox.setValidator(validator)
        self._sshUserNameBox.setText(userName)
        self._sshUserNameBox.setMinimumWidth(250)

        self._sshPortBox = QtWidgets.QLineEdit(self)
        sshPort = config.value('sshPort', 22)
        validator = QtGui.QRegExpValidator(QtGui.QIntValidator(1, 65535, self._sshPortBox))
        self._sshPortBox.setValidator(validator)
        self._sshPortBox.setText("%s" % sshPort)
        self._sshPortBox.setMinimumWidth(250)

        self._formLayout = QtWidgets.QFormLayout()
        self._formLayout.setContentsMargins(5, 5, 5, 5)
        self._formLayout.addRow("Client ID: ", self._clientIDBox)
        self._formLayout.addRow("API Key: ", self._apiKeyBox)

        self._okButton = QtWidgets.QPushButton("OK")
        self._cancelButton = QtWidgets.QPushButton("Cancel")

        self._getKeysLabel = QtWidgets.QLabel(self)
        infoMsg = "<qt><a href=\"link\">Get Client ID & API Key</a></qt>"
        self._getKeysLabel.setText(infoMsg)
        self._getKeysLabel.linkActivated.connect(self._getKeys)

        self._buttonsLayout = QtWidgets.QHBoxLayout()
        self._buttonsLayout.setContentsMargins(0, 0, 0, 0)
        self._buttonsLayout.addWidget(self._getKeysLabel)
        self._buttonsLayout.addWidget(QtWidgets.QWidget(self), 1)
        self._buttonsLayout.addWidget(self._okButton)
        self._buttonsLayout.addWidget(self._cancelButton)

        self._formWidget = QtWidgets.QWidget(self)
        self._formWidget.setContentsMargins(0, 0, 0, 0)
        self._formWidget.setLayout(self._formLayout)

        self._sshLayout = QtWidgets.QFormLayout()
        self._sshLayout.setContentsMargins(5, 5, 5, 5)
        self._sshLayout.addRow("SSH User: "******"SSH Port: ", self._sshPortBox)

        self._sshWidget = QtWidgets.QWidget(self)
        self._sshWidget.setContentsMargins(0, 0, 0, 0)
        self._sshWidget.setLayout(self._sshLayout)

        self._tabs = QtWidgets.QTabWidget(self)
        self._tabs.addTab(self._formWidget, "General")
        self._tabs.addTab(self._sshWidget, "SSH")

        self._layout.addWidget(self._tabs)
        self._layout.addLayout(self._buttonsLayout)

        self._cancelButton.clicked.connect(self.close)
        self._okButton.clicked.connect(self._onOK)

        self._clientIDBox.setFocus()