Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Gets IP using one of the services.

:param str preffered checker: Checker UID. If given, the preferred checker is used.
:param bool print_info: If set to True, debug info is printed.
:return str:

        def get_public_ip(preferred_checker=None, print_info=False):
    """
    Gets IP using one of the services.

    :param str preffered checker: Checker UID. If given, the preferred checker is used.
    :param bool print_info: If set to True, debug info is printed.
    :return str:
    """
    ensure_autodiscover()

    # If use preferred checker.
    if preferred_checker:
        ip_checker_cls = registry.get(preferred_checker)

        if not ip_checker_cls:
            return False

        ip_checker = ip_checker_cls()
        ip = ip_checker.get_public_ip()

        if print_info:
            print_('provider: ', ip_checker_cls)
        return ip

    # Using all checkers.

    for ip_checker_name, ip_checker_cls in registry._registry.items():
        ip_checker = ip_checker_cls()
        try:
            ip = ip_checker.get_public_ip()
            if ip:
                if print_info:
                    print_('provider: ', ip_checker_cls)
                return ip

        except Exception as e:
            pass

    return False
        


src/d/j/django-dash-0.4.4/src/dash/contrib/plugins/weather/forms.py   django-dash(Download)
from django.utils.translation import ugettext_lazy as _
 
from pif import get_public_ip
 
from dash.base import DashboardPluginFormBase
        if not self.cleaned_data.get('public_ip', None):
            try:
                self.cleaned_data['public_ip'] = get_public_ip()
            except Exception as e:
                if DEBUG:

src/d/j/django-dash-HEAD/src/dash/contrib/plugins/weather/forms.py   django-dash(Download)
from django.utils.translation import ugettext_lazy as _
 
from pif import get_public_ip
 
from dash.base import DashboardPluginFormBase
        if not self.cleaned_data.get('public_ip', None):
            try:
                self.cleaned_data['public_ip'] = get_public_ip()
            except Exception as e:
                if DEBUG: