from os import system, getenv, path
from time import sleep
class ManJaroInit:
def __init__(self, passwd):
"""
chushihua
:param passwd:
"""
self.passwd = passwd
self.home = getenv('HOME')
def zh_cn(self):
txt = '''export GTK_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
'''
file = path.join(self.home, '.xprofile')
with open(file=file, mode='w', encoding='utf8') as z:
z.write(txt)
def cmd(self, command, name=None):
"""
:param name:
:param command:
:return:
"""
res = system(command)
if int(res) == 0:
print("Run is Ok")
else:
if name:
print(f"{name} is failed")
else:
print(f"run is failed: {command}")
print(command)
sleep(8)
def pip(self):
"""
:return:
"""
cmd = "pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple"
self.cmd(command=cmd)
self.cmd(command="python3 -m pip install --upgrade pip")
self.cmd(command="pip3 install pandas requests pymysql")
def yay_install(self):
"""
yay install Sof
:return:
"""
pac = {"deepin-wine-wechat": "微信",
"deepin-wine-tim": "Tim",
"deepin.com.thunderspeed": "迅雷"}
for i in pac:
self.cmd(command=f"yay -S {i}", name=pac[i])
def yay(self):
self.sudo(cmd='yay --aururl "https://mirrors.aliyun.com/archlinuxcn" --save')
def select(self):
"""
:return:
"""
cmd = "pacman-mirrors -i -c China -m rank"
self.sudo(cmd)
def update(self):
"""
update pac list index
:return:
"""
self.sudo(cmd="pacman -Syy")
def install(self):
"""
:return:
"""
pac = ["wqy-zenhei",
"wqy-bitmapfont",
"wqy-microhei",
"ttf-wps-fonts",
"adobe-source-han-sans-cn-fonts",
"adobe-source-han-serif-cn-fonts",
"docker",
"git",
"piper",
"python-pip",
"yay",
"base-devel",
"wine-mono",
"deepin-picker",
"deepin-screen-recorder",
"deepin-screenshot",
"deepin-system-monitor",
"clang",
"cmake",
"make",
"goland",
"visual-studio-code-bin",
"google-chrome",
"foxitreader",
"wps-office",
" wps-office-mui-zh-cn",
"netease-cloud-music",
"aria2",
"net-tools",
"htop",
"tree",
"sshfs"]
for i in pac:
cmd = f"pacman -S --noconfirm --needed {i}"
self.sudo(cmd)
def sudo(self, cmd, name=None):
"""
use sudo run cmd
:param cmd: cmd
:param name:
:return:
"""
cmd = str(f"""echo {self.passwd} | sudo -S {cmd}""")
res = system(cmd)
if int(res) == 0:
print("run is ok")
else:
if name:
print(f"{name} is failed")
else:
print(f"run is failed: {cmd}")
sleep(8)
def start(self):
self.zh_cn()
# self.select()
self.update()
self.install()
self.pip()
self.yay()
self.yay_install()
print("please Run : source ~/.xprofile")
if __name__ == "__main__":
up = ManJaroInit(passwd='1')
up.start()
本文来自博客园,作者:坐公交也用券,转载请注明原文链接:https://www.cnblogs.com/liumou-site/p/17105821.html