Beispiel #1
0
    def run(self):
        try:
            output = sh.test("-e", "%s/reboot-failed" % self.path_root)
            if output.exit_code == 0:
                self.publish.event.put("/system/reboot",
                                       data={
                                           "code": "REBOOT_FAIL",
                                           "type": "event"
                                       })
            sh.rm("-rf", "%s/reboot-failed" % self.path_root)
        except sh.ErrorReturnCode_1:
            pass

        try:
            output = sh.test("-e", "%s/rebooting" % self.path_root)
            if output.exit_code == 0:
                _logger.info("Reboot success!")
                self.publish.event.put("/system/reboot",
                                       data={
                                           "code": "REBOOT_SUCCESS",
                                           "type": "event"
                                       })
            sh.rm("-rf", "%s/rebooting" % self.path_root)
        except sh.ErrorReturnCode_1:
            pass
        sh.sync()
 def __enter__(self):
     try:
         sh.test('-d', self.path)
         self.already_disabled = False
     except sh.ErrorReturnCode_1:
         self.already_disabled = True
     else:
         sh.mv(self.path, self.hidden_path)
Beispiel #3
0
 def __enter__(self):
     try:
         sh.test('-d', self.path)
         self.already_disabled = False
     except sh.ErrorReturnCode_1:
         self.already_disabled = True
     else:
         sh.mv(self.path, self.hidden_path)
Beispiel #4
0
    def run(self):
        try:
            output = sh.test("-e", "%s/reboot-failed" % self.path_root)
            if output.exit_code == 0:
                self.publish.event.put(
                    "/system/reboot",
                    data={"code": "REBOOT_FAIL", "type": "event"})
            sh.rm("-rf", "%s/reboot-failed" % self.path_root)
        except sh.ErrorReturnCode_1:
            pass

        try:
            output = sh.test("-e", "%s/rebooting" % self.path_root)
            if output.exit_code == 0:
                _logger.info("Reboot success!")
                self.publish.event.put(
                    "/system/reboot",
                    data={"code": "REBOOT_SUCCESS", "type": "event"})
            sh.rm("-rf", "%s/rebooting" % self.path_root)
        except sh.ErrorReturnCode_1:
            pass
        sh.sync()
Beispiel #5
0
    mkdir(build_variant_dir)
    cp('-r', PRISTINE, build_variant_dir)

    with sh.pushd(os.path.join(build_variant_dir, 'simulator')):
        tup('init')
        tup('generate', 'build.sh', '--config',
            os.path.join('configs', variant))
        try:
            errbuf = io.StringIO()
            sh.sh('-x', 'build.sh', _err=errbuf)
        except:
            errbuf.seek(0)
            for l in errbuf.readlines():
                print(l, end='')
            raise
        sh.test('-x', 'simulator')

        log.info("Built {}".format(variant_file))

        any_fail = False

        sim = sh.Command('./simulator')
        for test in glob.iglob('tests/**/*.bin', recursive=True):
            log.info("\t\ttest: %s", test)
            try:
                sim('-f', test)
                log.info("\t\t\tPASSED")
            except sh.ErrorReturnCode as e:
                # XXX: This is a hack
                if 'exceeds ram size' in e.stderr.decode('utf-8'):
                    log.info("\t\t\tSKIPPED -- Test too large for variant")
