コード例 #1
0
ファイル: vpn.py プロジェクト: xtc-Thin-Client/xtcapp
def writeVPN(values):
    logging.info("writeVPN")
    try:
        tmpfile = common.getRessource("tmpFile")
        filew = open(tmpfile, "w")
        if values["ovpn"] != "":
            line = "ovpn=" + values["ovpn"] + "\n"
            filew.write(line)
        if values["parametervpn"] != "":
            line = "parametervpn=" + values["parametervpn"] + "\n"
            filew.write(line)
        line = "autostartvpn=" + values["autostartvpn"] + "\n"
        filew.write(line)
        line = "systemlogin="******"systemlogin"] + "\n"
        filew.write(line)
        filew.close()
    except OSError as error:
        logging.error(error)
        common.errorDialog(error)
    try:
        # write file to system
        command = common.getRessource("commandVPNFile")
        command = command + " " + tmpfile
        common.runProgram(command)
    except OSError as error:
        logging.error(error)
        common.errorDialog(error)
コード例 #2
0
ファイル: vpn.py プロジェクト: xtc-Thin-Client/xtcapp
def vpnCancel(self):
    logging.info("vpnCancel")
    command = common.getRessource("commandVPNKill")
    command = command + " " + common.getRessource("commandVPNLog")
    logging.info(command)
    common.runProgram(command)
    self.vpnButtonConnect.setEnabled(True)
    self.vpnButtonCondition.setIcon(
        QtGui.QIcon(common.getRessource("disconnectIcon")))
コード例 #3
0
 def vpnTransfer(self):
     logging.info("vpnTransfer")
     vpn.vpnTransfer(self)
     # reboot system
     result = common.confirmDialog(
         self, common.getRessource("systemShutdownTitle"),
         common.getRessource("systemAssumeMessage"))
     if result:
         common.runProgram(common.getRessource("commandReboot"))
コード例 #4
0
 def connectionCancel(self):
     logging.info("connectionCancel")
     item = self.connectList.currentItem()
     if item is not None:
         name = item.text()
         if name in self.connectedThreads:
             runconnect = self.connectedThreads[name]
             if runconnect is not None:
                 pid = runconnect.getPid()
                 command = common.getRessource("commandKill")
                 command = command + " " + str(pid)
                 common.runProgram(command)
コード例 #5
0
def action_wrapper(hermes, intentMessage, conf):
    """ Write the body of the function that will be executed once the intent is recognized. 
    In your scope, you have the following objects : 
    - intentMessage : an object that represents the recognized intent
    - hermes : an object with methods to communicate with the MQTT bus following the hermes protocol. 
    - conf : a dictionary that holds the skills parameters you defined 
    Refer to the documentation for further details. 
    """
    url = conf['global']['url']
    try:
        verbose = conf['global']['verbose']
    except:
        verbose = 'False'

    dl, pl = common.readcache()
    if dl == [] or pl == []:
        dl = common.retrieveDeviceList(url)
        pl = common.retrieveProgramList(url)
        common.writecache(dl, pl)

    try:
        spoken_name = intentMessage.slots.Name.first().value

        if common.runProgram(url, common.getID(pl, spoken_name)):
            if verbose == 'True' or verbose == 'true':
                result_sentence = "Führe das Programm " + spoken_name + " aus."
            else:
                result_sentence = "OK"
        else:
            result_sentence = "Ich konnte den Programmnamen nicht finden!"
    except:
        result_sentence = "Ich habe es nicht verstanden!"

    current_session_id = intentMessage.session_id
    hermes.publish_end_session(current_session_id, result_sentence)
コード例 #6
0
ファイル: vpn.py プロジェクト: rausnehmkeil/xtcbin
def vpnAdditionalFiles(self):
    logging.info("vpnAdditionalFiles")
    command = common.getRessource("commandMountUSB")
    logging.info(command)
    common.runProgram(command, False)
    filename = getFile()
    command = common.getRessource("commandVPNCopy") + " " + filename
    logging.info(command)
    common.runProgram(command, False)
    command = common.getRessource("commandUmountUSB")
    logging.info(command)
    common.runProgram(command, False)
