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. 48
      PVEDiscordDark.py

48
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,7 +33,8 @@ class colors:
UNDERLINE = '\033[4m' UNDERLINE = '\033[4m'
def clear(): def clear():
print("\033c", end="") if ACTION == None:
print("\033c", end="")
def cprint(color, text, bold=False, inline=False): def cprint(color, text, bold=False, inline=False):
endc = '\n' endc = '\n'
@ -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,9 +99,10 @@ 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)
cprint(colors.NORMAL, 'Press [ENTER] to go back.') if ACTION == None:
input('') cprint(colors.NORMAL, 'Press [ENTER] to go back.')
doMainMenu() input('')
doMainMenu()
def uninstallTheme(): def uninstallTheme():
clear() clear()
@ -126,9 +131,10 @@ 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)
cprint(colors.NORMAL, 'Press [ENTER] to go back.') if ACTION == None:
input('') cprint(colors.NORMAL, 'Press [ENTER] to go back.')
doMainMenu() input('')
doMainMenu()
def doHeader(): def doHeader():
cprint(colors.HEADER, '[~]', True, True) cprint(colors.HEADER, '[~]', True, True)
@ -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)
try: if ACTION == None:
doMainMenu() try:
except KeyboardInterrupt: print('mm')
print('\n') doMainMenu()
exit(0) except KeyboardInterrupt:
print('\n')
exit(0)
else:
if ACTION == 'install':
installTheme()
else:
if themeIsInstalled():
uninstallTheme()
if __name__ == "__main__": if __name__ == "__main__":
main() main()
Loading…
Cancel
Save