Beispiel #6
0
    def to_computer(self, text):
        f = open(
            TMP_FILE, 'w'
        )  # write mode clears any previous content from the file if it exists

        if self.checks[0]:
            print("Saving: inxi to file")
            f.write(
                HEADER.format("Inxi -Fxzc0", "Listing computer information"))
            try:
                f.write(str(inxi('-Fxxxzc0')))
            except:
                " 'inxi' not found, install it to get this info"
            f.write('\n')

        if self.checks[1]:
            print("Getting info about installed graphical driver")
            f.write(
                HEADER.format("Installed drivers",
                              "Shows which graphic driver is installed"))
            try:
                f.write(str(mhwd('-li')))
            except:
                print(" 'mhwd' not found, this is not Manjaro?")
            f.write('\n')

        if self.checks[2]:
            print("Getting list of all drivers supported on detected gpu's")
            f.write(
                HEADER.format(
                    "Available drivers",
                    "list of all drivers supported on detected gpu's"))
            try:
                f.write(str(mhwd('-l')))
            except:
                print(" 'mhwd' not found, this is not Manjaro?")
            # f.write('\n')

        if self.checks[3]:
            print('hwinfo -graphic card')
            # os.system('hwinfo --gfxcard')
            f.write(HEADER.format("hwinfo --gfxcard",
                                  "Show Graphic Card info"))
            try:
                f.write(str(hwinfo('--gfxcard')))
            except:
                print('hwinfo graphic card info error')
                f.write('hwinfo graphic card info error')
            f.write('\n')

        if self.checks[4]:
            print('memory info')
            # os.system('free -h')
            f.write(HEADER.format("Memory Info", "Info about Memory and Swap"))
            try:
                f.write(str(free(' -h')))
            except:
                print('memory info error')
                f.write('memory info error')
            f.write('\n')

        if self.checks[5]:
            print('disk info')
            # os.system('lsblk')
            f.write(HEADER.format("Disk Info", "Disks and Partitions"))
            try:
                f.write(str(lsblk()))
            except:
                print('lsblk error')
                f.write('lsblk error')
            f.write('\n')

        if self.checks[6]:
            print('free disk space')
            # os.system('df')
            f.write(
                HEADER.format("Free Disk Space", "Free space per pertition"))
            try:
                f.write(str(df()))
            except:
                print('free disk space error')
                f.write('free disk space error')
            f.write('\n')

        if self.checks[7]:
            print('blockdev')
            # os.system('blockdev --getalignoff /dev/sda')
            f.write(HEADER.format("Disk Alignment", "0 is OK"))
            try:
                # f.write(str(os.system('blockdev --getalignoff /dev/sda')))
                f.write(str(blockdev(' --getalignoff /dev/sda')))
            except:
                print('error with blockdev')
                f.write('error with blockdev')
            f.write('\n')

        if self.checks[8]:
            print('BIOS / UEFI')
            # os.system('test -d /sys/firmware/efi && echo UEFI || echo BIOS')
            # os.system('parted -l | grep "Partition Table: "')
            f.write(HEADER.format("parted -l", "BIOS+msdos or UEFI+gpt"))
            try:
                f.write(
                    str(test(
                        ' -d /sys/firmware/efi && echo UEFI || echo BIOS')))
                # f.write(str(test -d(' /sys/firmware/efi && echo UEFI || echo BIOS')))
                f.write(str(parted(' -l | grep "Partition Table: "')))
                # f.write(str(parted -l(' | grep "Partition Table: "')))
            except:
                print('error with BIOS / UEFI')
                f.write('error with BIOS / UEFI')
            f.write('\n')

        if self.checks[9]:
            print("Saving: Xorg.0.log to file")
            f.write(
                HEADER.format("Xorg.0.log",
                              "searching for: failed, error & (WW) keywords"))
            try:
                f.write(
                    look_in_file('/var/log/Xorg.0.log',
                                 ['failed', 'error', '(WW)']))
            except FileNotFoundError:
                print("/var/log/Xorg.0.log not found!")
                f.write("Xorg.0.log not found!")
            f.write('\n')

        if self.checks[10]:
            print("Saving: Xorg.1.log to file")
            f.write(
                HEADER.format("Xorg.1.log",
                              "searching for: failed, error & (WW) keywords"))
            try:
                f.write(
                    look_in_file('/var/log/Xorg.1.log',
                                 ['failed', 'error', '(WW)']))
            except FileNotFoundError:
                print("/var/log/Xorg.1.log not found!")
                f.write("Xorg.1.log not found!")
            f.write('\n')

        if self.checks[11]:
            print("Saving: pacman.log to file")
            f.write(
                HEADER.format(
                    "pacman.log",
                    "searching for: pacsave, pacnew, pacorig keywords"))
            try:
                f.write(
                    look_in_file('/var/log/pacman.log',
                                 ['pacsave', 'pacnew', 'pacorig']))
            except FileNotFoundError:
                print(
                    "/var/log/pacman.log not found, this is not Manjaro or Arch based Linux?"
                )
                f.write("pacman.log not found!  Not Arch based OS?")
            f.write('\n')

        if self.checks[12]:
            print("Saving: journalctl (emergency) to file")
            os.system("journalctl -b > /tmp/journalctl.txt")
            f.write(
                HEADER.format("journalctl.txt",
                              "Searching for: Emergency keywords"))
            f.write(
                look_in_file('/tmp/journalctl.txt',
                             ['emergency', 'Emergency', 'EMERGENCY']))
            f.write('\n')

        if self.checks[13]:
            print("Saving: journalctl (alert) to file")
            os.system("journalctl -b > /tmp/journalctl.txt")
            f.write(
                HEADER.format("journalctl.txt",
                              "Searching for: Alert keywords"))
            f.write(
                look_in_file('/tmp/journalctl.txt',
                             ['alert', 'Alert', 'ALERT']))
            f.write('\n')

        if self.checks[14]:
            print("Saving: journalctl (critical) to file")
            os.system("journalctl -b > /tmp/journalctl.txt")
            f.write(
                HEADER.format("journalctl.txt",
                              "Searching for: Critical keywords"))
            f.write(
                look_in_file('/tmp/journalctl.txt',
                             ['critical', 'Critical', 'CRITICAL']))
            f.write('\n')

        if self.checks[15]:
            print("Saving: journalctl (failed) to file")
            os.system("journalctl -b > /tmp/journalctl.txt")
            f.write(
                HEADER.format("journalctl.txt",
                              "Searching for: Failed keywords"))
            f.write(
                look_in_file('/tmp/journalctl.txt',
                             ['failed', 'Failed', 'FAILED']))
            f.write('\n')

        if self.checks[16]:
            print("Saving: rc.log to file")
            f.write(
                HEADER.format("rc.log",
                              "OpenRc only! searching for: WARNING: keywords"))
            try:
                f.write(look_in_file('/var/log/rc.log', ['WARNING:']))
            except FileNotFoundError:
                print("/var/log/rc.log not found!     Systemd based OS?")
                f.write("rc.log not found!   Systemd based OS?")
            f.write('\n')

        if self.checks[17]:
            print('openrc services status')
            # os.system('rc-status --all')
            f.write(HEADER.format("Services", "OpenRc only!"))
            try:
                f.write(str(rc - status(' --all')))
            except:
                print("rc-status all error")
                f.write("rc.log not found!   Systemd based OS?")
            f.write('\n')

        f.close()
Beispiel #7
0
variants = {}

for variant_file in os.listdir('simulator/configs'):
	log.info("Building {}".format(variant_file))

	variant = os.path.basename(variant_file)

	build_variant_dir = os.path.join(BUILD_DIR, variant)
	mkdir(build_variant_dir)
	cp('-r', PRISTINE, build_variant_dir)

	with sh.pushd(os.path.join(build_variant_dir, 'simulator')):
		tup('generate', 'build.sh', '--config', os.path.join('configs', variant))
		sh.Command('./build.sh')()
		sh.test('-x', 'simulator')

		log.info("Built {}".format(variant_file))

		any_fail = False

		sim = sh.Command('./simulator')
		for test in glob.iglob('tests/**/*.bin', recursive=True):
			log.info("\t\ttest: %s", test)
			try:
				sim('-f', test)
				log.info("\t\t\tPASSED")
			except sh.ErrorReturnCode as e:
				# XXX: This is a hack
				if 'exceeds ram size' in e.stderr.decode('utf-8'):
					log.info("\t\t\tSKIPPED -- Test too large for variant")