save_conf.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. @Auther :liuyuqi.gov@msn.cn
  5. @Time :2018/7/4 15:55
  6. @File :main.py
  7. '''
  8. from configparser import ConfigParser
  9. config_file = "../conf/config.ini"
  10. data_path = "../data/"
  11. section_name = "data_file_name"
  12. cf = ConfigParser()
  13. def write():
  14. if not cf.has_section(section_name):
  15. cf.add_section(section_name)
  16. cf.set(section_name, "app_interference", data_path + "scheduling_preliminary_app_interference_20180606.csv")
  17. cf.set(section_name, "app_resources", data_path + "scheduling_preliminary_app_resources_20180606.csv")
  18. cf.set(section_name, "instance_deploy", data_path + "scheduling_preliminary_instance_deploy_20180606.csv")
  19. cf.set(section_name, "machine_resources", data_path + "scheduling_preliminary_machine_resources_20180606.csv")
  20. cf.set(section_name, "instance", data_path + "instance.csv")
  21. cf.set(section_name, "app", data_path + "app.csv")
  22. if not cf.has_section("table_size"):
  23. cf.add_section("table_size")
  24. cf.set("table_size", "app_size", "9338")
  25. cf.set("table_size", "machine_size", "6000")
  26. cf.set("table_size", "instance_size", "68219")
  27. cf.set("table_size", "app12_size", "35242")
  28. if not cf.has_section("system_config"):
  29. cf.add_section("system_config")
  30. cf.set("system_config", "debug", "true")
  31. if not cf.has_section("db_mysql"):
  32. cf.add_section("db_mysql")
  33. cf.set("db_mysql", "db_host", "localhost")
  34. cf.set("db_mysql", "db_port", "3306")
  35. cf.set("db_mysql", "db_user", "root")
  36. cf.set("db_mysql", "db_pass", "1233456")
  37. with open(config_file, "w") as f:
  38. cf.write(f)
  39. def read():
  40. cf.read(config_file)
  41. print(cf.get(section_name, "app_interference"))