Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. import sys
  2. import os
  3. import time
  4.  
  5. from pathlib import Path
  6.  
  7.  
  8. my_file = Path("database.txt")
  9. if my_file.is_file():
  10.  
  11. f= open("database.txt","r+")
  12.  
  13. infilename = "database.txt"
  14. with open(infilename, "r") as f:
  15. line_list = f.readlines()
  16.  
  17. # f = f.readlines()
  18. f.close()
  19. found = False
  20. f= open("database.txt","r+")
  21. for line in f:
  22. if str("users") in line:
  23. print ("Found it")
  24. print ("Beginning database edit/user add")
  25. print ("You will be requested for input soon")
  26. usernamenew = input("New DB username: ")
  27. passwordnew = input("New DB password: ")
  28. f.close
  29. f= open("database.txt","a+")
  30. f.write("UN:",usernamenew)
  31. f.write("UP:",passwordnew)
  32. found = True
  33.  
  34. if not found:
  35. f = open('database.txt', 'a')
  36. f.write(str("NUN: root 1")+"n")
  37. f.close()
  38. print("nCreating database")
  39. time.sleep(3)
  40. print(".")
  41. time.sleep(1)
  42. print("..")
  43. time.sleep(1)
  44. print("...")
  45. time.sleep(1)
  46. print(".")
  47. time.sleep(1)
  48. time.sleep(5)
  49. print("nCreating user")
  50. print(".")
  51. time.sleep(1)
  52. print("..")
  53. time.sleep(1)
  54. print("...")
  55. time.sleep(1)
  56. print(".")
  57. time.sleep(6)
  58. confirm = input("nAre you sure you wish to write changes? Y/N: ")
  59. if confirm == str("Y") or str("y"):
  60. print("nWriting changes NOW")
  61. f= open("database.txt","w+")
  62. f.close
  63. for i in range(1):
  64. f= open("database.txt","a+")
  65. f.write("users rn")
  66. f.write("NUN: root %drn" % (i+1))
  67. f.write("NUP: root %drn" % (i+1))
  68. f.close
  69. for i in range(1):
  70. f= open("database.txt","w+")
  71. f.write("users rn")
  72. f.write("NUN: root %drn" % (i+1))
  73. f.write("NUP: root %drn" % (i+1))
  74. f.close
  75. else:
  76. print("You have aborted the database creation")
  77. print("The following script may not run. This is due to no/invalid database installation")
  78.  
  79. my_file = Path("database.txt")
  80. if my_file.is_file():
  81.  
  82. f= open("database.txt","r+")
  83.  
  84. infilename = "database.txt"
  85. with open(infilename, "r") as f:
  86. line_list = f.readlines()
  87.  
  88. # f = f.readlines()
  89. f.close()
  90. found = False
  91. f= open("database.txt","r+")
  92. for line in f:
  93. if str("users") in line:
  94. print ("Found it")
  95. print ("Beginning database edit/user add")
  96. print ("You will be requested for input soon")
  97. usernamenew = input("New DB username: ")
  98. passwordnew = input("New DB password: ")
  99. f.close
  100. f= open("database.txt","a+")
  101. f.write("UN:",usernamenew)
  102. f.write("UP:",passwordnew)
  103. found = True
  104.  
  105. if not found:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement