def get_windows_sp(self): windows_sp = registry.get_value( 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'CSDVersion') log.debug('windows_sp=%s' % windows_sp) return windows_sp
def get_windows_version2(self): windows_version2 = registry.get_value( 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'ProductName') log.debug('windows_version2=%s' % windows_version2) return windows_version2
def undo_bcd(self, associated_task): bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not isfile(bcdedit): bcdedit = join_path(os.getenv('SystemRoot'), 'sysnative', 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return id = registry.get_value( 'HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive') if not id: log.debug("Could not find bcd id") return log.debug("Removing bcd entry %s" % id) command = [bcdedit, '/delete', id , '/f'] try: run_command(command) registry.set_value( 'HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive', "") except Exception, err: #this shouldn't be fatal log.error(err)
def get_windows_build(self): windows_build = registry.get_value( 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'CurrentBuildNumber') log.debug('windows_build=%s' % windows_build) return windows_build
def get_processor_name(self): processor_name = registry.get_value( 'HKEY_LOCAL_MACHINE', 'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0', 'ProcessorNameString') log.debug('processor_name=%s' % processor_name) return processor_name
def get_country(self): icountry = registry.get_value('HKEY_CURRENT_USER', 'Control Panel\\International', 'iCountry') try: icountry = int(icountry) except: pass country = mappings.icountry2country.get(icountry) if not country: scountry = registry.get_value('HKEY_CURRENT_USER', 'Control Panel\\International', 'sCountry') country = name2country.get(scountry) if not country: country = gmt2country.get(self.info.gmt) if not country: country = "US" log.debug('country=%s' %country) return country
def get_processor_name(self): processor_name = registry.get_value( 'HKEY_LOCAL_MACHINE', 'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0', 'ProcessorNameString') log.debug('processor_name=%s' %processor_name) return processor_name
def get_startup_folder(self): startup_folder = registry.get_value( 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' '\\Explorer\\Shell Folders', 'Common Startup') log.debug('startup_folder=%s' % startup_folder) return startup_folder
def get_previous_target_dir(self): ''' previous_target_dir = [] previous_target_dir.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[0], 'InstallationDir')) previous_target_dir.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[1], 'InstallationDir')) ''' previous_target_dir = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'InstallationDir') log.debug("previous_target_dir=%s" % previous_target_dir) return previous_target_dir
def get_uninstaller_path(self): ''' uninstaller_path = [] uninstaller_path.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[0], 'UninstallString')) uninstaller_path.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[1], 'UninstallString')) ''' uninstaller_path = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'UninstallString') log.debug('uninstaller_path=%s' % uninstaller_path) return uninstaller_path
def get_previous_distro_name(self): ''' previous_distro_name = [] previous_distro_name.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[0], 'DisplayName')) previous_distro_name.append(registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key[1], 'DisplayName')) ''' previous_distro_name = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayName') log.debug("previous_distro_name=%s" % previous_distro_name) return previous_distro_name
def get_gmt(self): gmt = registry.get_value('HKEY_LOCAL_MACHINE', 'SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation', 'Bias') if gmt: gmt = -gmt/60 if not gmt \ or gmt > 12 \ or gmt < -12: gmt = 0 log.debug('gmt=%s' %gmt) return gmt
def modify_bcd(self, drive, associated_task): log.debug("modify_bcd %s" % drive) if drive is self.info.system_drive \ or drive.path == "C:" \ or drive.path == os.getenv('SystemDrive').upper() \ or drive.path == self.info.target_drive.path: src = join_path(self.info.root_dir, 'winboot', 'wubildr') dest = join_path(drive.path, 'wubildr') shutil.copyfile(src, dest) src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr') dest = join_path(drive.path, 'wubildr.mbr') shutil.copyfile(src, dest) bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe') # FIXME: Just test for bcdedit in the PATH. What's the Windows # equivalent of `type`? if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'): log.debug("BCD has already been modified") return if self.info.efi: log.debug("EFI boot") efi_path = self.modify_EFI_folder(associated_task, bcdedit) try: run_command(['powercfg', '/h', 'off']) except Exception, err: #this shouldn't be fatal log.error(err) command = [ bcdedit, '/copy', '{bootmgr}', '/d', '%s' % self.info.distro.name ] id = run_command(command) id = id[id.index('{'):id.index('}') + 1] run_command([bcdedit, '/set', id, 'path', efi_path]) try: run_command([ bcdedit, '/set', '{fwbootmgr}', 'displayorder', id, '/addlast' ]) run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10']) run_command( [bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id]) except Exception, err: #this shouldn't be fatal log.error(err)
def modify_bcd(self, drive, associated_task): log.debug("modify_bcd %s" % drive) if drive is self.info.system_drive \ or drive.path == "C:" \ or drive.path == os.getenv('SystemDrive').upper(): src = join_path(self.info.root_dir, 'winboot', 'wisildr') dest = join_path(drive.path, 'wisildr') shutil.copyfile(src, dest) src = join_path(self.info.root_dir, 'winboot', 'wisildr.mbr') dest = join_path(drive.path, 'wisildr.mbr') shutil.copyfile(src, dest) bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe') # FIXME: Just test for bcdedit in the PATH. What's the Windows # equivalent of `type`? if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'): log.debug("BCD has already been modified") return command = [ bcdedit, '/create', '/d', '%s' % self.info.distro.name, '/application', 'bootsector' ] id = run_command(command) id = id[id.index('{'):id.index('}') + 1] mbr_path = join_path(self.info.target_dir, 'winboot', 'wisildr.mbr')[2:] run_command([ bcdedit, '/set', id, 'device', 'partition=%s' % self.info.target_drive.path ]) run_command([bcdedit, '/set', id, 'path', mbr_path]) run_command([bcdedit, '/displayorder', id, '/addlast']) run_command([bcdedit, '/timeout', '10']) run_command([bcdedit, '/bootsequence', id]) registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive', id)
def modify_bcd(self, drive, associated_task): log.debug("modify_bcd %s" % drive) if drive is self.info.system_drive \ or drive.path == "C:" \ or drive.path == os.getenv('SystemDrive').upper(): src = join_path(self.info.root_dir, 'winboot', 'wubildr') dest = join_path(drive.path, 'wubildr') shutil.copyfile(src, dest) src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr') dest = join_path(drive.path, 'wubildr.mbr') shutil.copyfile(src, dest) bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe') # FIXME: Just test for bcdedit in the PATH. What's the Windows # equivalent of `type`? if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'): log.debug("BCD has already been modified") return if self.info.efi: log.debug("EFI boot") efi_path = self.modify_EFI_folder(associated_task,bcdedit) run_command(['powercfg', '/h', 'off']) command = [bcdedit, '/copy', '{bootmgr}', '/d', '%s' % self.info.distro.name] id = run_command(command) id = id[id.index('{'):id.index('}')+1] run_command([bcdedit, '/set', id, 'path', efi_path]) try: run_command([bcdedit, '/set', '{fwbootmgr}', 'displayorder', id, '/addlast']) run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10']) run_command([bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id]) except Exception, err: #this shouldn't be fatal log.error(err) registry.set_value( 'HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive', id) return
def modify_bcd(self, drive, associated_task): log.debug("modify_bcd %s" % drive) if drive is self.info.system_drive \ or drive.path == "C:" \ or drive.path == os.getenv('SystemDrive').upper(): src = join_path(self.info.root_dir, 'winboot', 'wubildr') dest = join_path(drive.path, 'wubildr') shutil.copyfile(src, dest) src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr') dest = join_path(drive.path, 'wubildr.mbr') shutil.copyfile(src, dest) bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe') # FIXME: Just test for bcdedit in the PATH. What's the Windows # equivalent of `type`? if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'): log.debug("BCD has already been modified") return command = [bcdedit, '/create', '/d', '%s' % self.info.distro.name, '/application', 'bootsector'] id = run_command(command) id = id[id.index('{'):id.index('}')+1] mbr_path = join_path(self.info.target_dir, 'winboot', 'wubildr.mbr')[2:] run_command([bcdedit, '/set', id, 'device', 'partition=%s' % self.info.target_drive.path]) run_command([bcdedit, '/set', id, 'path', mbr_path]) run_command([bcdedit, '/displayorder', id, '/addlast']) run_command([bcdedit, '/timeout', '10']) run_command([bcdedit, '/bootsequence', id]) registry.set_value( 'HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive', id)
def get_uninstaller_path(self): uninstaller_path = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'UninstallString') log.debug('uninstaller_path=%s' % uninstaller_path) return uninstaller_path
def get_previous_target_dir(self): previous_target_dir = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'InstallationDir') log.debug("previous_target_dir=%s" % previous_target_dir) return previous_target_dir
def get_previous_distro_name(self): previous_distro_name = registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayName') log.debug("previous_distro_name=%s" % previous_distro_name) return previous_distro_name
def modify_bcd(self, drive, associated_task): log.debug("modify_bcd %s" % drive) if drive is self.info.system_drive or drive.path == "C:" or drive.path == os.getenv('SystemDrive').upper(): if self.info.run_task == "cd_boot": src = join_path(self.info.root_dir, 'winboot', 'yldrd') elif self.info.flag: src = join_path(self.info.root_dir, 'winboot', 'yldr') else: src = join_path(self.info.root_dir, 'winboot', 'yldrd') if self.info.run_task == "cd_boot": dest = join_path(drive.path, 'yldrd') elif self.info.flag: dest = join_path(drive.path, 'yldr') else: dest = join_path(drive.path, 'yldrd') shutil.copyfile(src, dest) run_command(['attrib', '+R', '+S', '+H', dest]) if self.info.run_task == "cd_boot": src = join_path(self.info.root_dir, 'winboot', 'yldrd.mbr') elif self.info.flag: src = join_path(self.info.root_dir, 'winboot', 'yldr.mbr') else: src = join_path(self.info.root_dir, 'winboot', 'yldrd.mbr') if self.info.run_task == "cd_boot": dest = join_path(drive.path, 'yldrd.mbr') elif self.info.flag: dest = join_path(drive.path, 'yldr.mbr') else: dest = join_path(drive.path, 'yldrd.mbr') shutil.copyfile(src, dest) run_command(['attrib', '+R', '+S', '+H', dest]) if self.info.run_task == "cd_boot": mbr_path = join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:] elif self.info.flag: mbr_path = join_path(self.info.target_dir, 'winboot', 'yldr.mbr')[2:] else: mbr_path = join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:] bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe') if not os.path.isfile(bcdedit): bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe') if not os.path.isfile(bcdedit): log.error("Cannot find bcdedit") return if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'): log.debug("BCD has already been modified") return if self.info.run_task == "cd_boot": command = [bcdedit, '/create', '/d', '%s LiveCD' % self.info.distro.name, '/application', 'bootsector'] elif self.info.flag: command = [bcdedit, '/create', '/d', '%s' % self.info.distro.name, '/application', 'bootsector'] else: command = [bcdedit, '/create', '/d', '%s LiveCD' % self.info.distro.name, '/application', 'bootsector'] log.debug("run command %s" %command) id = run_command(command) id = id[id.index('{'):id.index('}')+1] #mbr_path = self.info.flag and join_path(self.info.target_dir, 'winboot', 'yldr.mbr')[2:] or join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:] ##print mbr_path run_command([bcdedit, '/set', id, 'device', 'partition=%s' % self.info.target_drive.path]) run_command([bcdedit, '/set', id, 'path', mbr_path]) run_command([bcdedit, '/displayorder', id, '/addlast']) run_command([bcdedit, '/timeout', '10']) registry.set_value( 'HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive', id)
with hide('output', 'running', 'warnings'): PYTHON = local( f'{PY_LAUNCHER} -c "import sys; import os; print(os.path.dirname(sys.executable))"', capture=True) TCL_PATH = os.path.join(PYTHON, 'tcl') INNO_SETUP_DOWNLOAD = r'https://s3.amazonaws.com/ncr-colibri/install/innosetup6-unicode.exe' INNO_REG_PATH5 = u'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1' INNO_REG_PATH6 = u'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 6_is1' INNO_REG_KEY = u'InstallLocation' COLIBRI_REG_PATH = u'HKEY_LOCAL_MACHINE\\Software\\NCR\\Brasil' COLIBRI_REG_KEY = u'NCRSolution' DEP_CACHE_DIR = '_cache' DEP_DEST_DIR = r'{}\Lib\site-packages'.format(WORKON_HOME) CHUNK_SIZE = 1024 try: CAMINHO_INNO = get_value(INNO_REG_PATH6, INNO_REG_KEY, KEY_READ) except: try: CAMINHO_INNO = get_value(INNO_REG_PATH5, INNO_REG_KEY, KEY_READ) except: CAMINHO_INNO = None class FakeColibriModule(ModuleType): def __init__(self): super().__init__('colibri') @staticmethod def callback(um_plugin, um_evento, um_contexto): pass