Beispiel #1
0
 def filename(self):
     """Create a .ini filename located in user home directory."""
     folder = osp.join(get_home_dir(), self.subfolder)
     # Save defaults in a "defaults" dir of .anaconda_navigator to not
     # pollute it
     if 'defaults' in self.name:
         folder = osp.join(folder, 'defaults')
     try:
         os.makedirs(folder)
     except os.error:
         # Folder (or one of its parents) already exists
         pass
     ini_file = osp.join(folder, '{0}.ini'.format(self.name))
     return ini_file
Beispiel #2
0
def run_notebook(project_path, project=None, filename=""):
    """
    Start notebook server.
    """
    from anaconda_navigator.api import AnacondaAPI
    api = AnacondaAPI()

    if project is None:
        project = api.load_project(project_path)

    kernels_folder = os.sep.join([get_home_dir(), ".ipython", "kernels"])
    display_name = '{0} ({1})'.format(project.name, project_path)
    kernel_uuid = uuid.uuid1()
    kernel_path = os.sep.join([kernels_folder, "{name}", "kernel.json"])
    pyexec = os.sep.join([project.env_prefix(project_path), 'bin', 'python'])
    spec = {
        "argv": [pyexec, "-m", "IPython.kernel", "-f", "{connection_file}"],
        "display_name": display_name,
        "language": "python",
    }

    # Delete any other kernel sec mathching this name!
    kernels = os.listdir(kernels_folder)
    for kernel in kernels:
        path = os.sep.join([kernels_folder, kernel])
        file_path = os.sep.join([path, 'kernel.json'])

        if os.path.isfile(file_path):
            with open(file_path, 'r') as f:
                data = json.loads(f.read())

            name = data.get('display_name', None)
            if name is not None and project_path in name:
                shutil.rmtree(path)

    os.makedirs(os.path.split(kernel_path.format(name=kernel_uuid))[0])

    with open(kernel_path.format(name=kernel_uuid), 'w') as f:
        f.write(json.dumps(spec))

    # This is not working!
    cmd = ('jupyter notebook '
           '--KernelSpecManager.whitelist={%s}' % kernel_uuid)

    cmd = ('jupyter notebook')
    command = (cmd + ' ' + filename)
    logger.debug(",".join([command, project_path]))
    subprocess.Popen(command.split(), cwd=project_path)
Beispiel #3
0
        LINUX_DNF = False
        # print(e)

    # print('is DEB', LINUX_DEB)
    # print('is RPM', LINUX_RPM)

UBUNTU = is_ubuntu()
GTK = is_gtk_desktop()
DEV = 'dev' in __version__
BITS = 8 * tuple.__itemsize__
BITS_64 = BITS == 64
BITS_32 = BITS == 32
OS_64_BIT = platform.machine().endswith('64')

# Paths
HOME_PATH = get_home_dir()
CONF_PATH = get_conf_path()
LAUNCH_SCRIPTS_PATH = os.path.join(CONF_PATH, 'scripts')
CONTENT_PATH = os.path.join(CONF_PATH, 'content')
CONTENT_JSON_PATH = os.path.join(CONTENT_PATH, 'content.json')
IMAGE_ICON_SIZE = (256, 256)
IMAGE_DATA_PATH = os.path.join(CONF_PATH, 'images')
CHANNELS_PATH = os.path.join(CONF_PATH, 'channels')
METADATA_PATH = os.path.join(CONF_PATH, 'metadata')
DEFAULT_PROJECTS_PATH = os.path.join(HOME_PATH, 'AnacondaProjects')
LOCKFILE = os.path.join(CONF_PATH, 'navigator.lock')
PIDFILE = os.path.join(CONF_PATH, 'navigator.pid')
DEFAULT_BRAND = 'Anaconda Cloud'
GLOBAL_VSCODE_APP = 'vscode'

# License management