forked from yamtargokboru3810/Telegram-UserBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules
45 lines (38 loc) · 1.33 KB
/
modules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import subprocess
import platform
from userbot import SUDO
def _start_instalation():
install_with = None
package_managers = ["pacman", "apt-get", "yum", "brew", "yaourt", "dnf", "homebrew", "eopkg", "snap"]
if "linux" in str(platform.system()).lower():
for manager in package_managers:
try:
subprocess.check_call(f"which {manager}", shell=True, stderr=subprocess.STDOUT)
install_package(manager)
return
except:
continue
def install_package(package_manager):
packages = []
to_install = []
with open("Aptfile") as file:
for line in file:
packages.append(line)
for package in packages:
try:
subprocess.check_call(f"which {package}", shell=True, stderr=subprocess.STDOUT)
except:
to_install.append(package)
if to_install:
if SUDO:
subprocess.Popen(f"echo {str(SUDO)} | sudo -S {str(package_manager)}" +
f" install -y {' '.join(to_install)}", shell=True)
else:
subprocess.Popen(f"{str(package_manager)} install -y {' '.join(to_install)}",
shell=True)
try:
if not 'heroku' in os.environ['PATH']:
_start_instalation()
except:
_start_instalation()