Browse Source

Add unattended mode, and change google.com ping to github.com

pull/27/head
Weilbyte 4 years ago
parent
commit
692442eb96
No known key found for this signature in database GPG Key ID: BB87B2C8A1468388
  1. 22
      PVEDiscordDark.py

22
PVEDiscordDark.py

@ -3,9 +3,12 @@ import subprocess
import urllib.request import urllib.request
import os.path import os.path
import shutil import shutil
import argparse
import os import os
import time import time
ACTION = None
images = [ images = [
'dd_cephblurp.png', 'dd_cephwhite.png', 'dd_cephblurp.png', 'dd_cephwhite.png',
'dd_icon-cpu.png', 'dd_icon-hdd.png', 'dd_icon-cpu.png', 'dd_icon-hdd.png',
@ -30,6 +33,7 @@ class colors:
UNDERLINE = '\033[4m' UNDERLINE = '\033[4m'
def clear(): def clear():
if ACTION == None:
print("\033c", end="") print("\033c", end="")
def cprint(color, text, bold=False, inline=False): def cprint(color, text, bold=False, inline=False):
@ -59,7 +63,7 @@ def checkPVE():
def checkConn(): def checkConn():
try: try:
urllib.request.urlopen('http://google.com') urllib.request.urlopen('http://github.com')
return return
except: except:
cprint(colors.FAIL, 'An Internet connection is required to install PVEDiscordDark.', True) cprint(colors.FAIL, 'An Internet connection is required to install PVEDiscordDark.', True)
@ -95,6 +99,7 @@ def installTheme():
cprint(colors.NORMAL, f'Downloading images [{index + 1}/{len(images)}]..\r', False, True) cprint(colors.NORMAL, f'Downloading images [{index + 1}/{len(images)}]..\r', False, True)
urllib.request.urlretrieve(f'{baseURL}/PVEDiscordDark/images/{image}', f'/usr/share/pve-manager/images/{image}') urllib.request.urlretrieve(f'{baseURL}/PVEDiscordDark/images/{image}', f'/usr/share/pve-manager/images/{image}')
cprint(colors.OKGREEN, '\nTheme installed successfully!', True) cprint(colors.OKGREEN, '\nTheme installed successfully!', True)
if ACTION == None:
cprint(colors.NORMAL, 'Press [ENTER] to go back.') cprint(colors.NORMAL, 'Press [ENTER] to go back.')
input('') input('')
doMainMenu() doMainMenu()
@ -126,6 +131,7 @@ def uninstallTheme():
if asset.startswith('dd_'): if asset.startswith('dd_'):
os.remove(f'/usr/share/pve-manager/images/{asset}') os.remove(f'/usr/share/pve-manager/images/{asset}')
cprint(colors.OKGREEN, '\n\nTheme uninstalled successfully!', True) cprint(colors.OKGREEN, '\n\nTheme uninstalled successfully!', True)
if ACTION == None:
cprint(colors.NORMAL, 'Press [ENTER] to go back.') cprint(colors.NORMAL, 'Press [ENTER] to go back.')
input('') input('')
doMainMenu() doMainMenu()
@ -157,15 +163,27 @@ def doMainMenu():
doMainMenu() doMainMenu()
def main(): def main():
parser = argparse.ArgumentParser(description='PVEDiscordDark Theme Utility')
parser.add_argument('--action', '-a', choices=['install', 'uninstall'], help='action for unattended mode')
args = parser.parse_args()
global ACTION
ACTION = args.action
checkPVE() checkPVE()
checkConn() checkConn()
time.sleep(0.5) time.sleep(0.5)
if ACTION == None:
try: try:
print('mm')
doMainMenu() doMainMenu()
except KeyboardInterrupt: except KeyboardInterrupt:
print('\n') print('\n')
exit(0) exit(0)
else:
if ACTION == 'install':
installTheme()
else:
if themeIsInstalled():
uninstallTheme()
if __name__ == "__main__": if __name__ == "__main__":
main() main()
Loading…
Cancel
Save