def __get_branch(branch=None, quiet=True, only_use_regedit=False): if only_use_regedit == False: debug("Using cache/file to read registry.") branch_file_name, branch_root = __get_branch_file(branch) if branch_file_name != None: with codecs.open(branch_file_name, 'r', encoding=get_codepage()) as registry_file: registry = registry_file.read() #CACHE[branch_root] = registry return (branch_root, registry) debug("Using regedit to read registry.") _initWine() process_args = [common.ENV['WINE'], "regedit", "/E", "-"] if branch != None: process_args.append(branch) else: branch = '' registry = '' process = common.Popen(process_args, env=common.ENV_NO_DISPLAY(common.ENV_NO_GECKO())) buffer = process.stdout.readline() while buffer != '': registry += buffer buffer = process.stdout.readline() #if process.returncode and not quiet: if registry == '' or registry.strip() == 'Success': if not quiet: error("Warning: Registry branch '%s' doesn't exist." % branch) return '' try: registry = registry.decode(get_codepage()) except UnicodeDecodeError: pass return registry
def _initWine(): _wineprocess = common.Popen("%s -p10" % common.ENV['WINESERVER'], shell=True, stdin='null', stdout='null', stderr='null', env=common.ENV_NO_DISPLAY( common.ENV_NO_GECKO()))
def _writeRegistry(registrycontent): _initWine() regfilename = util.tempname('setregistry-', '.reg') with codecs.open(regfilename, 'w', encoding=get_codepage()) as regfile: regfile.write(registrycontent) #print("Running regedit with no display output") process = common.Popen([common.ENV['WINE'], "regedit", regfilename], stdout='null', stderr='null', env=common.ENV_NO_DISPLAY(common.ENV_NO_GECKO())) process.communicate() return process.returncode
def get_win_env_path(key, insensitive=False, userenv=False): """Get a path key from the Wine environment, quick and dirty""" if userenv: filename = 'user.reg' start = '[Environment]' else: filename = 'system.reg' start = '[System\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment]' if insensitive: start = start.lower() # Get the environment part of the reg file env = file_get_part( '{0}/{1}'.format( common.ENV['WINEPREFIX'], filename ), start, '\n\n', insensitive = insensitive ) # Search for the key result = re.search( '"{key}"="(.*?)\n'.format(key = key), env ) if result: # Got it result = result.groups()[0][:-1] else: # Didn't get it, try insensitively result = re.search( '(?i)"{key}"="(.*?)\n'.format(key = key), env ) if result: # Got it result = result.groups()[0][:-1] else: # Didn't get it, try getting it from Wine in another way # FIXME: This is slow, can we speed it up somehow? result = common.run( [common.ENV['WINE'], 'cmd.exe', '/c', 'echo', '%{0}%'.format(key)], env = common.ENV_NO_DISPLAY(common.ENV_NO_GECKO()) )[0].strip() if not len(result): return None # Remove double backslashes, except from the drive part result = result.replace('\\\\', '\\').replace('\\\\', '\\') result = result.replace(':\\', ':\\\\') return result
def wine_first_run(): # Create Wine structure returncode = common.system( ['wineboot', '-i'], env=common.ENV_NO_DISPLAY() ) # The init process isn't always actually finished when it says it is, so check it first checks = 1 while base.check_setup() is False and checks < 500: time.sleep(0.2) checks += 1 if base.check_setup(): appearance.set_menu_style(True) shellfolders.setdefaults() return True else: return False
def kill(): return common.system( ['wineboot', '--kill'], env=common.ENV_NO_DISPLAY() ) == 0
def end_session(force=False): command = ['wineboot', '--end-session'] if force: command.append('--force') return common.system(command, env=common.ENV_NO_DISPLAY()) == 0
def shutdown(): return common.system( ['wineboot', '--shutdown'], env=common.ENV_NO_DISPLAY() ) == 0
def reboot(): return common.system( ['wineboot', '--restart'], env=common.ENV_NO_DISPLAY() ) == 0