Exemplo n.º 1
0
    def send_command(self, cmd, get_output=False):
        if get_output:
            with tempfile.TemporaryFile() as directed_file:
                backup_stdout_fileno = os.dup(sys.stdout.fileno())
                os.dup2(directed_file.fileno(), sys.stdout.fileno())

                self.lib.sm_backend_exec_cmd(ctypes.c_char_p(misc.encode(cmd)))

                os.dup2(backup_stdout_fileno, sys.stdout.fileno())
                os.close(backup_stdout_fileno)
                directed_file.seek(0)
                return directed_file.readlines()
        else:

            self.lib.sm_backend_exec_cmd(ctypes.c_char_p(misc.encode(cmd)))
Exemplo n.º 2
0
    def send_command(self, cmd, get_output = False):
        if get_output:
            with tempfile.TemporaryFile() as directed_file:
                backup_stdout_fileno = os.dup(sys.stdout.fileno())
                os.dup2(directed_file.fileno(), sys.stdout.fileno())

                self.lib.sm_backend_exec_cmd(ctypes.c_char_p(misc.encode(cmd)))

                os.dup2(backup_stdout_fileno, sys.stdout.fileno())
                os.close(backup_stdout_fileno)
                directed_file.seek(0)
                return directed_file.read()
        else:

            self.lib.sm_backend_exec_cmd(ctypes.c_char_p(misc.encode(cmd)))
Exemplo n.º 3
0
 def get_type_size(self, typename, value):
     if typename in TYPESIZES:  # int or float type; fixed length
         return TYPESIZES[typename]
     elif typename == 'bytearray':
         return (len(value.strip()) + 1) / 3
     elif typename == 'string':
         return len(misc.encode(value))
     return None
Exemplo n.º 4
0
    def send_command(self, cmd, get_output=False):
        """
        Execute command using libscanmem.
        This function is NOT thread safe, send only one command at a time.
        
        cmd: command to run
        get_output: if True, return in a string what libscanmem would print to stdout
        """
        if get_output:
            with tempfile.TemporaryFile() as directed_file:
                backup_stdout_fileno = os.dup(sys.stdout.fileno())
                os.dup2(directed_file.fileno(), sys.stdout.fileno())

                self._lib.sm_backend_exec_cmd(ctypes.c_char_p(
                    misc.encode(cmd)))

                os.dup2(backup_stdout_fileno, sys.stdout.fileno())
                os.close(backup_stdout_fileno)
                directed_file.seek(0)
                return directed_file.read()
        else:
            self._lib.sm_backend_exec_cmd(ctypes.c_char_p(misc.encode(cmd)))
Exemplo n.º 5
0
    def start_mining(self):
        home = self.root.get_screen("HomeScreen")

        if Config.getboolean("Misc", "saveLogins"):
            Config.set("Misc", "username", home.ids["UsrNameInput"].text)
            Config.set("Misc", "password",
                       encode(str(home.ids["PwdInput"].text), "JonIsGreen"))
            Config.write()

            Logger.info("Logins: Saved")

        Miner = self.root.get_screen("MiningScreen").Miner
        Miner.usrName = home.ids["UsrNameInput"].text
        Miner.pwdInput = home.ids["PwdInput"].text
        Miner.stopOnlyWhenStopPressed = home.ids["MineUntilOrForSwitch"].active
        Miner.mineUntilPoints = None if home.ids[
            "PointsInput"].text == "" else home.ids["PointsInput"].text
        Miner.mineForTime = None if home.ids[
            "TimeInput"].text == "" else home.ids["TimeInput"].text
        Miner.requireAll = home.ids["RequirementsAll"].state == "down"

        self.root.current = "MiningScreen"