environment/lib/python2.7/site-packages/IPython/parallel/apps/ipcontrollerapp.py
def save_connection_dict(self, fname, cdict):
        """save a connection dict to json file."""
        c = self.config
        url = cdict['url']
        location = cdict['location']
        if not location:
            try:
                proto,ip,port = split_url(url)
            except AssertionError:
                pass
            else:
                try:
                    location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
                except (socket.gaierror, IndexError):
                    self.log.warn("Could not identify this machine's IP, assuming 127.0.0.1."
                    " You may need to specify '--location=<external_ip_address>' to help"
                    " IPython decide when to connect via loopback.")
                    location = '127.0.0.1'
            cdict['location'] = location
        fname = os.path.join(self.profile_dir.security_dir, fname)
        self.log.info("writing connection info to %s", fname)
        with open(fname, 'w') as f:
            f.write(json.dumps(cdict, indent=2))
        os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)
def save_connection_dict(self, fname, cdict):
        c = self.config
        url = cdict['url']
        location = cdict['location']
        if not location:
            try:
                proto,ip,port = split_url(url)
            except AssertionError:
                pass
            else:
                try:
                    location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
                except (socket.gaierror, IndexError):
                    self.log.warn("Could not identify this machine's IP, assuming 127.0.0.1."
                    " You may need to specify '--location=<external_ip_address>' to help"
                    " IPython decide when to connect via loopback.")
                    location = '127.0.0.1'
            cdict['location'] = location
        fname = os.path.join(self.profile_dir.security_dir, fname)
        self.log.info("writing connection info to %s", fname)
        with open(fname, 'w') as f:
            f.write(json.dumps(cdict, indent=2))
        os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)
def save_connection_dict ( self , fname , cdict ) : c = self . config url = cdict [ 'url' ] location = cdict [ 'location' ] if not location : try : proto , ip , port = split_url ( url ) except AssertionError : pass else : try : location = socket . gethostbyname_ex ( socket . gethostname ( ) ) [ 2 ] [ - 1 ] except ( socket . gaierror , IndexError ) : self . log . warn ( "Could not identify this machine's IP, assuming 127.0.0.1." " You may need to specify '--location=<external_ip_address>' to help" " IPython decide when to connect via loopback." ) location = '127.0.0.1' cdict [ 'location' ] = location fname = os . path . join ( self . profile_dir . security_dir , fname ) self . log . info ( "writing connection info to %s" , fname ) with open ( fname , 'w' ) as f : f . write ( json . dumps ( cdict , indent = 2 ) ) os . chmod ( fname , stat . S_IRUSR | stat . S_IWUSR )
save a connection dict to json file.
save a connection dict to json file .