コード例 #7
0
ファイル: vpn.py プロジェクト: xtc-Thin-Client/xtcapp
def vpnGetFile(self):
    logging.info("vpnGetFile")
    command = common.getRessource("commandMountUSB")
    logging.info(command)
    common.runProgram(command, False)
    filename = getFile("ovpn", common.getRessource("VPNUSBDirectory"))
    if filename != "":
        targetfilename = common.getRessource("VPNOvpnFile")
        command = common.getRessource(
            "commandVPNCopy") + " " + filename + " " + targetfilename
        logging.info(command)
        common.runProgram(command)
        self.vpnInputovpn.setText(targetfilename)
    command = common.getRessource("commandUmountUSB")
    logging.info(command)
    common.runProgram(command, False)
コード例 #8
0
def timeaction(connectionname):
    configfile = common.ressourcefile
    loggingfilename = common.getRessourceByName(configfile,
                                                "loggingTimeAction")
    debugfile = common.getRessourceByName(configfile, "debugSwitch")
    debug = False
    if os.path.isfile(debugfile):
        debug = True
    common.loggingStart(loggingfilename, debug)
    logging.info("timeaction")

    # get action time from file
    values = common.readTime()
    if "execute" in values:
        logging.info("execute: " + values["execute"])
        if values["execute"] == "no":
            print("no action. Terminated")
            logging.info("no action. Terminated")
            sys.exit(0)
    else:
        sys.exit(0)

    actiontime = values["execat"]
    logging.info(actiontime)
    action = values["action"]
    logging.info(action)

    if actiontime.startswith("+"):
        splitline = actiontime.split("+")
        text = splitline[1]
        splitline = text.split(":")
        text = splitline[0]
        hours = int(text)
        text = splitline[1]
        minutes = int(text)
        actionat = datetime.now() + timedelta(hours=hours, minutes=minutes)
    else:
        actionat = datetime.strptime(actiontime, "%Y-%m-%d %H:%M")

    logging.info("current time: " + str(datetime.now()))
    logging.info("action at " + str(actionat))
    print("current time: " + str(datetime.now()))
    print("action at " + str(actionat))
    print("action: " + action)

    run = True
    while run:
        if datetime.now() >= actionat:
            break
        # wait 10 sec. before new check
        time.sleep(10)

    # write last action to file
    values["last"] = str(datetime.now())
    logging.info(values["last"])
    if "repeat" in values:
        logging.info("repeat " + values["repeat"])
        if values["repeat"] == "no":
            values["execute"] = "no"
    else:
        values["execute"] = "no"
    common.writeTime(values)
    logging.info("execute at: " + str(datetime.now()))

    # execute action
    if action == "shutdown":
        common.runProgram(common.getRessource("commandShutdown"))
    if action == "reboot":
        common.runProgram(common.getRessource("commandreboot"))
    if action == "test":
        print("execute action test")
        logging.info("execute action test")
        sys.exit(0)
コード例 #9
0
ファイル: dialogtigervnc.py プロジェクト: rausnehmkeil/xtcbin
 def newPasswordFile(self, connectionname, password):
     logging.info("writePasswordFile")
     filename = common.getRessource("passwordFile") + "." + connectionname
     command = common.getRessource("commandVNCPasswd")
     common.runProgram("echo '" + password + "' | " + command + " " +
                       filename)
コード例 #10
0
ファイル: vpn.py プロジェクト: xtc-Thin-Client/xtcapp
def vpnCheckState():
    command = common.getRessource("commandVPNState")
    command = command + " " + common.getRessource("commandVPNLog")
    logging.info(command)
    return common.runProgram(command)
