1
0

create_delivery_zip.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env python3
  2. #ident "@(#)$Format:LocalFoodAI: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. dummy_env = """# ==========================================
  20. # LOCAL FOOD AI - DUMMY CONFIGURATION
  21. # ==========================================
  22. # ------------------------------------------
  23. # 1. NETWORK & ENVIRONMENT MODE
  24. # ------------------------------------------
  25. # NETWORK_MODE: Controls network call execution.
  26. # Possible values: 'local' (or 'server')
  27. NETWORK_MODE=server
  28. LLM_MODEL=your_llm_model
  29. # ------------------------------------------
  30. # 2. DATABASE CREDENTIALS (MySQL)
  31. # ------------------------------------------
  32. MYSQL_ROOT_PASSWORD=your_mysql_root_pass
  33. DB_READER_PASS=your_db_reader_pass
  34. DB_LOADER_PASS=your_db_loader_pass
  35. DB_APP_AUTH_PASS=your_db_auth_pass
  36. MYSQL_ZABBIX_PASSWORD=your_mysql_zabbix_pass
  37. # ------------------------------------------
  38. # 3. ZABBIX & SNMP CREDENTIALS
  39. # ------------------------------------------
  40. ZABBIX_USER=Admin
  41. ZABBIX_PASS=your_zabbix_pass
  42. ZABBIX_SNMP_USER=zabbix_snmp
  43. ZABBIX_SNMP_AUTHKEY=your_snmp_authkey
  44. ZABBIX_SNMP_PRIVKEY=your_snmp_privkey
  45. DISCORD_WEBHOOK=your_discord_webhook
  46. # ------------------------------------------
  47. # 4. EMAIL ALERTS CONFIGURATION
  48. # ------------------------------------------
  49. EMAIL_USER=your_email@gmail.com
  50. EMAIL_PASS=your_email_app_password
  51. # ------------------------------------------
  52. # 5. TAIGA PROJECT MANAGEMENT CREDENTIALS
  53. # ------------------------------------------
  54. TAIGA_URL=your_taiga_url
  55. TAIGA_USER=your_taiga_user
  56. TAIGA_PASS=your_taiga_pass
  57. """
  58. with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
  59. zipf.writestr('.env', dummy_env)
  60. for root, dirs, files in os.walk(repo_root):
  61. for file in files:
  62. full_path = os.path.join(root, file)
  63. rel_path = os.path.relpath(full_path, repo_root)
  64. posix_path = rel_path.replace(os.sep, '/')
  65. # Check against .gitignore rules
  66. if not spec.match_file(posix_path):
  67. zipf.write(full_path, rel_path)
  68. print(f"Successfully created: delivery.zip")
  69. if __name__ == "__main__":
  70. main()