fixed permission error

This commit is contained in:
Specoolazius 2022-04-02 21:39:02 +02:00
parent a01a46e20d
commit e4c3ccbf97

View File

@ -156,6 +156,10 @@ class Client(discord.Bot, ABC):
await process_chmod.communicate() await process_chmod.communicate()
return process_chmod.returncode return process_chmod.returncode
if not retry:
await __grant_permission()
try:
process = await asyncio.create_subprocess_exec( process = await asyncio.create_subprocess_exec(
program=os.path.join(os.getcwd(), SHELL_SCRIPT_PATH, file_name), program=os.path.join(os.getcwd(), SHELL_SCRIPT_PATH, file_name),
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
@ -167,14 +171,12 @@ class Client(discord.Bot, ABC):
if process.returncode == 0: if process.returncode == 0:
self.logger.info(f'stdout:\n{stdout.decode()}') self.logger.info(f'stdout:\n{stdout.decode()}')
# bash returncode 126: permission error
elif process.returncode == 126 and retry:
# retrying once
self.logger.warning(f'Missing permissions for {file_name}')
return await self.execute_shell(file_name, retry=False)
else: else:
self.logger.error(f'stderr:\n{stderr.decode()}') self.logger.error(f'stderr:\n{stderr.decode()}')
return process.returncode return process.returncode
except PermissionError:
# retrying once
self.logger.warning(f'Missing permissions for {file_name}')
return await self.execute_shell(file_name, retry=False)