start.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/python
  2. import yaml
  3. import os
  4. def main():
  5. # Create yaml files
  6. file = open("cache.yaml","w")
  7. file = open("varname.yaml","w")
  8. file = open("style.yaml","w")
  9. # Define default values and import user input
  10. default_name = 'adei'
  11. name = raw_input("> Please enter the type of database: [%s] " %default_name)
  12. if not name:
  13. name = default_name
  14. default_time = '2'
  15. time = raw_input("> Please key in the time polling duration in second: [%s] " %default_time)
  16. if not time:
  17. time = default_time
  18. default_user = 'jack'
  19. user = raw_input("> Please enter the username for the access into the database: [%s] " %default_user)
  20. if not user:
  21. user = default_user
  22. default_password = 'rose'
  23. password = raw_input("> Please enter the password for the access into the database: [%s] " %default_password)
  24. if not password:
  25. password = default_password
  26. default_pw_designer = 'titanic'
  27. pw_designer = raw_input("> Please key in the password for the access into designer page: [%s] " %default_pw_designer)
  28. if not pw_designer:
  29. pw_designer = default_pw_designer
  30. default_script = 'services/getdata.php'
  31. script = raw_input("> Please enter the file name for data retrieval: [%s] " %default_script)
  32. if not script:
  33. script = default_script
  34. default_server = 'http://katrin.kit.edu/adei-katrin/'
  35. server = raw_input("> Please enter the url for the database: [%s] " %default_server)
  36. if not server:
  37. server = default_server
  38. default_background = 'cps_02.png'
  39. background = raw_input("> Please key in the background image name: [%s] " %default_background)
  40. if not background:
  41. background = default_background
  42. default_port = '8888'
  43. port = raw_input("> Please enter the port number: [%s] " %default_port)
  44. if not port:
  45. port = default_port
  46. default_title = 'My Project'
  47. title = raw_input("> Please enter the project title: [%s] " %default_title)
  48. if not title:
  49. title = default_title
  50. os.makedirs("static/"+title+"/images")
  51. # Define a dictionary for the user input
  52. config = {
  53. 'type': name,
  54. 'polling': time,
  55. 'username': user,
  56. 'password': password,
  57. 'pw_designer': pw_designer,
  58. 'script': script,
  59. 'server': server,
  60. 'background': background,
  61. 'port': port,
  62. 'title': title,
  63. }
  64. # Create config.yaml file and insert the user input
  65. with open ("config.yaml","w") as stream:
  66. stream.write(yaml.dump(config, default_flow_style=False))
  67. file.close()
  68. if __name__ == "__main__":
  69. main()