Skip to content

Commit 9748007

Browse files
authored
Update update.py
1 parent 9ff0159 commit 9748007

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

.github/update.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import asyncio
2-
import sys
3-
from os import path
42

5-
requirements_path = path.join(
6-
path.dirname(path.dirname(path.dirname(__file__))), "requirements.txt"
7-
)
3+
from userbot import runcmd
84

95

106
async def update_requirements():
11-
reqs = str(requirements_path)
127
try:
13-
process = await asyncio.create_subprocess_shell(
14-
" ".join([sys.executable, "-m", "pip", "install", "-r", reqs]),
15-
stdout=asyncio.subprocess.PIPE,
16-
stderr=asyncio.subprocess.PIPE,
17-
)
18-
await process.communicate()
19-
return process.returncode
8+
await runcmd("pip install --upgrade pip")
9+
print("Pip is upto-date")
10+
except BaseException:
11+
print("Error while updating pip")
12+
try:
13+
await runcmd("pip install -r requirements.txt")
14+
print("Succesfully Updated requirements")
2015
except Exception as e:
21-
return repr(e)
16+
print(f"Error while installing requirments {str(e)}")
2217

2318

24-
asyncio.run(update_requirements())
19+
loop = asyncio.get_event_loop()
20+
loop.run_until_complete(update_requirements())
21+
loop.close()

0 commit comments

Comments
 (0)