From 229a19ac7cacfcc7b4ca0121ad361e27e66a5438 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 28 May 2024 18:20:16 +0200 Subject: [PATCH] Expose the .in_rlang() method --- python/r2pipe/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/python/r2pipe/__init__.py b/python/r2pipe/__init__.py index ba89b43..5a83651 100644 --- a/python/r2pipe/__init__.py +++ b/python/r2pipe/__init__.py @@ -33,13 +33,18 @@ VERSION = "1.8.8" -def inr2(): +def in_r2(): """Return wheter r2pipe is called from radare2 environment or the system shell """ - import os - a = int(os.environ["R2PIPE_IN"]), - b = int(os.environ["R2PIPE_OUT"]), - return a > 0 and b > 0 + try: + import os + a = int(os.environ["R2PIPE_IN"]), + b = int(os.environ["R2PIPE_OUT"]), + return a > 0 and b > 0 + except: + return False + +from r2pipe.open_base import in_rlang def version(): """Return string with the version of the r2pipe library