-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforce_upload.py
More file actions
125 lines (105 loc) · 3.79 KB
/
Copy pathforce_upload.py
File metadata and controls
125 lines (105 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
"""
FORCE UPLOAD with verification
"""
import paramiko
import os
import sys
import os
# Use environment variables for One.com SFTP credentials
HOST = os.environ.get("ONE_SFTP_HOST")
USERNAME = os.environ.get("ONE_SFTP_USER")
PASSWORD = os.environ.get("ONE_SFTP_PASSWORD")
PORT = int(os.environ.get("ONE_SFTP_PORT", "22"))
REMOTE_PATH = os.environ.get("ONE_SFTP_REMOTE_ROOT", "/webroots/dae9921c/")
LOCAL_PATH = os.environ.get("ONE_LOCAL_UPLOAD_PATH", "c:/Users/gebruiker/Desktop/mijn_api/webshop_for_upload")
print("=" * 70)
print("🚀 FORCE UPLOAD - Modern Homepage to One.com")
print("=" * 70)
print()
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if not (HOST and USERNAME and PASSWORD):
print("Missing SFTP credentials. Set ONE_SFTP_HOST, ONE_SFTP_USER, and ONE_SFTP_PASSWORD environment variables.")
raise SystemExit(1)
print(f"🔌 Connecting to {HOST}:{PORT} as {USERNAME}...")
ssh.connect(HOST, port=PORT, username=USERNAME, password=PASSWORD, timeout=30)
print("✅ Connected!")
print()
sftp = ssh.open_sftp()
local_file = os.path.join(LOCAL_PATH, "index.html")
remote_file = REMOTE_PATH + "index.html"
backup_file = REMOTE_PATH + "index.html.backup"
# Check local file
print("📄 Checking local file...")
with open(local_file, 'r', encoding='utf-8') as f:
local_content = f.read()
print(f" Size: {len(local_content)} bytes")
if 'Blockchain Payments Made Simple' in local_content:
print(" ✅ Modern content confirmed")
else:
print(" ❌ ERROR: Local file doesn't have modern content!")
sys.exit(1)
print()
print("💾 Creating backup of current server file...")
try:
# Backup current file
sftp.rename(remote_file, backup_file)
print(" ✅ Backup created: index.html.backup")
except:
print(" ⚠️ No existing file to backup (or backup failed)")
print()
print("📤 Uploading NEW index.html...")
sftp.put(local_file, remote_file)
print(" ✅ Upload complete")
print()
print("🔧 Setting permissions...")
sftp.chmod(remote_file, 0o644)
print(" ✅ Permissions set (644)")
print()
print("✅ Verifying upload...")
with sftp.open(remote_file, 'r') as f:
remote_content = f.read(5000).decode('utf-8')
checks = {
'Blockchain Payments Made Simple': False,
'MODERN V2 LOADED': False,
'dashboard-section': False,
'#features': False
}
for check_text in checks.keys():
if check_text in remote_content:
checks[check_text] = True
print(f" ✅ Found: '{check_text}'")
else:
print(f" ❌ Missing: '{check_text}'")
if all(checks.values()):
print()
print("=" * 70)
print("🎉 SUCCESS! Modern homepage is NOW LIVE on server!")
print("=" * 70)
else:
print()
print("⚠️ WARNING: Upload succeeded but some content checks failed")
# Get file stats
attrs = sftp.stat(remote_file)
print()
print(f"📊 Server file info:")
print(f" Size: {attrs.st_size} bytes")
print(f" Permissions: {oct(attrs.st_mode)}")
sftp.close()
ssh.close()
print()
print("=" * 70)
print("✅ DEPLOYMENT COMPLETE!")
print("=" * 70)
print()
print("🌐 Visit: https://apiblockchain.io")
print("🔄 Hard refresh: Ctrl+Shift+R")
print("🕶️ Incognito: Ctrl+Shift+N")
print()
except Exception as e:
print(f"❌ ERROR: {e}")
import traceback
traceback.print_exc()
sys.exit(1)