changes to setup workflow and instructions
This commit is contained in:
+85
-40
@@ -29,14 +29,19 @@ class DriveSendSetupNode:
|
||||
"multiline": False,
|
||||
"placeholder": "Google Drive Folder ID (from URL)"
|
||||
}),
|
||||
"storage_method": (["env_file", "display_only"],),
|
||||
"owner_email": ("STRING", {
|
||||
"default": "",
|
||||
"multiline": False,
|
||||
"placeholder": "Your Gmail address (for ownership transfer)"
|
||||
}),
|
||||
"storage_method": (["display_only", "env_file"],),
|
||||
"encryption_key_method": (["off", "Display Only", "save to .env"],),
|
||||
},
|
||||
"optional": {
|
||||
"service_account_path": ("STRING", {
|
||||
"default": "",
|
||||
"default": "service_account.json",
|
||||
"multiline": False,
|
||||
"placeholder": "Path to service_account.json (optional)"
|
||||
"placeholder": "Path to service_account.json"
|
||||
}),
|
||||
"reconnect": ("BOOLEAN", {"default": False}),
|
||||
}
|
||||
@@ -46,32 +51,56 @@ class DriveSendSetupNode:
|
||||
RETURN_NAMES = ("status",)
|
||||
FUNCTION = "setup"
|
||||
CATEGORY = "DriveSend"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def setup(
|
||||
self,
|
||||
auth_method,
|
||||
folder_id,
|
||||
owner_email,
|
||||
storage_method,
|
||||
encryption_key_method,
|
||||
service_account_path="",
|
||||
service_account_path="service_account.json",
|
||||
reconnect=False
|
||||
):
|
||||
output_lines = []
|
||||
env_vars = {}
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("[DriveSend Setup] Starting configuration...")
|
||||
print("="*60)
|
||||
|
||||
# Handle folder ID
|
||||
if folder_id:
|
||||
env_vars['GOOGLE_DRIVE_FOLDER_ID'] = folder_id
|
||||
output_lines.append(f"GOOGLE_DRIVE_FOLDER_ID={folder_id}")
|
||||
output_lines.append(f"✓ Folder ID configured")
|
||||
else:
|
||||
output_lines.append("⚠ No Folder ID provided - will upload to Drive root")
|
||||
|
||||
# Handle owner email (required for service account)
|
||||
if owner_email:
|
||||
env_vars['GOOGLE_OWNER_EMAIL'] = owner_email
|
||||
output_lines.append(f"✓ Owner Email: {owner_email}")
|
||||
elif auth_method == "service_account":
|
||||
output_lines.append("⚠ WARNING: No owner_email set!")
|
||||
output_lines.append(" Service accounts have 0 GB storage quota.")
|
||||
output_lines.append(" Files will fail to upload without ownership transfer.")
|
||||
|
||||
# Handle authentication based on method
|
||||
if auth_method == "service_account":
|
||||
# Try to find and encode service account
|
||||
# Try to find service account file
|
||||
sa_path = None
|
||||
|
||||
if service_account_path and Path(service_account_path).exists():
|
||||
sa_path = Path(service_account_path)
|
||||
elif (NODE_DIR / 'service_account.json').exists():
|
||||
# Check provided path first
|
||||
if service_account_path:
|
||||
check_path = Path(service_account_path)
|
||||
if check_path.exists():
|
||||
sa_path = check_path
|
||||
elif (NODE_DIR / service_account_path).exists():
|
||||
sa_path = NODE_DIR / service_account_path
|
||||
|
||||
# Fall back to default name in node directory
|
||||
if not sa_path and (NODE_DIR / 'service_account.json').exists():
|
||||
sa_path = NODE_DIR / 'service_account.json'
|
||||
|
||||
if sa_path:
|
||||
@@ -87,57 +116,65 @@ class DriveSendSetupNode:
|
||||
sa_data = json.loads(sa_json)
|
||||
client_email = sa_data.get('client_email', 'unknown')
|
||||
|
||||
output_lines.append(f"Service Account: {client_email}")
|
||||
output_lines.append(f"GOOGLE_SERVICE_ACCOUNT_JSON=<base64 encoded - {len(sa_base64)} chars>")
|
||||
output_lines.append(f"✓ Service Account loaded: {client_email}")
|
||||
output_lines.append(f" Make sure your Drive folder is shared with this email!")
|
||||
|
||||
print(f"\n[DriveSend Setup] Service Account loaded: {client_email}")
|
||||
print(f"[DriveSend Setup] Make sure to share your Google Drive folder with: {client_email}")
|
||||
print(f"\n[DriveSend Setup] Service Account: {client_email}")
|
||||
print(f"[DriveSend Setup] Share your Google Drive folder with: {client_email}")
|
||||
|
||||
except Exception as e:
|
||||
output_lines.append(f"Error loading service account: {e}")
|
||||
output_lines.append(f"✗ Error loading service account: {e}")
|
||||
else:
|
||||
output_lines.append("Warning: No service_account.json found")
|
||||
output_lines.append("Please place service_account.json in the node directory or provide a path")
|
||||
output_lines.append("✗ service_account.json NOT FOUND")
|
||||
output_lines.append("")
|
||||
output_lines.append("Please rename your downloaded JSON key file to:")
|
||||
output_lines.append(" service_account.json")
|
||||
output_lines.append("")
|
||||
output_lines.append("And place it in:")
|
||||
output_lines.append(f" {NODE_DIR}/")
|
||||
return ("\n".join(output_lines),)
|
||||
|
||||
elif auth_method == "oauth":
|
||||
# OAuth will be handled at runtime
|
||||
output_lines.append("")
|
||||
output_lines.append("⚠ OAuth WARNING:")
|
||||
output_lines.append(" OAuth tokens expire every 7 DAYS in testing mode.")
|
||||
output_lines.append(" You will need to re-authenticate weekly.")
|
||||
output_lines.append(" Service Account is recommended for persistent use.")
|
||||
output_lines.append("")
|
||||
|
||||
creds_path = NODE_DIR / 'credentials.json'
|
||||
token_path = NODE_DIR / 'token.json'
|
||||
|
||||
if creds_path.exists():
|
||||
output_lines.append("OAuth credentials.json found")
|
||||
output_lines.append("✓ OAuth credentials.json found")
|
||||
|
||||
if token_path.exists() and not reconnect:
|
||||
output_lines.append("Existing token.json found - already authenticated")
|
||||
output_lines.append("✓ Existing token.json found - already authenticated")
|
||||
else:
|
||||
output_lines.append("Run the AutoUploader node to complete OAuth authentication")
|
||||
output_lines.append("→ Run the AutoUploader node to complete OAuth authentication")
|
||||
if reconnect:
|
||||
# Delete existing token to force re-auth
|
||||
try:
|
||||
token_path.unlink()
|
||||
output_lines.append("Deleted existing token for reconnection")
|
||||
output_lines.append(" Deleted existing token for reconnection")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
output_lines.append("Warning: credentials.json not found")
|
||||
output_lines.append("Please download OAuth credentials from Google Cloud Console")
|
||||
output_lines.append("✗ credentials.json NOT FOUND")
|
||||
output_lines.append(" Download OAuth credentials from Google Cloud Console")
|
||||
|
||||
# Handle encryption key
|
||||
if encryption_key_method != "off":
|
||||
# Check if key already exists
|
||||
existing_key = os.environ.get('comfyui_encryption_key')
|
||||
|
||||
if existing_key and not reconnect:
|
||||
output_lines.append("Encryption key already configured")
|
||||
output_lines.append("✓ Encryption key already configured")
|
||||
env_vars['comfyui_encryption_key'] = existing_key
|
||||
else:
|
||||
# Generate new key
|
||||
new_key = generate_key()
|
||||
env_vars['comfyui_encryption_key'] = new_key
|
||||
output_lines.append(f"comfyui_encryption_key={new_key}")
|
||||
print(f"\n[DriveSend Setup] Generated encryption key: {new_key}")
|
||||
output_lines.append("✓ New encryption key generated")
|
||||
|
||||
# Save to .env file if requested
|
||||
# Output based on storage method
|
||||
if storage_method == "env_file" and env_vars:
|
||||
env_path = NODE_DIR / '.env'
|
||||
|
||||
@@ -159,22 +196,30 @@ class DriveSendSetupNode:
|
||||
for key, value in existing_vars.items():
|
||||
f.write(f"{key}={value}\n")
|
||||
|
||||
output_lines.append(f"\nCredentials saved to: {env_path}")
|
||||
print(f"[DriveSend Setup] Credentials saved to {env_path}")
|
||||
output_lines.append(f"\n✓ Credentials saved to: {env_path}")
|
||||
|
||||
elif storage_method == "display_only":
|
||||
output_lines.append("\n--- Copy these to your environment variables ---")
|
||||
output_lines.append("")
|
||||
output_lines.append("="*50)
|
||||
output_lines.append("COPY THESE TO RUNPOD SECRETS / ENV VARIABLES:")
|
||||
output_lines.append("="*50)
|
||||
|
||||
# Print to console for copying
|
||||
print("\n" + "="*60)
|
||||
print("COPY THESE VALUES TO YOUR ENVIRONMENT VARIABLES:")
|
||||
print("="*60)
|
||||
|
||||
for key, value in env_vars.items():
|
||||
if key == 'GOOGLE_SERVICE_ACCOUNT_JSON':
|
||||
# Print full base64 for copying
|
||||
print(f"\n{key}={value}")
|
||||
else:
|
||||
print(f"{key}={value}")
|
||||
print(f"\n{key}={value}")
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("See console output above for full values to copy")
|
||||
print("="*60)
|
||||
|
||||
# Print summary
|
||||
print("\n" + "="*50)
|
||||
print("\n" + "="*60)
|
||||
print("[DriveSend Setup] Configuration complete!")
|
||||
print("="*50)
|
||||
print("="*60 + "\n")
|
||||
|
||||
status = "\n".join(output_lines)
|
||||
return (status,)
|
||||
|
||||
Reference in New Issue
Block a user