start.py 2.6 KB

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