[Fuego] [PATCH 1/8] Create mylong function as a compatible replacement for long()

[email protected] Wed, 20 Apr 2022 15:41:33 +0530
Newsgroups dev.linux.lists.fuego
Message-ID <[email protected]>
From: Shivanand Kunijadar <[email protected]>

Python3 removed the long() variable type and cast.
Define mylong() in try and except block which replaces mylong()
with long() in python2 and returns same passed value in python3.

Signed-off-by: Shivanand Kunijadar <[email protected]>
---
 scripts/deorphan-runs.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scripts/deorphan-runs.py b/scripts/deorphan-runs.py
index c81ed24..82dcacb 100755
--- a/scripts/deorphan-runs.py
+++ b/scripts/deorphan-runs.py
@@ -77,6 +77,14 @@ class data_class:
         else:
             return item
 
+# define mylong to work in python2 and 3
+try:
+    val = long(4)
+    mylong = long
+except:
+    def mylong(x):
+        return x
+
 def populate_build_data():
     # construct the build_data map to hold information about this build
     build_data = data_class()
@@ -88,7 +96,7 @@ def populate_build_data():
     test_name = os.path.basename(test_name)
     build_data.job_name = "%s.%s.%s" % (board_name, test.spec, test_name)
     build_data.workspace = conf.FUEGO_RW+"/buildzone"
-    build_data.start_time = long(time.time() * 1000)
+    build_data.start_time = mylong(time.time() * 1000)
     build_data.reboot_flag = test.reboot
     build_data.rebuild_flag = test.rebuild
     build_data.precleanup_flag = test.precleanup
-- 
2.20.1