Пример #1
0
    def get_product():
        product = ""
        os_type = SystemInfo.get_type()
        if os_type.strip().lower() == "linux":
            if SystemInfo.get_name().strip().lower().find("raspbian") >= 0:
                try:
                    f = open('/sys/firmware/devicetree/base/model', 'r')
                    product = f.read()
                    f.close()
                except Exception as e:
                    product = "get hardware product error in raspbian system"
            else:
                # need sudo
                command = "dmidecode -t system"
                status, output = get_command_output(command)
                if status == 0:
                    lines = output.splitlines()
                    for line in lines:
                        if line.strip().find("Manufacturer") >= 0:
                            product = product + line.split(":")[1].strip()
                        if line.strip().find("Product Name") >= 0:
                            product = product + "/" + line.split(
                                ":")[1].strip()
                        if line.strip().find("Version") >= 0:
                            product = product + "/" + line.split(
                                ":")[1].strip()
                else:
                    product = "get hardware product error in linux system"
        else:
            product = "do not support non-linux operating system"

        product = product.replace('\x00', '')
        return product
Пример #2
0
 def get_firefox_version(self):
     firefox_version = "0"
     if self.get_series() and "debian" == self.get_series().lower():
         command = "firefox --version"
         status, output = get_command_output(command)
         if status == 0:
             firefox_version = output.split()[2]
     return firefox_version
Пример #3
0
 def get_chrome_version(self):
     chrome_version = "0"
     if self.get_series() and "debian" == self.get_series().lower():
         command = "chromium-browser --version"
         status, output = get_command_output(command)
         if status == 0:
             chrome_version = output.split()[1]
     return chrome_version
Пример #4
0
 def get_desktop_version(self):
     desktop_version = "UNKNOWN"
     if self.get_series() and "debian" == self.get_series().lower():
         status, output = get_command_output(
             "dpkg -l | grep gnome-desktop3-data")
         if status == 0 and output:
             osp = output.split()
             if len(osp) > 2:
                 desktop_version = osp[2]
     return desktop_version
Пример #5
0
 def get_firefox_webdirver():
     firefox_webdriver_path = ""
     firefox_webdirver_version = "0"
     firefox_webdriver_paths = ["/usr/local/bin/geckodriver"]
     for path in firefox_webdriver_paths:
         command = "ls " + path
         status, output = get_command_output(command)
         if status == 0:
             firefox_webdriver_path = path
         break
     # 如果在这2个目录中找到了, 就得到版本信息.
     if firefox_webdriver_path:
         command = path + " --version"
         status, output = get_command_output(command)
         if status == 0:
             firefox_webdirver_version = output.split()[1]
     # 否则, 查找 chromedriver 文件, 得到版本信息
     else:
         # TODO, 查找 geckodriver, 得到版本信息
         pass
     return firefox_webdriver_path, firefox_webdirver_version
Пример #6
0
    def get_sn():
        sn = None
        system_type = SystemInfo.get_type().strip().lower()
        system_name = SystemInfo.get_name().strip().lower()
        if system_type == "linux":
            if system_name and system_name.strip().lower().find(
                    "raspbian") >= 0:
                # for raspberry pi
                # The serial number can be found in /proc/cpuinfo
                # cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2
                command = "cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2"
                status, output = get_command_output(command)
                if status == 0:
                    sn = output
                else:
                    logger.error(
                        "cannot get serial number from /proc/cpuinfo for raspbian"
                    )
            else:
                command1 = "sudo dmidecode -t system | grep -i serial | cut -d ':' -f 2"
                status1, output1 = get_command_output(command1)
                if status1 == 0 and output1.strip() != "0":
                    sn = output1.strip()
                else:
                    command2 = "sudo dmidecode -t system | grep UUID"
                    status2, output2 = get_command_output(command2)
                    if status2 == 0:
                        sn = output2.split(":")[1].strip()
                    else:
                        logger.error("cannot get uuid using dmidecode")
        else:
            logger.error("just support linux system")

        # 如果得不到sn, 使用缺省网卡的mac地址
        if not sn:
            sn = NetInfo.get_default_mac()
        return sn
Пример #7
0
 def get_chrome_webdirver():
     chrome_webdriver_path = ""
     chrome_webdirver_version = "0"
     chrome_webdriver_paths = [
         "/usr/local/bin/chromedriver",
         "/usr/lib/chromium-browser/chromedriver"
     ]
     for path in chrome_webdriver_paths:
         command = "ls " + path
         status, output = get_command_output(command)
         if status == 0:
             chrome_webdriver_path = path
         break
     # 如果在这2个目录中找到了, 就得到版本信息.
     if chrome_webdriver_path:
         command = path + " --version"
         status, output = get_command_output(command)
         if status == 0:
             chrome_webdirver_version = output.split()[1]
     # 否则, 查找 chromedriver 文件, 得到版本信息
     else:
         # TODO, 查找 chromedriver, 得到版本信息
         pass
     return chrome_webdriver_path, chrome_webdirver_version
Пример #8
0
 def get_selenium_version(self):
     selenium_version = "0"
     if self.get_python_version().split(".")[0] == "3":
         command = "pip3 list | grep selenium"
     else:
         command = "pip list | grep selenium"
     status, output = get_command_output(command)
     if status == 0:
         # some result like this
         # DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
         # selenium (3.141.0)
         rows = output.split("\n")
         for row in rows:
             if row and row.strip().lower().rfind("selenium") >= 0:
                 selenium_version = row.split()[1].strip("(").strip(")")
     return selenium_version