google / glazier

A tool for automating the installation of the Microsoft Windows operating system on various device platforms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't reboot out of WinPE, expected str not int

iamacarpet opened this issue · comments

Hello,

I'm having trouble with Glazier & Python 3.10.4 on WinPE (Win11 build).

Exception: os.py:822] expected str, bytes or os.PathLike object, not int

Tracking it back, it looks like the RestartEvent is passed an int for timeout:

raise RestartEvent(
        'Leaving WinPE', timeout=10, task_list_path=constants.SYS_TASK_LIST)

However, by the time it gets here it's supposed to be a string, but it appears it isn't:

def Restart(timeout: str, reason: str):
  """Restarts a Windows machine, given a timeout period and a reason.

  Args:
    timeout: How long to wait before restarting the machine.
    reason: Reason why the machine is being restarted. This will be displayed to
      the user and written to the Windows event log.
  """
  execute.execute_binary(f'{_System32()}/shutdown.exe',
                         ['-r', '-t', timeout, '-c', f'"{reason}"'])

Certainly not by the time it makes it here:

def execute_binary(binary: str, args: Optional[List[str]] = None,
                   return_codes: Optional[List[int]] = None,
                   shell: bool = False,
                   log: bool = True) -> int:
  """Execute a binary with optional parameters and return codes.

  ....

  try:
    process = subprocess.Popen(cmd, stdout=stdout, stderr=stderr, shell=shell,
                               universal_newlines=True)

I'm by no means a python expert, so I'm not 100% I've traced it correctly.

Has anyone seen anything similar?

image

Hey @iamacarpet - thanks for reporting this issue (and the detailed error information).

This looks like a bug introduced in #525. I'll put in a fix tomorrow. To unblock you, you can modify power.py on your local system and change the following then re-launch Glazier to continue:

execute.execute_binary(f'{_System32()}/shutdown.exe', ['-r', '-t', timeout, '-c', f'"{reason}"'])

to

execute.execute_binary(f'{_System32()}/shutdown.exe', ['-r', '-t', f'{timeout}', '-c', f'"{reason}"'])

Thanks so much @TsekNet , that seems to have done the trick :).