def run_wing():
    """Runs the Wing IDE using our template project file."""
    parser = OptionParser()
    parser.add_option(
        "-w", "--wingpath", action="store", type="string", dest="wingpath", help="location of WingIDE executable"
    )
    parser.add_option(
        "-p",
        "--projpath",
        action="store",
        type="string",
        dest="projpath",
        default="",
        help="location of WingIDE project file",
    )
    parser.add_option(
        "-v", "--version", action="store", type="string", dest="version", default="4.0", help="version of WingIDE"
    )
    (options, args) = parser.parse_args(sys.argv[1:])

    wingpath = options.wingpath
    projpath = options.projpath
    version = options.version
    if len(version) == 1:
        version = version + ".0"

    if not os.path.isfile(projpath):
        venvdir = os.path.dirname(os.path.dirname(sys.executable))
        proj_template = os.path.join(os.path.dirname(venvdir), "config", "wing_proj_template.wpr")
        projpath = os.path.join(venvdir, "etc", "wingproj.wpr")
        _modify_wpr_file(proj_template, projpath, version)

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = os.environ
    if sys.platform != "win32":
        libs = env.get("LD_LIBRARY_PATH", "").split(os.pathsep)
        rtop = find_up(".git")
        if not rtop:
            rtop = find_up(".git")
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set([os.path.dirname(x) for x in find_files(rtop, "*.so")])
            libs.extend(sodirs)
            env["LD_LIBRARY_PATH"] = os.pathsep.join(libs)

    if sys.platform == "darwin":
        cmd = ["open", projpath]
    else:
        if not wingpath:
            wingpath = _find_wing()
        cmd = [wingpath, projpath]
    try:
        Popen(cmd, env=env)
    except Exception as err:
        print "Failed to run command '%s'." % " ".join(cmd)
def run_wing():
    """Runs the Wing IDE using our template project file."""
    wingpath = None
    projpath = ""
    for arg in sys.argv[1:]:
        if arg.startswith("--wingpath="):
            wingpath = arg.split("=")[1]
        elif arg.startswith("--proj="):
            projpath = arg.split("=")[1]
    if not wingpath:
        if sys.platform == "win32":
            wname = "wing.exe"
            locs = [r"C:\Program Files (x86)\WingIDE 3.2"]
        elif sys.platform == "darwin":
            wname = "wing"
            locs = ["/Applications/WingIDE.app/Contents/MacOS", "/Applications/Wing/WingIDE.app/Contents/MacOS"]
        else:
            wname = "wing3.2"
            locs = ["/usr/bin", "/usr/sbin", "/usr/local/bin"]

        wingpath = find_in_path(wname)  # searches PATH
        if not wingpath:
            wingpath = find_in_dir_list(wname, locs)  # look in common places
        if not wingpath:
            raise OSError("%s was not found in PATH or in any of the common places." % wname)

    if not os.path.isfile(projpath):
        venvdir = os.path.dirname(os.path.dirname(sys.executable))
        projpath = os.path.join(venvdir, "etc", "wingproj.wpr")

    if sys.platform == "darwin":
        _modify_wpr_file(projpath)  # have to put virtualenv sys path info in wing project file on Mac

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = os.environ
    if sys.platform != "win32":
        libs = env.get("LD_LIBRARY_PATH", "").split(os.pathsep)
        rtop = find_up(".git")
        if not rtop:
            rtop = find_up(".git")
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set([os.path.dirname(x) for x in find_files(rtop, "*.so")])
            libs.extend(sodirs)
            env["LD_LIBRARY_PATH"] = os.pathsep.join(libs)

    try:
        Popen([wingpath, projpath], env=env)
    except Exception as err:
        print "Failed to run wing executable (%s) using project (%s)." % (wingpath, projpath)
Exemple #3
0
def repo_top():
    """Return the top level directory in the current Git repository."""
    # apparently --show-toplevel doesn't work until git 1.7 :(
    # p = Popen('git rev-parse --show-toplevel',
    # stdout=PIPE, stderr=STDOUT, env=os.environ, shell=True)
    # return p.communicate()[0].strip()
    d = find_up(".git")
    if d is None:
        return d
    return os.path.dirname(d)
Exemple #4
0
def repo_top():
    """Return the top level directory in the current Git repository."""
    # apparently --show-toplevel doesn't work until git 1.7 :(
    # p = Popen('git rev-parse --show-toplevel',
    # stdout=PIPE, stderr=STDOUT, env=os.environ, shell=True)
    # return p.communicate()[0].strip()
    d = find_up('.git')
    if d is None:
        return d
    return os.path.dirname(d)
