create_delivery_zip.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env python3
  2. #ident "@(#)$Format:LocalFoodAI_lanfr144:create_delivery_zip.py:%an:%ae:%ad:%cn:%ce:%cd:%H:%D:%N$"
  3. import os
  4. import zipfile
  5. import pathspec
  6. def main():
  7. repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  8. gitignore_path = os.path.join(repo_root, ".gitignore")
  9. if os.path.exists(gitignore_path):
  10. with open(gitignore_path, 'r') as f:
  11. spec = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, f)
  12. else:
  13. spec = pathspec.PathSpec([])
  14. # Standard ignores
  15. spec.patterns.append(pathspec.patterns.GitWildMatchPattern('.git/'))
  16. spec.patterns.append(pathspec.patterns.GitWildMatchPattern('*.zip'))
  17. zip_path = os.path.join(repo_root, "delivery.zip")
  18. print(f"Building {zip_path}...")
  19. network_mode = 'server'
  20. llm_model = 'your_llm_model'
  21. env_path = os.path.join(repo_root, ".env")
  22. if os.path.exists(env_path):
  23. with open(env_path, 'r') as f:
  24. for line in f:
  25. if line.startswith('NETWORK_MODE='):
  26. network_mode = line.strip().split('=', 1)[1]
  27. elif line.startswith('LLM_MODEL='):
  28. llm_model = line.strip().split('=', 1)[1]
  29. dummy_env = f"""# ==========================================
  30. # LOCAL FOOD AI - DUMMY CONFIGURATION
  31. # ==========================================
  32. # ------------------------------------------
  33. # 1. NETWORK & ENVIRONMENT MODE
  34. # ------------------------------------------
  35. # NETWORK_MODE: Controls network call execution.
  36. # Possible values: 'local' (or 'server')
  37. NETWORK_MODE={network_mode}
  38. LLM_MODEL={llm_model}
  39. # ------------------------------------------
  40. # 2. DATABASE CREDENTIALS (MySQL)
  41. # ------------------------------------------
  42. MYSQL_ROOT_PASSWORD=your_mysql_root_pass
  43. DB_READER_PASS=your_db_reader_pass
  44. DB_LOADER_PASS=your_db_loader_pass
  45. DB_APP_AUTH_PASS=your_db_auth_pass
  46. MYSQL_ZABBIX_PASSWORD=your_mysql_zabbix_pass
  47. # ------------------------------------------
  48. # 3. ZABBIX & SNMP CREDENTIALS
  49. # ------------------------------------------
  50. ZABBIX_URL=your_zabbix_url
  51. ZABBIX_USER=your_zabbix_user
  52. ZABBIX_PASS=your_zabbix_pass
  53. ZABBIX_SNMP_USER=your_snmp_user
  54. ZABBIX_SNMP_AUTHKEY=your_snmp_authkey
  55. ZABBIX_SNMP_PRIVKEY=your_snmp_privkey
  56. DISCORD_WEBHOOK=your_discord_webhook
  57. # ------------------------------------------
  58. # 4. EMAIL ALERTS CONFIGURATION
  59. # ------------------------------------------
  60. EMAIL_USER=your_email_user
  61. EMAIL_PASS=your_email_pass
  62. # ------------------------------------------
  63. # 5. TAIGA PROJECT MANAGEMENT CREDENTIALS
  64. # ------------------------------------------
  65. TAIGA_URL=your_taiga_url
  66. TAIGA_USER=your_taiga_user
  67. TAIGA_PASS=your_taiga_pass
  68. # ------------------------------------------
  69. # 6. SERVER DEPLOYMENT CREDENTIALS
  70. # ------------------------------------------
  71. SERVER_HOST=your_server_host
  72. SERVER_USER=your_server_user
  73. SERVER_PASS=your_server_pass
  74. """
  75. with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
  76. zipf.writestr('.env', dummy_env)
  77. for root, dirs, files in os.walk(repo_root):
  78. for file in files:
  79. full_path = os.path.join(root, file)
  80. rel_path = os.path.relpath(full_path, repo_root)
  81. posix_path = rel_path.replace(os.sep, '/')
  82. # Check against .gitignore rules
  83. if not spec.match_file(posix_path):
  84. zipf.write(full_path, rel_path)
  85. print(f"Successfully created: delivery.zip")
  86. if __name__ == "__main__":
  87. main()