MCPcopy Create free account
hub / github.com/bitsadmin/wesng / determine_product

Function determine_product

wes.py:544–654  ·  view source on GitHub ↗
(systeminfo)

Source from the content-addressed store, hash-verified

542
543# Determine Windows version based on the systeminfo input file provided
544def determine_product(systeminfo):
545 systeminfo = charset_convert(systeminfo)
546
547 # Fixup for 7_sp1_x64_enterprise_fr_systeminfo_powershell.txt
548 systeminfo = systeminfo.replace('\xA0', '\x20')
549
550 # OS Version
551 regex_version = re.compile(r'.*?((\d+\.?){3}) ((Service Pack (\d)|N\/\w|.+) )?[ -\xa5]+ (\d+).*', re.MULTILINE | re.IGNORECASE)
552 systeminfo_matches = regex_version.findall(systeminfo)
553 if len(systeminfo_matches) == 0:
554 raise WesException('Not able to detect OS version based on provided input file\n In case you used the missingkbs script, use: wes.py -m missing.txt')
555
556 systeminfo_matches = systeminfo_matches[0]
557 mybuild = int(systeminfo_matches[5])
558 servicepack = systeminfo_matches[4]
559
560 # OS Name
561 win_matches = re.findall(r'.*?Microsoft[\(R\)]{0,3} Windows[\(R\)?]{0,3} ?(Serverr? )?(\d+\.?\d?( R2)?|XP|VistaT).*', systeminfo, re.MULTILINE | re.IGNORECASE)
562 if len(win_matches) == 0:
563 raise WesException('Not able to detect OS name based on provided input file')
564 win = win_matches[0][1]
565
566 # System Type
567 archs = re.findall(r'.*?([\w\d]+?)-based PC.*', systeminfo, re.MULTILINE | re.IGNORECASE)
568 if len(archs) > 0:
569 arch = archs[0]
570 else:
571 logging.warning('Cannot determine system\'s architecture. Assuming x64')
572 arch = 'x64'
573
574 # Hotfix(s)
575 hotfixes = get_hotfixes(systeminfo)
576
577 # Determine Windows 10/11 version based on build
578 version = None
579 for build in buildnumbers:
580 if mybuild == build:
581 version = buildnumbers[build]
582 break
583 if mybuild > build:
584 version = buildnumbers[build]
585 else:
586 break
587
588 # Compile name for product filter
589 # Architecture
590 if win not in ['XP', 'VistaT', '2003', '2003 R2']:
591 if arch == 'X86':
592 arch = '32-bit'
593 elif arch == 'x64':
594 arch = 'x64-based'
595
596 # Client OSs
597 if win == 'XP':
598 productfilter = 'Microsoft Windows XP'
599 if arch != 'X86':
600 productfilter += ' Professional %s Edition' % arch
601 if servicepack:

Callers 1

mainFunction · 0.85

Calls 3

charset_convertFunction · 0.85
WesExceptionClass · 0.85
get_hotfixesFunction · 0.85

Tested by

no test coverage detected