コード例 #11
0
    def systemAssume(self):
        logging.info("systemAssume")
        values = {}
        password = self.systemInputPassword.text()
        passwordrepeat = self.systemInputPasswordRepeat.text()
        if password != "" or passwordrepeat != "":
            if password == passwordrepeat:
                values["adminPassword"] = common.convertPassword(password)
            else:
                common.messageDialog("systemPasswordComparisonError")
                return

        if self.systemInputStartAdmin.isChecked():
            values["startAdmin"] = "yes"
        else:
            values["startAdmin"] = "no"

        if self.systemInputRemoteVNC.isChecked():
            password = self.systemInputRemotePassword.text()
            passwordrepeat = self.systemInputRemotePasswordRepeat.text()

            if password == "" or passwordrepeat == "":
                common.messageDialog("systemRemotePasswordError")
                return

            if password == passwordrepeat:
                common.remoteVNC(True, self)
            else:
                common.messageDialog("systemPasswordComparisonError")
                return
        else:
            common.remoteVNC(False, self)

        if self.systemInputSSH.isChecked():
            common.remoteSSH(True)
        else:
            common.remoteSSH(False)

        values["language"] = self.systemInputLanguage.currentText()
        values["keyboardLayout"] = self.systemInputKeyboardLayout.currentText()
        common.writeSystem(values)
        common.writeKeyboardLayout(values["keyboardLayout"])
        # reboot system
        result = common.confirmDialog(
            self, common.getRessource("systemShutdownTitle"),
            common.getRessource("systemAssumeMessage"))

        common.deleteConfigScript()
        if self.systemInputScreensaver.isChecked():
            common.setScreensaver("on")
        else:
            common.setScreensaver("off")
        if self.systemInputMonitorStandby.isChecked():
            common.setMonitorStandby("on")
        else:
            common.setMonitorStandby("off")

        if result:
            common.deleteConfigScript()
            if self.systemInputScreensaver.isChecked():
                common.setScreensaver("on")
            else:
                common.setScreensaver("off")

            if self.systemInputMonitorStandby.isChecked():
                common.setMonitorStandby("on")
            else:
                common.setMonitorStandby("off")
            common.setResolution(self.systemInputResolution.text())

            if self.systemInputUSBAutomount.isChecked():
                common.setUSBAutomount("on")
            else:
                common.setUSBAutomount("off")

            common.setResolution(self.systemInputResolution.text())
            if self.systemInputOneninedesign.isChecked():
                common.setOneninedesign("on")
            else:
                common.setOneninedesign("off")

            if self.systemInputArgon1.isChecked():
                common.setArgon1("on")
            else:
                common.setArgon1("off")

            common.runProgram(common.getRessource("commandReboot"))
コード例 #12
0
    def connectionExec(self, values):
        logging.info("connectionExec")

        repeat = True
        while repeat:
            run = 0

            while run < 2:
                connectionname = values["name"]
                command = values["command"]
                systemlogin = values["systemlogin"]
                logging.info("connectionExec " + connectionname)

                result = True
                if systemlogin == "yes":
                    common.runProgram(common.getRessource("commandWMDesktop"))
                    logging.info("loginDialog")
                    dialogLogin = dialoglogin.dialogLoginUI(
                        self.configfile, connectionname)
                    dialogLogin.exec_()
                    result = dialogLogin.getResult()
                    if result is True:
                        # replace parameter <user> and <password> in command string
                        command = command.replace(
                            common.getRessource("commandPlaceholderUser"),
                            dialogLogin.getLogin())
                        command = command.replace(
                            common.getRessource("commandPlaceholderPassword"),
                            dialogLogin.getPassword())

                if result:
                    result = common.isHostAlive(values["address"])

                if result:
                    break
                else:
                    if "alternative" in values:
                        if values["alternative"] != "":
                            alternative = values["alternative"]
                            values = []
                            values = common.readConnection(alternative)
                            if not "name" in values:
                                break
                        else:
                            break
                    else:
                        break

                run = run + 1

            if result:
                # connect to Desktop 1
                commandwm = common.getRessource("commandWMDesktop")
                command = commandwm + " " + command
                logging.info(command)
                # run connection as thread
                runconnect = connectThread.connectThread(
                    command, connectionname)
                runconnect.threadCancel.connect(self.connectThreadCancel)
                #self.connect(runconnect, QtCore.SIGNAL(
                #             "connectThreadCancel(QString)"), self.connectThreadCancel)
                self.connectedThreads[connectionname] = runconnect
                runconnect.start()
                break
            else:
                #common.messageDialog("connectNoConnection", False)
                repeat = common.cancelDialog("connectNoConnection")
