Git Product home page Git Product logo

Comments (4)

kylebarron avatar kylebarron commented on May 30, 2024

Fixed for windows:
dcb590a

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

Print notice to console if couldn't find path

from stata_kernel.

mcaceresb avatar mcaceresb commented on May 30, 2024

I usually do shutil.which but you could try finding anything in the user's path that looks like "stata", right? Modified from this SO answer

from glob import glob
import os


def is_exe(fpath):
    return os.path.isfile(fpath) and os.access(fpath, os.X_OK)


def which(program):
    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
        else:
            matches  = glob(program)
            exe_list = []
            for p in matches:
                if is_exe(p):
                    exe_list += [p]

            if len(exe_list) > 0:
                return exe_list
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

        exe_list = []
        for path in os.environ["PATH"].split(os.pathsep):
            exe_file = os.path.join(path, program)
            matches  = glob(exe_file)
            for p in matches:
                if is_exe(p):
                    exe_list += [p]

        if len(exe_list) > 0:
            return exe_list

    return None

Then if which("stata") returns None, try which("stata*") and then figure out a rule to parse that list (prefer names that match "stata15" or "stata15.*mp" and such).

from stata_kernel.

kylebarron avatar kylebarron commented on May 30, 2024

Yes, this would be helpful. I also want to try and search through the default save locations on Mac, where it's unlikely Stata will be on the user's path

from stata_kernel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.