def __extend_classpath(class_paths): import platform if platform.python_implementation() == 'Jython': for class_path in class_paths: from classpath_updater import ClassPathUpdater cp_updater = ClassPathUpdater() cp_updater.add_file(class_path)
def __extend_classpath(jar_path): import java.io.File jar_file = java.io.File(jar_path) try: # extend class path with instrumentation import org.rf.ide.core.jvmutils.classpath.JarLoader org.rf.ide.core.jvmutils.classpath.JarLoader.addToClassPath(jar_file) except: # extend class path with reflection from classpath_updater import ClassPathUpdater cp_updater = ClassPathUpdater() cp_updater.add_url(jar_file.toURI().toURL())
def _extend_paths_from_dryrun_environment(): import sys import os import platform if ('RED_DRYRUN_PYTHONPATH' in os.environ): sys.path.extend(os.environ['RED_DRYRUN_PYTHONPATH'].split(';')) if ('RED_DRYRUN_CLASSPATH' in os.environ): sys.path.extend(os.environ['RED_DRYRUN_CLASSPATH'].split(';')) if 'Jython' in platform.python_implementation(): for class_path in os.environ['RED_DRYRUN_CLASSPATH'].split(';'): from classpath_updater import ClassPathUpdater cp_updater = ClassPathUpdater() cp_updater.add_file(class_path)
def test_if_jar_module_path_is_returned_for_python_module(self): import platform if 'Jython' in platform.python_implementation(): parent_path = os.path.dirname(os.path.realpath(__file__)) module_path = os.path.join(parent_path, 'res_test_red_modules', 'SamplePythonLib.jar') from classpath_updater import ClassPathUpdater cp_updater = ClassPathUpdater() cp_updater.add_file(module_path) result = get_module_path('ExamplePythonLibrary') from java.io import File self.assertEqual(File(result).getAbsolutePath(), File(module_path).getAbsolutePath())
elif sys.version_info < (3, 0, 0) and isinstance(arg, list): return [__decode_unicode_if_needed(elem) for elem in arg] else: return arg def _is_virtualenv(): return hasattr(sys, 'real_prefix') if __name__ == '__main__': port = sys.argv[1] data_source_path = sys.argv[2] project_location_path = sys.argv[3] recursiveInVirtualenv = sys.argv[4] excluded_paths = sys.argv[5].split(';') if len(sys.argv) > 5 else [] start_path = __decode_unicode_if_needed(project_location_path) recursive = not _is_virtualenv() or recursiveInVirtualenv excluded_paths = __decode_unicode_if_needed(excluded_paths) python_paths, class_paths = _collect_source_paths(start_path, recursive, excluded_paths) sys.path.extend(python_paths + class_paths) if 'Jython' in platform.python_implementation(): for class_path in class_paths: from classpath_updater import ClassPathUpdater cp_updater = ClassPathUpdater() cp_updater.add_file(class_path) start_auto_discovering(port, data_source_path)