Beispiel #1
0
 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)
     with open(fname, 'wb') 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):
     """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:
             location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
         cdict['location'] = location
     fname = os.path.join(self.profile_dir.security_dir, fname)
     with open(fname, 'wb') as f:
         f.write(json.dumps(cdict, indent=2))
     os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)
Beispiel #3
0
 def save_connection_dict(self, fname, cdict):
     """save a connection dict to json file."""
     c = self.master_config
     url = cdict['url']
     location = cdict['location']
     if not location:
         try:
             proto,ip,port = split_url(url)
         except AssertionError:
             pass
         else:
             location = socket.gethostbyname_ex(socket.gethostname())[2][-1]
         cdict['location'] = location
     fname = os.path.join(c.Global.security_dir, 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):
     """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)
     with open(fname, 'wb') as f:
         f.write(json.dumps(cdict, indent=2))
     os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR)