Example #1
0
def nxipython(wtshell=False):
    """nxipython

    Call a IPython shell REPL.

    The `IPYTHONDIR` is set up to sys.prefix/nexiles_ipython_profile if not set.

    If `wtshell` is true, an attempt is made to set up the JVM class path
    suitable for Windchill hacking.

    :param wtshell: whether or not to set up a Windchill shell.
    """
    if "IPYTHONDIR" not in os.environ:
        ipython_dir = os.path.join(sys.prefix, "nexiles_ipython_profile")
        print "Setting IPYTHONDIR to default: %s " % ipython_dir
        os.environ["IPYTHONDIR"] = ipython_dir

    if wtshell and "WT_HOME" in os.environ:
        print "Windchill shell requested -- setting up JVM class loader"

        from wt_classpath import set_windchill_classpath
        set_windchill_classpath(os.environ["WT_HOME"])

    try:
        from IPython.Shell import IPShellEmbed
        sh = IPShellEmbed()
        return sh()
    except:
        import code
        return code.interact()
Example #2
0
def main():
    if "WT_HOME" not in os.environ:
        print "please set WT_HOME."
        sys.exit(10)
    WT_HOME = os.environ["WT_HOME"]
    wt_classpath.set_windchill_classpath(WT_HOME)
    code.interact()
Example #3
0
for index, p in enumerate(sys.path):
    if ".jar" in p:
        site_packages_dir = os.path.join(p, "site-packages")
        sys.path.insert(index + 1, site_packages_dir)

        # also add pip and distribute
        sys.path.append(site_packages_dir + "/distribute-0.6.31-py2.5.egg")
        sys.path.append(site_packages_dir + "/pip-1.2.1-py2.5.egg")
        break

sys.add_package("org.json")
sys.add_package("org.json.simple")
sys.add_package("org.json.simple.parser")

from monkey import patch
patch()

# add WEB-INF/lib-python as site dir if we have a WT_HOME
if "WT_HOME" in os.environ:
    from site import addsitedir

    WT_HOME = os.environ["WT_HOME"]
    addsitedir(os.path.join(WT_HOME, "codebase", "WEB-INF", "lib-python"))

    if "SETUP_WT_CLASSPATH" in os.environ:
        import wt_classpath
        wt_classpath.set_windchill_classpath(WT_HOME)


# vim: set ft=python ts=4 sw=4 expandtab :