# Tool Name :- MyServer
# Author :- LordReaper
# Date :- 13/11/2018 - 9/11/2019
# Powered By :- H1ckPro Software's

import sys
import os
from time import sleep
from core.system import *

if len(sys.argv)>1:
  pass
else:
  print ("error : invalid arguments !!")
  print ("use : myserver --help  for more information")
  sys.exit()

if sys.argv[1]=="-s":

  if len(sys.argv)==2:
    if system=="ubuntu":
      os.system("sudo python3 core/s.py "+sys.argv[1])
    else:
      os.system("python3 core/s.py "+sys.argv[1])

  elif len(sys.argv)==3:
    if sys.argv[2]=="apache":
      if system=="ubuntu":
        os.system("sudo python3 core/server.py -apa")
      else:
        os.system("python3 core/server.py -apa")
    else:
      print ("error : invalid arguments !!")
      print ("use : myserver --help  for more information")

  elif len(sys.argv)==6:
    if sys.argv[2]=="-php":
      if system=="ubuntu":
        os.system("sudo python3 core/server.py -php "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
      else:
        os.system("python3 core/server.py -php "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
    elif sys.argv[2]=="-py":
      if system=="ubuntu":
        os.system("sudo python3 core/server.py -py "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
      else:
        os.system("python3 core/server.py -py "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
    elif sys.argv[2]=="-ng":
      if system=="ubuntu":
        os.system("sudo python3 core/server.py -ng "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
      else:
        os.system("python3 core/server.py -ng "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
    else:
      print ("error : invalid arguments !!")
      print ("use : myserver --help  for more information")

  elif len(sys.argv)==5:
    if system=="ubuntu":
      os.system("sudo python3 core/server.py -d "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
    else:
      os.system("python3 core/server.py -d "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
  else:
    print ("error : invalid arguments !!")
    print ("use : myserver --help  for more information")

elif sys.argv[1]=="-h":
  if len(sys.argv)==2:
    if system=="ubuntu":
      os.system("sudo python3 core/s.py "+sys.argv[1])
    else:
      os.system("python3 core/s.py "+sys.argv[1])

  elif len(sys.argv)==5:
    if system=="ubuntu":
      os.system("sudo python3 core/host.py "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
    else:
      os.system("python3 core/host.py "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])

  else:
    print ("error : invalid arguments")
    print ("use : myserver --help  for more information")

elif sys.argv[1]=="-db":
  if len(sys.argv)==3:
    if sys.argv[2]=="start":
      if system=="ubuntu":
        os.system("sudo python3 core/mysql.py "+sys.argv[2])
      else:
        os.system("python3 core/mysql.py "+sys.argv[2])
    elif sys.argv[2]=="stop":
      if system=="ubuntu":
        os.system("sudo python3 core/mysql.py "+sys.argv[2])
      else:
        os.system("python3 core/mysql.py "+sys.argv[2])
    else:
      print ("error : invalid arguments !!")
      print ("use : myserver --help  for more information")
  else:
    print ("error : invalid arguments !!")
    print ("use : myserver --help  for more information")

elif sys.argv[1]=="rm":
  if len(sys.argv)==3:
    if sys.argv[2]=="-T" or sys.argv[2]=="-t":
      if system=="ubuntu":
        os.system("sudo python3 core/un.py")
      else:
        os.system("python3 core/un.py")
    else:
      print ("error : invalid arguments")
      print ("use : myserver --help  for more information")
  else:
    print ("error : invalid arguments")
    print ("use : myserver --help  for more information")

elif sys.argv[1]=="update":
  if system=="ubuntu":
    os.system("sudo python3 core/upd.py")
  else:
    os.system("python3 core/upd.py")

elif sys.argv[1]=="start":
  if system=="ubuntu":
    os.system("sudo python3 .MyServer.py")
  else:
     os.system("python3 .MyServer.py")

elif sys.argv[1]=="--help" or sys.argv[1]=="-help" or sys.argv[1]=="help":
  print ("")
  print ("Usage: myserver [command]... [arguments]...")
  print ("")
  print (" Commands:")
  print (" -s <hostname> <port> <path>            to start default localhost server.")
  print (" -s -ng <hostname> <port> <path>        to start php localhost server.")
  print (" -s -php <hostname> <port> <path>       to start php localhost server.")
  print (" -s -py <hostname> <port> <path>        to start python localhost server.")
  print (" -h <hostname> <localhost_port> <port>  to access localhost server on internet.")
  print (" -db [start/stop]                       to start/stop MySQL database server.")
  print (" -s apache                              to start apache web server.")
  print (" update                                 update MyServer.")
  print (" rm -t                                  uninstall MyServer.")
  print (" start                                  start MyServer menu.")
  print ("")

else:
  print ("error : invalid arguments !!")
  print ("use : myserver --help  for more information")

[((16, 2, 16, 12), 'sys.exit', 'sys.exit', ({}, {}), '()', False, 'import sys\n'), ((22, 6, 22, 54), 'os.system', 'os.system', ({(22, 16, 22, 53): "('sudo python3 core/s.py ' + sys.argv[1])"}, {}), "('sudo python3 core/s.py ' + sys.argv[1])", False, 'import os\n'), ((24, 6, 24, 49), 'os.system', 'os.system', ({(24, 16, 24, 48): "('python3 core/s.py ' + sys.argv[1])"}, {}), "('python3 core/s.py ' + sys.argv[1])", False, 'import os\n'), ((68, 6, 68, 54), 'os.system', 'os.system', ({(68, 16, 68, 53): "('sudo python3 core/s.py ' + sys.argv[1])"}, {}), "('sudo python3 core/s.py ' + sys.argv[1])", False, 'import os\n'), ((70, 6, 70, 49), 'os.system', 'os.system', ({(70, 16, 70, 48): "('python3 core/s.py ' + sys.argv[1])"}, {}), "('python3 core/s.py ' + sys.argv[1])", False, 'import os\n'), ((29, 8, 29, 53), 'os.system', 'os.system', ({(29, 18, 29, 52): '"""sudo python3 core/server.py -apa"""'}, {}), "('sudo python3 core/server.py -apa')", False, 'import os\n'), ((31, 8, 31, 48), 'os.system', 'os.system', ({(31, 18, 31, 47): '"""python3 core/server.py -apa"""'}, {}), "('python3 core/server.py -apa')", False, 'import os\n'), ((74, 6, 74, 89), 'os.system', 'os.system', ({(74, 16, 74, 88): "('sudo python3 core/host.py ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' + sys\n    .argv[4])"}, {}), "('sudo python3 core/host.py ' + sys.argv[2] + ' ' + sys.argv[3] +\n    ' ' + sys.argv[4])", False, 'import os\n'), ((76, 6, 76, 84), 'os.system', 'os.system', ({(76, 16, 76, 83): "('python3 core/host.py ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' + sys.argv[4])"}, {}), "('python3 core/host.py ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' +\n    sys.argv[4])", False, 'import os\n'), ((39, 8, 39, 98), 'os.system', 'os.system', ({(39, 18, 39, 97): "('sudo python3 core/server.py -php ' + sys.argv[3] + ' ' + sys.argv[4] +\n    ' ' + sys.argv[5])"}, {}), "('sudo python3 core/server.py -php ' + sys.argv[3] + ' ' + sys.\n    argv[4] + ' ' + sys.argv[5])", False, 'import os\n'), ((41, 8, 41, 93), 'os.system', 'os.system', ({(41, 18, 41, 92): "('python3 core/server.py -php ' + sys.argv[3] + ' ' + sys.argv[4] + ' ' +\n    sys.argv[5])"}, {}), "('python3 core/server.py -php ' + sys.argv[3] + ' ' + sys.argv[4] +\n    ' ' + sys.argv[5])", False, 'import os\n'), ((58, 6, 58, 94), 'os.system', 'os.system', ({(58, 16, 58, 93): "('sudo python3 core/server.py -d ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' +\n    sys.argv[4])"}, {}), "('sudo python3 core/server.py -d ' + sys.argv[2] + ' ' + sys.argv[\n    3] + ' ' + sys.argv[4])", False, 'import os\n'), ((60, 6, 60, 89), 'os.system', 'os.system', ({(60, 16, 60, 88): "('python3 core/server.py -d ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' + sys\n    .argv[4])"}, {}), "('python3 core/server.py -d ' + sys.argv[2] + ' ' + sys.argv[3] +\n    ' ' + sys.argv[4])", False, 'import os\n'), ((86, 8, 86, 60), 'os.system', 'os.system', ({(86, 18, 86, 59): "('sudo python3 core/mysql.py ' + sys.argv[2])"}, {}), "('sudo python3 core/mysql.py ' + sys.argv[2])", False, 'import os\n'), ((88, 8, 88, 55), 'os.system', 'os.system', ({(88, 18, 88, 54): "('python3 core/mysql.py ' + sys.argv[2])"}, {}), "('python3 core/mysql.py ' + sys.argv[2])", False, 'import os\n'), ((117, 4, 117, 41), 'os.system', 'os.system', ({(117, 14, 117, 40): '"""sudo python3 core/upd.py"""'}, {}), "('sudo python3 core/upd.py')", False, 'import os\n'), ((119, 4, 119, 36), 'os.system', 'os.system', ({(119, 14, 119, 35): '"""python3 core/upd.py"""'}, {}), "('python3 core/upd.py')", False, 'import os\n'), ((44, 8, 44, 97), 'os.system', 'os.system', ({(44, 18, 44, 96): "('sudo python3 core/server.py -py ' + sys.argv[3] + ' ' + sys.argv[4] + ' ' +\n    sys.argv[5])"}, {}), "('sudo python3 core/server.py -py ' + sys.argv[3] + ' ' + sys.argv\n    [4] + ' ' + sys.argv[5])", False, 'import os\n'), ((46, 8, 46, 92), 'os.system', 'os.system', ({(46, 18, 46, 91): "('python3 core/server.py -py ' + sys.argv[3] + ' ' + sys.argv[4] + ' ' +\n    sys.argv[5])"}, {}), "('python3 core/server.py -py ' + sys.argv[3] + ' ' + sys.argv[4] +\n    ' ' + sys.argv[5])", False, 'import os\n'), ((91, 8, 91, 60), 'os.system', 'os.system', ({(91, 18, 91, 59): "('sudo python3 core/mysql.py ' + sys.argv[2])"}, {}), "('sudo python3 core/mysql.py ' + sys.argv[2])", False, 'import os\n'), ((93, 8, 93, 55), 'os.system', 'os.system', ({(93, 18, 93, 54): "('python3 core/mysql.py ' + sys.argv[2])"}, {}), "('python3 core/mysql.py ' + sys.argv[2])", False, 'import os\n'), ((105, 8, 105, 44), 'os.system', 'os.system', ({(105, 18, 105, 43): '"""sudo python3 core/un.py"""'}, {}), "('sudo python3 core/un.py')", False, 'import os\n'), ((107, 8, 107, 39), 'os.system', 'os.system', ({(107, 18, 107, 38): '"""python3 core/un.py"""'}, {}), "('python3 core/un.py')", False, 'import os\n'), ((123, 4, 123, 42), 'os.system', 'os.system', ({(123, 14, 123, 41): '"""sudo python3 .MyServer.py"""'}, {}), "('sudo python3 .MyServer.py')", False, 'import os\n'), ((125, 5, 125, 38), 'os.system', 'os.system', ({(125, 15, 125, 37): '"""python3 .MyServer.py"""'}, {}), "('python3 .MyServer.py')", False, 'import os\n'), ((49, 8, 49, 97), 'os.system', 'os.system', ({(49, 18, 49, 96): "('sudo python3 core/server.py -ng ' + sys.argv[3] + ' ' + sys.argv[4] + ' ' +\n    sys.argv[5])"}, {}), "('sudo python3 core/server.py -ng ' + sys.argv[3] + ' ' + sys.argv\n    [4] + ' ' + sys.argv[5])", False, 'import os\n'), ((51, 8, 51, 92), 'os.system', 'os.system', ({(51, 18, 51, 91): "('python3 core/server.py -ng ' + sys.argv[3] + ' ' + sys.argv[4] + ' ' +\n    sys.argv[5])"}, {}), "('python3 core/server.py -ng ' + sys.argv[3] + ' ' + sys.argv[4] +\n    ' ' + sys.argv[5])", False, 'import os\n')]