Skip to content

Commit

Permalink
upgrader hang bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
greeeen-dev committed Jul 14, 2024
1 parent e90e045 commit 3458c3e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions cogs/sysmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,8 @@ async def install(self, ctx, url):
msg = await ctx.send(embed=embed)
try:
os.system('rm -rf ' + os.getcwd() + '/plugin_install')
status(os.system(
'git clone ' + url + ' ' + os.getcwd() + '/plugin_install'))
await self.bot.loop.run_in_executor(None, lambda: status(os.system(
'git clone ' + url + ' ' + os.getcwd() + '/plugin_install')))
with open('plugin_install/plugin.json', 'r') as file:
new = json.load(file)
if not bool(re.match("^[a-z0-9_-]*$", new['id'])):
Expand Down Expand Up @@ -1354,7 +1354,9 @@ def check(interaction):
newdeps = new['requirements']
if len(newdeps) > 0:
self.logger.debug('Installing: ' + ' '.join(newdeps))
status(os.system('python3 -m pip install --no-dependencies ' + ' '.join(newdeps)))
await self.bot.loop.run_in_executor(None, lambda: status(
os.system('python3 -m pip install --no-dependencies ' + ' '.join(newdeps))
))
except:
self.logger.exception('Dependency installation failed')
raise RuntimeError()
Expand Down Expand Up @@ -1710,8 +1712,10 @@ def check(interaction):
self.logger.debug('Purging old update files')
os.system('rm -rf ' + os.getcwd() + '/update')
self.logger.info('Downloading from remote repository...')
os.system('git clone --branch ' + new['version'] + ' --single-branch --depth 1 ' + self.bot.config[
'files_endpoint'] + '/unifier.git ' + os.getcwd() + '/update')
await self.bot.loop.run_in_executor(None, lambda: os.system(
'git clone --branch ' + new['version'] + ' --single-branch --depth 1 ' + self.bot.config[
'files_endpoint'] + '/unifier.git ' + os.getcwd() + '/update'
))
self.logger.debug('Confirming download...')
x = open(os.getcwd() + '/update/plugins/system.json', 'r')
x.close()
Expand Down Expand Up @@ -1742,7 +1746,9 @@ def check(interaction):
pass
if len(newdeps) > 0:
self.logger.debug('Installing: ' + ' '.join(newdeps))
status(os.system('python3 -m pip install ' + ' '.join(newdeps)))
await self.bot.loop.run_in_executor(None, lambda: status(
os.system('python3 -m pip install ' + ' '.join(newdeps))
))
except:
self.logger.exception('Dependency installation failed, no rollback required')
embed.title = f'{self.bot.ui_emojis.error} {selector.get("failed")}'
Expand Down Expand Up @@ -1854,8 +1860,8 @@ def check(interaction):
url = plugin_info['repository']
try:
os.system('rm -rf ' + os.getcwd() + '/plugin_install')
status(os.system(
'git clone ' + url + ' ' + os.getcwd() + '/plugin_install'))
await self.bot.loop.run_in_executor(None, lambda: status(os.system(
'git clone ' + url + ' ' + os.getcwd() + '/plugin_install')))
with open('plugin_install/plugin.json', 'r') as file:
new = json.load(file)
if not bool(re.match("^[a-z0-9_-]*$", new['id'])):
Expand Down Expand Up @@ -1927,7 +1933,9 @@ def check(interaction):
newdeps.remove(dep)
if len(newdeps) > 0:
self.logger.debug('Installing: ' + ' '.join(newdeps))
status(os.system('python3 -m pip install --no-dependencies ' + ' '.join(newdeps)))
await self.bot.loop.run_in_executor(None, lambda: status(
os.system('python3 -m pip install --no-dependencies ' + ' '.join(newdeps))
))
except:
self.logger.exception('Dependency installation failed')
raise RuntimeError()
Expand Down

0 comments on commit 3458c3e

Please sign in to comment.