zhongrj
2025-11-25 b89962006164a462404b79a738bee8cbb6d7fe7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
from django.core.management.base import BaseCommand
import socket
 
class Command(BaseCommand):
    requires_system_checks = []
 
    def add_arguments(self, parser):
        parser.add_argument("host", type=str)
        
        super(Command, self).add_arguments(parser)
 
    def handle(self, **options):
        host = options.get('host')
        try:
            socket.gethostbyname(host)
            print(host)
        except:
            # Try replacing _ with "-"
            host = host.replace("_", "-")
            print(host)