start.py 2.6 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. os.makedirs("static/dataimage")
  10. # Define default values and import user input
  11. default_name = 'adei'
  12. name = raw_input("> Please enter the type of database: [%s] " %default_name)
  13. if not name:
  14. name = default_name
  15. default_time = '2'
  16. time = raw_input("> Please key in the time polling duration in second: [%s] " %default_time)
  17. if not time:
  18. time = default_time
  19. default_user = 'jack'
  20. user = raw_input("> Please enter the username for the access into the database: [%s] " %default_user)
  21. if not user:
  22. user = default_user
  23. default_password = 'rose'
  24. password = raw_input("> Please enter the password for the access into the database: [%s] " %default_password)
  25. if not password:
  26. password = default_password
  27. default_pw_designer = 'titanic'
  28. pw_designer = raw_input("> Please key in the password for the access into designer page: [%s] " %default_pw_designer)
  29. if not pw_designer:
  30. pw_designer = default_pw_designer
  31. default_script = 'services/getdata.php'
  32. script = raw_input("> Please enter the file name for data retrieval: [%s] " %default_script)
  33. if not script:
  34. script = default_script
  35. default_server = 'http://katrin.kit.edu/adei-katrin/'
  36. server = raw_input("> Please enter the url for the database: [%s] " %default_server)
  37. if not server:
  38. server = default_server
  39. default_background = 'cps_02.png'
  40. background = raw_input("> Please key in the background image name: [%s] " %default_background)
  41. if not background:
  42. background = default_background
  43. default_port = '8888'
  44. port = raw_input("> Please enter the port number: [%s] " %default_port)
  45. if not port:
  46. port = default_port
  47. default_title = 'My Project'
  48. title = raw_input("> Please enter the project title: [%s] " %default_title)
  49. if not title:
  50. title = default_title
  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()