コード例 #13
0
ファイル: thinclient.py プロジェクト: xtc-Thin-Client/xtcapp
    def save(self):
        logging.info("save and restart")
        values = {}
        # check password
        if self.systemInputStartAdmin.isChecked() == False:
            password = self.systemInputPassword.text()
            values["adminPassword"] = password
            passwordrepeat = self.systemInputPasswordRepeat.text()
            if password == "":
                common.messageDialog("systemRemotePasswordError")
                return
            if self.PasswordChanged:
                if password == passwordrepeat:
                    values["adminPassword"] = common.convertPassword(password)
                else:
                    common.messageDialog("systemPasswordComparisonError")
                    return

        # check remote vnc password
        if self.systemInputRemoteVNC.isChecked(
        ) and self.RemotePasswordChanged:
            vncpassword = self.systemInputRemotePassword.text()
            passwordrepeat = self.systemInputRemotePasswordRepeat.text()
            if vncpassword == "":
                common.messageDialog("systemRemotePasswordError")
                return
            if vncpassword != passwordrepeat:
                common.messageDialog("systemPasswordComparisonError")
                return

        # check ssh password
        if self.systemInputSSH.isChecked() and self.sshPasswordChanged:
            sshpassword = self.systemInputsshPassword.text()
            passwordrepeat = self.systemInputsshPasswordRepeat.text()
            if sshpassword == "":
                common.messageDialog("systemsshPasswordError")
                return
            if sshpassword != passwordrepeat:
                common.messageDialog("systemPasswordComparisonError")
                return

        # action time is string, convert to datetime or hour:minute
        value = self.timeInputActionTime.text()
        if value != "":
            # hour:minute
            if value.startswith("+"):
                value = value.replace("+", "")
                try:
                    time = datetime.strptime(value, "%H:%M")
                except ValueError as error:
                    common.messageDialog("timeActionError")
                    return
            else:
                try:
                    time = datetime.strptime(value, "%Y-%m-%d %H:%M")
                except ValueError as error:
                    common.messageDialog("timeActionError")
                    return

        # network
        if self.networkInputSave.isChecked() == False:
            networkvalues = {}
            networkvalues[
                "connection"] = self.networkInputInterface.currentText()
            networkvalues["address"] = self.networkInputAddress.text()
            networkvalues["subnetmask"] = self.networkInputSubnetmask.text()
            networkvalues["gateway"] = self.networkInputGateway.text()
            networkvalues["dns"] = self.networkInputDNS.text()
            networkvalues["ssid"] = self.networkInputWlanSSID.currentText()
            networkvalues["password"] = self.networkInputWlanPassword.text()

            if self.networkInputDHCP.isChecked():
                common.networkWriteDHCP(networkvalues)
            else:
                result = common.networkWriteStaticIP(networkvalues)
                if not result:
                    return

        # vpn
        vpn.vpnTransfer(self)

        # system
        if self.systemInputStartAdmin.isChecked():
            values["startAdmin"] = "yes"
        else:
            values["startAdmin"] = "no"

        if self.systemInputRemoteVNC.isChecked():
            if self.RemotePasswordChanged:
                common.remoteVNC(True, vncpassword)
        else:
            common.remoteVNC(False, None)

        if self.systemInputSSH.isChecked():
            if self.sshPasswordChanged:
                common.remoteSSH(True, self.systemInputsshPassword.text())
        else:
            common.remoteSSH(False, None)

        values["resolution"] = self.systemInputResolution.currentText()
        values["resolution2"] = self.systemInputResolution2.currentText()

        orientation = "left"
        if self.systemInputMultiMonitorLeft.isChecked():
            orientation = "left"
        if self.systemInputMultiMonitorRight.isChecked():
            orientation = "right"
        if self.systemInputMultiMonitorAbove.isChecked():
            orientation = "above"
        if self.systemInputMultiMonitorBelow.isChecked():
            orientation = "below"

        common.setMultiMonitor(True, orientation)

        values["language"] = self.systemInputLanguage.currentText()
        values["keyboardLayout"] = self.systemInputKeyboardLayout.currentText()

        values["startMinimized"] = "no"
        if self.systemInputMinimize.isChecked():
            values["startMinimized"] = "yes"

        values["networkSave"] = "yes"
        if self.networkInputSave.isChecked():
            values["networkSave"] = "no"
        # write system file
        common.writeSystem(values)

        common.writeKeyboardLayout(values["keyboardLayout"])
        # write system file
        common.deleteConfigScript()

        if self.systemInputScreensaver.isChecked():
            common.setScreensaver("on")
        else:
            common.setScreensaver("off")
        if self.systemInputMonitorStandby.isChecked():
            common.setMonitorStandby("on")
        else:
            common.setMonitorStandby("off")

        common.deleteConfigScript()
        if self.systemInputScreensaver.isChecked():
            common.setScreensaver("on")
        else:
            common.setScreensaver("off")

        if self.systemInputMonitorStandby.isChecked():
            common.setMonitorStandby("on")
        else:
            common.setMonitorStandby("off")

        common.setResolution(self.systemInputResolution.currentText())

        if self.systemInputUSBAutomount.isChecked():
            common.setUSBAutomount("on")
        else:
            common.setUSBAutomount("off")

        if self.systemInputOneninedesign.isChecked():
            common.setOneninedesign("on")
        else:
            common.setOneninedesign("off")

        if self.systemInputArgon1.isChecked():
            common.setArgon1("on")
        else:
            common.setArgon1("off")

        common.setSoundCard(self.systemInputSound.currentText())

        # write time
        values = {}
        values["save"] = "yes"
        if self.timeInputSave.isChecked():
            values["save"] = "no"
        values["automatic"] = "no"
        if self.timeInputAuto.isChecked():
            values["automatic"] = "yes"
        values["ntp"] = self.timeInputNTP.text()
        values["zone"] = self.timeInputTimezone.currentText()
        values["repeat"] = "no"
        if self.timeInputActionRepeat.isChecked():
            values["repeat"] = "yes"
        values["time"] = self.timeInputTime.text()
        values["execute"] = "no"
        if self.timeInputAction.isChecked():
            values["execute"] = "yes"
        values["action"] = self.timeInputActionAction.currentText()
        values["execat"] = self.timeInputActionTime.text()
        common.writeTime(values)

        # write time temp. file for save and reboot
        values = {}
        values["show"] = "no"
        if self.timeInputView.isChecked():
            values["show"] = "yes"
        common.writeTimeTemp(values)

        # reboot system
        result = common.confirmDialog(
            self, common.getRessource("systemShutdownTitle"),
            common.getRessource("systemAssumeMessage"))
        if result:
            command = common.getRessource("commandReboot")
            common.runProgram(command)
