# 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")

[((319, 329), 'sys.exit', 'sys.exit', ([], {}), '()\n', (327, 329), False, 'import sys\n'), ((408, 458), 'os.system', 'os.system', (["('sudo python3 core/s.py ' + sys.argv[1])"], {}), "('sudo python3 core/s.py ' + sys.argv[1])\n", (417, 458), False, 'import os\n'), ((473, 518), 'os.system', 'os.system', (["('python3 core/s.py ' + sys.argv[1])"], {}), "('python3 core/s.py ' + sys.argv[1])\n", (482, 518), False, 'import os\n'), ((2183, 2233), 'os.system', 'os.system', (["('sudo python3 core/s.py ' + sys.argv[1])"], {}), "('sudo python3 core/s.py ' + sys.argv[1])\n", (2192, 2233), False, 'import os\n'), ((2248, 2293), 'os.system', 'os.system', (["('python3 core/s.py ' + sys.argv[1])"], {}), "('python3 core/s.py ' + sys.argv[1])\n", (2257, 2293), False, 'import os\n'), ((608, 653), 'os.system', 'os.system', (['"""sudo python3 core/server.py -apa"""'], {}), "('sudo python3 core/server.py -apa')\n", (617, 653), False, 'import os\n'), ((674, 714), 'os.system', 'os.system', (['"""python3 core/server.py -apa"""'], {}), "('python3 core/server.py -apa')\n", (683, 714), False, 'import os\n'), ((2349, 2446), 'os.system', 'os.system', (["('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])\n", (2358, 2446), False, 'import os\n'), ((2449, 2541), 'os.system', 'os.system', (["('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])\n", (2458, 2541), False, 'import os\n'), ((919, 1024), 'os.system', 'os.system', (["('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])\n", (928, 1024), False, 'import os\n'), ((1030, 1129), 'os.system', 'os.system', (["('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])\n", (1039, 1129), False, 'import os\n'), ((1806, 1909), 'os.system', 'os.system', (["('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])\n", (1815, 1909), False, 'import os\n'), ((1911, 2008), 'os.system', 'os.system', (["('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])\n", (1920, 2008), False, 'import os\n'), ((2748, 2802), 'os.system', 'os.system', (["('sudo python3 core/mysql.py ' + sys.argv[2])"], {}), "('sudo python3 core/mysql.py ' + sys.argv[2])\n", (2757, 2802), False, 'import os\n'), ((2821, 2870), 'os.system', 'os.system', (["('python3 core/mysql.py ' + sys.argv[2])"], {}), "('python3 core/mysql.py ' + sys.argv[2])\n", (2830, 2870), False, 'import os\n'), ((3772, 3809), 'os.system', 'os.system', (['"""sudo python3 core/upd.py"""'], {}), "('sudo python3 core/upd.py')\n", (3781, 3809), False, 'import os\n'), ((3822, 3854), 'os.system', 'os.system', (['"""python3 core/upd.py"""'], {}), "('python3 core/upd.py')\n", (3831, 3854), False, 'import os\n'), ((1180, 1284), 'os.system', 'os.system', (["('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])\n", (1189, 1284), False, 'import os\n'), ((1290, 1388), 'os.system', 'os.system', (["('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])\n", (1299, 1388), False, 'import os\n'), ((2934, 2988), 'os.system', 'os.system', (["('sudo python3 core/mysql.py ' + sys.argv[2])"], {}), "('sudo python3 core/mysql.py ' + sys.argv[2])\n", (2943, 2988), False, 'import os\n'), ((3007, 3056), 'os.system', 'os.system', (["('python3 core/mysql.py ' + sys.argv[2])"], {}), "('python3 core/mysql.py ' + sys.argv[2])\n", (3016, 3056), False, 'import os\n'), ((3409, 3445), 'os.system', 'os.system', (['"""sudo python3 core/un.py"""'], {}), "('sudo python3 core/un.py')\n", (3418, 3445), False, 'import os\n'), ((3466, 3497), 'os.system', 'os.system', (['"""python3 core/un.py"""'], {}), "('python3 core/un.py')\n", (3475, 3497), False, 'import os\n'), ((3910, 3948), 'os.system', 'os.system', (['"""sudo python3 .MyServer.py"""'], {}), "('sudo python3 .MyServer.py')\n", (3919, 3948), False, 'import os\n'), ((3962, 3995), 'os.system', 'os.system', (['"""python3 .MyServer.py"""'], {}), "('python3 .MyServer.py')\n", (3971, 3995), False, 'import os\n'), ((1439, 1543), 'os.system', 'os.system', (["('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])\n", (1448, 1543), False, 'import os\n'), ((1549, 1647), 'os.system', 'os.system', (["('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])\n", (1558, 1647), False, 'import os\n')]