2021-03-03 16:13:43 +00:00
|
|
|
import time
|
2021-03-08 01:56:00 +00:00
|
|
|
import sys
|
|
|
|
from consoleoutput import consoleTitle, clearConsole, printMainMenu, oColors
|
2021-03-08 21:13:57 +00:00
|
|
|
from plugin_downloader import searchPackage, getSpecificPackage
|
2021-03-08 01:56:00 +00:00
|
|
|
from plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
2021-03-08 21:13:57 +00:00
|
|
|
from handle_config import checkConfig
|
2021-03-10 01:05:56 +00:00
|
|
|
from utilities import getHelp, check_requirements
|
|
|
|
from handle_sftp import createSFTPConnection, sftp_showPlugins
|
2021-03-08 01:56:00 +00:00
|
|
|
|
|
|
|
def createInputLists():
|
|
|
|
global COMMANDLIST
|
|
|
|
COMMANDLIST = [
|
|
|
|
'get',
|
|
|
|
'update',
|
|
|
|
'check',
|
2021-03-08 21:13:57 +00:00
|
|
|
'exit',
|
|
|
|
'help'
|
2021-03-08 01:56:00 +00:00
|
|
|
]
|
|
|
|
global INPUTSELECTEDOBJECT
|
|
|
|
INPUTSELECTEDOBJECT = [
|
|
|
|
'all',
|
|
|
|
'*'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
|
|
|
while True:
|
|
|
|
if inputCommand == 'get':
|
2021-03-08 21:13:57 +00:00
|
|
|
if inputSelectedObject.isdigit():
|
2021-03-10 01:05:56 +00:00
|
|
|
if not checkConfig().localPluginFolder:
|
|
|
|
getSpecificPackage(inputSelectedObject, checkConfig().sftp_folderPath, inputParams)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
getSpecificPackage(inputSelectedObject, checkConfig().pathToPluginFolder, inputParams)
|
2021-03-08 21:13:57 +00:00
|
|
|
else:
|
|
|
|
searchPackage(inputSelectedObject)
|
|
|
|
break
|
2021-03-08 01:56:00 +00:00
|
|
|
if inputCommand == 'update':
|
2021-03-10 01:05:56 +00:00
|
|
|
updateInstalledPackage(inputSelectedObject)
|
2021-03-08 01:56:00 +00:00
|
|
|
break
|
|
|
|
if inputCommand == 'check':
|
2021-03-10 01:05:56 +00:00
|
|
|
checkInstalledPackage(inputSelectedObject)
|
2021-03-08 01:56:00 +00:00
|
|
|
break
|
|
|
|
if inputCommand == 'exit':
|
|
|
|
sys.exit()
|
2021-03-08 21:13:57 +00:00
|
|
|
if inputCommand == 'help':
|
|
|
|
getHelp()
|
|
|
|
break
|
2021-03-10 01:05:56 +00:00
|
|
|
if inputCommand == 'sftp':
|
|
|
|
sftp = createSFTPConnection()
|
|
|
|
sftp_showPlugins(sftp)
|
|
|
|
break
|
2021-03-08 01:56:00 +00:00
|
|
|
else:
|
|
|
|
print(oColors.brightRed + "Command not found. Please try again." + oColors.standardWhite)
|
|
|
|
getInput()
|
|
|
|
getInput()
|
2021-03-07 00:49:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def getInput():
|
2021-03-08 01:56:00 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
inputCommand, inputSelectedObject, *inputParams = input("pluGET >> ").split()
|
|
|
|
break
|
|
|
|
except ValueError:
|
|
|
|
print(oColors.brightRed + "Wrong input! Use: > *command* *selectedObject* *optionalParams*" + oColors.standardWhite)
|
|
|
|
|
|
|
|
inputParams = inputParams[0] if inputParams else None
|
2021-03-07 00:49:57 +00:00
|
|
|
print(inputCommand)
|
|
|
|
print(inputSelectedObject)
|
|
|
|
print(inputParams)
|
2021-03-08 01:56:00 +00:00
|
|
|
handleInput(inputCommand, inputSelectedObject, inputParams)
|
2021-03-03 16:13:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def inputMainMenu():
|
2021-03-10 01:05:56 +00:00
|
|
|
consoleTitle()
|
2021-03-03 16:13:43 +00:00
|
|
|
clearConsole()
|
2021-03-08 21:13:57 +00:00
|
|
|
checkConfig()
|
2021-03-10 01:05:56 +00:00
|
|
|
check_requirements()
|
2021-03-08 21:13:57 +00:00
|
|
|
createInputLists()
|
2021-03-03 16:13:43 +00:00
|
|
|
printMainMenu()
|
2021-03-07 00:49:57 +00:00
|
|
|
getInput()
|
2021-03-10 01:05:56 +00:00
|
|
|
outputTest()
|
2021-03-03 16:13:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def outputTest():
|
|
|
|
print("Hello world")
|
|
|
|
print("Waiting still seconds: 5", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 4", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 3", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 2", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 1", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Done ✅☑✔ ")
|
|
|
|
input("Press key to end program...")
|
|
|
|
|
2021-03-07 00:49:57 +00:00
|
|
|
|
2021-03-03 16:13:43 +00:00
|
|
|
inputMainMenu()
|