def run_wing():
    """Runs the Wing IDE using our template project file."""
    parser = OptionParser()
    parser.add_option("-w",
                      "--wingpath",
                      action="store",
                      type="string",
                      dest="wingpath",
                      help="location of WingIDE executable")
    parser.add_option("-p",
                      "--projpath",
                      action="store",
                      type="string",
                      dest="projpath",
                      default='',
                      help="location of WingIDE project file")
    parser.add_option("-v",
                      "--version",
                      action="store",
                      type="string",
                      dest="version",
                      default='5.0',
                      help="version of WingIDE")
    (options, args) = parser.parse_args(sys.argv[1:])

    wingpath = options.wingpath
    projpath = options.projpath
    version = options.version
    if len(version) == 1:
        version = version + '.0'

    if not os.path.isfile(projpath):

        # Support different versions of Wing
        major_rev = int(version.split('.')[0])
        if major_rev > 4:
            wingproj_file = 'wing_proj_template5.wpr'
        else:
            wingproj_file = 'wing_proj_template.wpr'

        venvdir = os.path.dirname(os.path.dirname(sys.executable))
        proj_template = os.path.join(os.path.dirname(venvdir), 'config',
                                     wingproj_file)
        projpath = os.path.join(venvdir, 'etc', 'wingproj.wpr')
        _modify_wpr_file(proj_template, projpath, version)

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = {}
    env.update(os.environ)
    if sys.platform == 'darwin':
        libpname = 'DYLD_LIBRARY_PATH'
        libext = '*.dyld'
    elif not sys.platform.startswith('win'):
        libpname = 'LD_LIBRARY_PATH'
        libext = '*.so'
    else:
        libpname = None

    if libpname:
        libs = env.get(libpname, '').split(os.pathsep)
        rtop = find_up('.git')
        if not rtop:
            rtop = find_up('.git')
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set(
                [os.path.dirname(x) for x in find_files(rtop, libext)])
            libs.extend(sodirs)
            env[libpname] = os.pathsep.join(libs)

    if sys.platform == 'darwin':
        cmd = ['open', projpath]
    else:
        if not wingpath:
            wingpath = _find_wing()
        cmd = [wingpath, projpath]
    try:
        print "wing command: ", ' '.join(cmd)
        Popen(cmd, env=env)
    except Exception as err:
        print "Failed to run command '%s'." % ' '.join(cmd)
def run_wing():
    """Runs the Wing IDE using our template project file."""
    parser = OptionParser()
    parser.add_option("-w", "--wingpath", action="store", type="string",
                      dest="wingpath", help="location of WingIDE executable")
    parser.add_option("-p", "--projpath", action="store", type="string",
                      dest="projpath", default='',
                      help="location of WingIDE project file")
    parser.add_option("-v", "--version", action="store", type="string",
                      dest="version", default='5.0',
                      help="version of WingIDE")
    (options, args) = parser.parse_args(sys.argv[1:])

    wingpath = options.wingpath
    projpath = options.projpath
    version = options.version
    if len(version)==1:
        version = version + '.0'

    if not os.path.isfile(projpath):

        # Support different versions of Wing
        major_rev = int(version.split('.')[0])
        if major_rev > 4:
            wingproj_file = 'wing_proj_template5.wpr'
        else:
            wingproj_file = 'wing_proj_template.wpr'

        venvdir = os.path.dirname(os.path.dirname(sys.executable))
        proj_template = os.path.join(os.path.dirname(venvdir),
                                     'config',wingproj_file)
        projpath = os.path.join(venvdir, 'etc', 'wingproj.wpr')
        _modify_wpr_file(proj_template, projpath, version)

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = {}
    env.update(os.environ)
    if sys.platform == 'darwin':
        libpname = 'DYLD_LIBRARY_PATH'
        libext = '*.dyld'
    elif not sys.platform.startswith('win'):
        libpname = 'LD_LIBRARY_PATH'
        libext = '*.so'
    else:
        libpname = None

    if libpname:
        libs = env.get(libpname,'').split(os.pathsep)
        rtop = find_up('.git')
        if not rtop:
            rtop = find_up('.git')
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set([os.path.dirname(x) for x in find_files(rtop, libext)])
            libs.extend(sodirs)
            env[libpname] = os.pathsep.join(libs)

    if sys.platform == 'darwin':
        cmd = ['open', projpath]
    else:
        if not wingpath:
            wingpath = _find_wing()
        cmd = [wingpath, projpath]
    try:
        print "wing command: ",' '.join(cmd)
        Popen(cmd, env=env)
    except Exception as err:
        print "Failed to run command '%s'." % ' '.join(cmd)
Exemple #7
0
def run_wing():
    """Runs the Wing IDE using our template project file."""
    parser = OptionParser()
    parser.add_option("-w",
                      "--wingpath",
                      action="store",
                      type="string",
                      dest="wingpath",
                      help="location of WingIDE executable")
    parser.add_option("-p",
                      "--projpath",
                      action="store",
                      type="string",
                      dest="projpath",
                      default='',
                      help="location of WingIDE project file")
    parser.add_option("-v",
                      "--version",
                      action="store",
                      type="string",
                      dest="version",
                      default='4.0',
                      help="version of WingIDE")
    (options, args) = parser.parse_args(sys.argv[1:])

    wingpath = options.wingpath
    projpath = options.projpath
    version = options.version
    if len(version) == 1:
        version = version + '.0'

    if not os.path.isfile(projpath):
        venvdir = os.path.dirname(os.path.dirname(sys.executable))
        proj_template = os.path.join(os.path.dirname(venvdir), 'config',
                                     'wing_proj_template.wpr')
        projpath = os.path.join(venvdir, 'etc', 'wingproj.wpr')
        _modify_wpr_file(proj_template, projpath, version)

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = os.environ
    if sys.platform != 'win32':
        libs = env.get('LD_LIBRARY_PATH', '').split(os.pathsep)
        rtop = find_up('.git')
        if not rtop:
            rtop = find_up('.git')
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set(
                [os.path.dirname(x) for x in find_files(rtop, '*.so')])
            libs.extend(sodirs)
            env['LD_LIBRARY_PATH'] = os.pathsep.join(libs)

    if sys.platform == 'darwin':
        cmd = ['open', projpath]
    else:
        if not wingpath:
            wingpath = _find_wing()
        cmd = [wingpath, projpath]
    try:
        Popen(cmd, env=env)
    except Exception as err:
        print "Failed to run command '%s'." % ' '.join(cmd)