예제 #1
0
def getCPU():
    cpumodel = controls.execute(
        "lscpu | grep 'Model name:' | cut -d':' -f2 | sed -e 's/^[[:space:]]*//'| tr -d '\n'"
    )
    cpucore = controls.execute(
        "lscpu | grep '^CPU(s):' | cut -d':' -f2 | sed -e 's/^[[:space:]]*//'| tr -d '\n'"
    )
    return (cpumodel + " - " + cpucore)
예제 #2
0
def checkConfigFiles():
    if checkPalamar() == True:
        if controls.execute("cat /usr/share/palamar/palamar.conf | grep -w DomainIP | cut -d '=' -f2") == "" or\
            controls.execute("cat /usr/share/palamar/palamar.conf | grep -w Hostname | cut -d '=' -f2") == "" or\
            controls.execute("cat /usr/share/palamar/palamar.conf | grep -w DomainUsername | cut -d '=' -f2") == "":
            print("f2")
            return False
    else:
        print("f")
        return False
    print("true")
    return True
예제 #3
0
    def on_send_click(self, button):
        try:
            buffer = self.textview.get_buffer()
            text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False)
            print(text)
 
            hostname = controls.execute("hostname")
            username = controls.execute("whoami")           


            list_of_files = glob.glob(summary.MAINDIR+'ss/*')
            latest_file = max(list_of_files, key=os.path.getctime)

            data = []
            data.append({
                "machine_name": hostname,
                "username": username,
                "note": text,
                "filename": latest_file
            })

            with open(summary.MAINDIR + "ss/main.json", "a") as outfile:
                json.dump(data, outfile)

            file_object = open(summary.MAINDIR + "ss/main.json", 'a')
            file_object.write("\n")
            file_object.close()

            # create new script that handles all api calls

            self.window.close()
        except Exception as e:
            message.log_error("Exception occurred: " + str(e))
            message.MessageDialogWindow().error_dialog(_("Error"), 
                _("There has been an error while sending information to the server. Please try again later"))
            
            self.window.close()
        return True
예제 #4
0
    def on_close_notification_click(self, button, notification_text,
                                    notification_index):
        try:
            hostname = controls.execute("hostname")
            data = {
                "machine_name": hostname,
                "message": notification_text,
                "index": notification_index
            }

            resp = requests.delete(self.notifications_address,
                                   data=data).json()
            message.log_info(resp)
        except Exception as e:
            message.log_error("Exception occurred: " + str(e))
예제 #5
0
    def handle_keys_thread(self):
        while True:

            # We need some way of knowing when to quit execution of this method.
            if self.finish_flag == 0:
                break

            # Make sure this time period is shorter than:
            # (network latency + command duration on the car).
            # Otherwise the car motors will stutter.
            time.sleep(0.01)

            # Translate keys into commands and hand them over to the control pacakge.
            commands = set()

            if len(self.pressed_keys) == 0:
                continue

            f_speed = self.slider_fs.value() / 100.0
            b_speed = self.slider_bs.value() / 100.0

            if QtCore.Qt.Key_Shift in self.pressed_keys:
                f_speed = 1.0
                b_speed = 1.0

            for key in self.pressed_keys:
                if key == QtCore.Qt.Key_Up or key == QtCore.Qt.Key_W:
                    commands.add('f' + str(f_speed))  # Forward
                elif key == QtCore.Qt.Key_Down or key == QtCore.Qt.Key_S:
                    commands.add('b' + str(b_speed))  # Backwards
                elif key == QtCore.Qt.Key_Right or key == QtCore.Qt.Key_D:
                    commands.add('r')  # Steer right
                elif key == QtCore.Qt.Key_Left or key == QtCore.Qt.Key_A:
                    commands.add('l')  # Steer left
            controls.execute(commands, config.controls_sock, config.car_addr,
                             config.controls_port)
예제 #6
0
 def get_notifications(self, tray):
     try:
         hostname = controls.execute("hostname")
         data = {"machine_name": hostname}
         self.response = (requests.post(self.get_notifications_address,
                                        data=data)).json()
         self.count = self.response['count']
         if (self.count > 0):
             tray.set_from_file(summary.MAINDIR + "images/Notification.png")
         else:
             tray.set_from_file(summary.MAINDIR + "images/Computer.png")
         tray.is_server_up = True
     except Exception as e:
         tray.is_server_up = False
         tray.set_from_file(summary.MAINDIR + "images/Computer.png")
         message.log_error("Exception occurred: " + str(e))
예제 #7
0
def getDist():
    return controls.execute(
        "lsb_release -ir | cut -d':' -f2| sed -e 's/^[[:space:]]*//'| tr '\n' ' '"
    )
예제 #8
0
def getRAM():
    memory = controls.execute("awk '/MemTotal/ {print $2}' /proc/meminfo")
    memory = round(int(memory) / 1024 / 1000, 2)
    return (str(memory) + " GB")
예제 #9
0
def getHostname():
    return controls.execute("hostname | tr -d '\n'")
예제 #10
0
def getWorkgroup():
    return controls.execute(
        "net ads workgroup | cut -d':' -f2 | tr -d ' ' | tr -d '\n'")
예제 #11
0
def getDomain():
    return controls.execute(
        "net ads info 2> /dev/null | grep Realm | cut -d':' -f2 | tr -d ' ' | tr -d '\n'"
    )
예제 #12
0
def checkPalamar():
    if controls.execute("which palamar") == "":
        return False
    return True