コード例 #14
0
    def connectionExec(self, values):
        # logging
        configfile = common.ressourcefile
        loggingfilename = common.getRessourceByName(configfile,
                                                    "loggingFileRun")
        debugfile = common.getRessourceByName(configfile, "debugSwitch")
        debug = False
        if os.path.isfile(debugfile):
            debug = True
        common.loggingStart(loggingfilename, debug)
        logging.info("connectionExec")

        run = 0
        while run < 2:
            connectionname = values["name"]
            command = values["command"]
            systemlogin = values["systemlogin"]
            logging.info("connectionExec " + connectionname)

            result = True
            if systemlogin == "yes":
                common.runProgram(common.getRessource("commandWMDesktop"))
                logging.info("loginDialog")
                dialogLogin = dialoglogin.dialogLoginUI(
                    configfile, connectionname)
                dialogLogin.exec_()
                result = dialogLogin.getResult()
                if result is True:
                    # replace parameter <user> and <password> in command string
                    command = command.replace(
                        common.getRessource("commandPlaceholderUser"),
                        dialogLogin.getLogin())
                    command = command.replace(
                        common.getRessource("commandPlaceholderPassword"),
                        dialogLogin.getPassword())

            if result:
                result = common.isHostAlive(values["address"])

            if result:
                break
            else:
                if "alternative" in values:
                    if values["alternative"] != "":
                        alternative = values["alternative"]
                        values = []
                        values = common.readConnection(alternative)
                        if not "name" in values:
                            break
                    else:
                        break
                else:
                    break
            run = run + 1

        if result:
            # connect to Desktop 1
            commandwm = common.getRessource("commandWMDesktop")
            command = commandwm + " " + command
            logging.info(command)
            # run connection as thread
            self.runconnect = connectThread.connectThread(
                command, connectionname)
            self.runconnect.threadCancel.connect(self.connectThreadCancel)
            self.runconnect.start()
        else:
            common.messageDialog("runNoConnection")
            self.close()