From 7aa5afaeb6ac078d233383663ec6f96e20420b43 Mon Sep 17 00:00:00 2001
From: rahulp13
Date: Tue, 22 Feb 2022 01:15:43 +0530
Subject: Prompt ToS if Sandpiper-SaaS directly invoked

---
 src/maker/Maker.py  | 61 ++++++++++++++++++++++-------------------------------
 src/maker/NgVeri.py | 11 ++++++++++
 2 files changed, 36 insertions(+), 36 deletions(-)

(limited to 'src')

diff --git a/src/maker/Maker.py b/src/maker/Maker.py
index 60087018..01095d91 100755
--- a/src/maker/Maker.py
+++ b/src/maker/Maker.py
@@ -50,9 +50,31 @@ home = expanduser("~")
 verilogFile = []
 toggle_flag = []
 
-# beginning class Maker. This class create the Maker Tab
+
+# This function is called to accept TOS of makerchip
+def makerchipTOSAccepted(display=True):
+    if not os.path.isfile(home + "/.makerchip_accepted"):
+        if display:
+            reply = QtWidgets.QMessageBox.warning(
+                None, "Terms of Service", "Please review the Makerchip \
+                       Terms of Service \
+                       (<a href='https://www.makerchip.com/terms/'>\
+                       https://www.makerchip.com/terms/</a>). \
+                       Have you read and do you \
+                       accept these Terms of Service?",
+                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
+            )
+
+            if reply == QtWidgets.QMessageBox.Yes:
+                f = open(home + "/.makerchip_accepted", "w")
+                f.close()
+                return True
+
+        return False
+    return True
 
 
+# beginning class Maker. This class create the Maker Tab
 class Maker(QtWidgets.QWidget):
 
     # initailising the varaibles
@@ -177,22 +199,9 @@ class Maker(QtWidgets.QWidget):
         if os.name == 'nt':
             init_path = ''  # noqa:F841
         try:
-            if not os.path.isfile(home + "/.makerchip_accepted"):
-                reply = QtWidgets.QMessageBox.warning(
-                    None, "Terms of Services", "Please review the makerchip\
-                         Terms of Service \
-                         (<a href='https://www.makerchip.com/terms/'>\
-                         https://www.makerchip.com/terms/</a> ).\
-                          Have you read and do you accept \
-                          these Terms of Service? [y/N]:",
-                    QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
-                )
+            if not makerchipTOSAccepted(True):
+                return
 
-                if reply == QtWidgets.QMessageBox.Yes:
-                    f = open(home + "/.makerchip_accepted", "w")
-                    f.close()
-                else:
-                    return
             print("Running Makerchip..............................")
             # self.file = open(self.verilogfile,"w")
             # self.file.write(self.entry_var[1].toPlainText())
@@ -372,27 +381,7 @@ Please check if Verilog File Chosen.")
         self.optionsbox.setLayout(self.optionsgrid)
         return self.optionsbox
 
-    # This function is called to accept TOS of makerchip
-
-    def makerchipaccepted(self):
-        reply = QtWidgets.QMessageBox.warning(
-            None, "Terms of Services", "Please review the makerchip\
-                         Terms of Service \
-                         (<a href='https://www.makerchip.com/terms/'>\
-                         https://www.makerchip.com/terms/</a> ).\
-                          Have you read and do you \
-                          accept these Terms of Service? [y/N]:",
-            QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
-        )
-
-        if reply == QtWidgets.QMessageBox.Yes:
-            f = open(home + "/.makerchip_accepted", "w")
-            f.close()
-        # else:
-        #    return
-
     # This function adds the other parts of widget like text box
-
     def creategroup(self):
 
         self.trbox = QtWidgets.QGroupBox()
diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py
index 496782f9..3a1cc845 100755
--- a/src/maker/NgVeri.py
+++ b/src/maker/NgVeri.py
@@ -104,6 +104,17 @@ class NgVeri(QtWidgets.QWidget):
         file = (os.path.basename(self.fname)).split('.')[0]
         if self.entry_var[1].findText(file) == -1:
             self.entry_var[1].addItem(file)
+
+        if not Maker.makerchipTOSAccepted(True):
+            QtWidgets.QMessageBox.warning(
+                None, "Warning Message",
+                "Please accept the Makerchip Terms of Service "
+                "to proceed further.",
+                QtWidgets.QMessageBox.Ok
+            )
+
+            return
+
         model.verilogfile()
         error = model.verilogParse()
         if error != "Error":
-- 
cgit