Advertisement
MRtecno98

SRMPSetupServer V.1.0.0

May 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. #SRMP(Send/Receive Mail Protocol) è un protocollo creato da me(MRtecno98) per lo scambio
  2. #di messaggi via internet, questo programma imposta un server basato su questo
  3. #protocollo appunto.
  4. #Istruzioni in GUI, ricordatevi però dei dati forniti con il comando "show"
  5. #la password dell'utente root è sempre "admin"
  6.  
  7. import os , json
  8.  
  9. dirname = "SRMP"
  10. nameroot = "root"
  11. rootaccount = {"name" : "root" , "password" : "admin"}
  12.  
  13. print("SRMP Server Setup".center(40 , "="))
  14. print("start: Start the setup of the server")
  15. print("select: select options of the setup")
  16. print("show: show options of setup")
  17. print("="*40)
  18.  
  19.  
  20. while True :
  21.     opp = input("setup> ")
  22.  
  23.     if opp == "start" :
  24.         os.mkdir(os.path.join(".",dirname))
  25.         accounts = {rootaccount["name"] : rootaccount["password"]}
  26.         jsonAccounts = json.dumps(accounts)
  27.         file = open(os.path.join("." , dirname , "accounts.json") , "w")
  28.         file.write(jsonAccounts)
  29.         file.close()
  30.         os.mkdir(os.path.join(".",dirname,rootaccount["name"]))
  31.         print("Setup Finish!")
  32.     elif opp == "select" :
  33.         print("Insert Settings of the Setup, press enter for default")
  34.         rootname = input("Insert name of root account(Default: 'root'): ")
  35.         namedir = input("Insert name of directory contains server files(Default 'SRMP'): ")
  36.         if rootname == "" :
  37.             rootname = "root"
  38.         if namedir == "" :
  39.             namedir = "SRMP"
  40.         nameroot = rootname
  41.         dirname = namedir
  42.     elif opp == "show" :
  43.         print("Name of directory of SRMP: " + dirname)
  44.         print("Name of root account of SRMP: " + nameroot)
  45.     elif opp.replace(" " , "").replace("\n") == "" :
  46.         continue
  47.     else :
  48.         print("Errated Command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement