mirror of
https://github.com/Specoolazius/mcserver-discordbot.git
synced 2024-11-25 01:39:42 +01:00
fixed permission error
This commit is contained in:
parent
a01a46e20d
commit
e4c3ccbf97
@ -156,25 +156,27 @@ class Client(discord.Bot, ABC):
|
|||||||
await process_chmod.communicate()
|
await process_chmod.communicate()
|
||||||
return process_chmod.returncode
|
return process_chmod.returncode
|
||||||
|
|
||||||
process = await asyncio.create_subprocess_exec(
|
if not retry:
|
||||||
program=os.path.join(os.getcwd(), SHELL_SCRIPT_PATH, file_name),
|
await __grant_permission()
|
||||||
stdout=asyncio.subprocess.PIPE,
|
|
||||||
stderr=asyncio.subprocess.PIPE,
|
|
||||||
)
|
|
||||||
|
|
||||||
stdout, stderr = await process.communicate()
|
try:
|
||||||
self.logger.info(f'Executed script {file_name} with exit code {process.returncode}')
|
process = await asyncio.create_subprocess_exec(
|
||||||
|
program=os.path.join(os.getcwd(), SHELL_SCRIPT_PATH, file_name),
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
|
|
||||||
if process.returncode == 0:
|
stdout, stderr = await process.communicate()
|
||||||
self.logger.info(f'stdout:\n{stdout.decode()}')
|
self.logger.info(f'Executed script {file_name} with exit code {process.returncode}')
|
||||||
|
|
||||||
# bash returncode 126: permission error
|
if process.returncode == 0:
|
||||||
elif process.returncode == 126 and retry:
|
self.logger.info(f'stdout:\n{stdout.decode()}')
|
||||||
|
else:
|
||||||
|
self.logger.error(f'stderr:\n{stderr.decode()}')
|
||||||
|
|
||||||
|
return process.returncode
|
||||||
|
|
||||||
|
except PermissionError:
|
||||||
# retrying once
|
# retrying once
|
||||||
self.logger.warning(f'Missing permissions for {file_name}')
|
self.logger.warning(f'Missing permissions for {file_name}')
|
||||||
return await self.execute_shell(file_name, retry=False)
|
return await self.execute_shell(file_name, retry=False)
|
||||||
|
|
||||||
else:
|
|
||||||
self.logger.error(f'stderr:\n{stderr.decode()}')
|
|
||||||
|
|
||||||
return process.returncode
|
|
||||||
|
Loading…
Reference in New Issue
Block a user