'Generate a new connection file
Taken from jupyter_client/console_app.py
Licensed under the BSD license'

def _new_connection_file(self):

    if (not osp.isdir(jupyter_runtime_dir())):
        try:
            os.makedirs(jupyter_runtime_dir())
        except PermissionError:
            return None
    cf = ''
    while (not cf):
        ident = str(uuid.uuid4()).split('-')[(-1)]
        cf = os.path.join(jupyter_runtime_dir(), ('kernel-%s.json' % ident))
        cf = (cf if (not os.path.exists(cf)) else '')
    return cf
