示例#1
0
 def openPathForUser(self):
     selection = self.treevw.selection()
     if selection:
         folder = os.path.join(self.getScriptsDir(), selection[0])
     else:
         folder = self.getScriptsDir()
     Utils.openPathForUser(folder)
示例#2
0
 def downloadResultFile(self, _event=None):
     """Callback for tool click #TODO move to ToolController
     Download the tool result file and asks the user if he or she wants to open it. 
     If OK, tries to open it
     Args:
         _event: not used 
     """
     apiclient = APIClient.getInstance()
     dialog = ChildDialogInfo(self.appliViewFrame, "Download Started",
                              "Downloading...")
     dialog.show()
     abs_path = os.path.dirname(os.path.abspath(__file__))
     outputDir = os.path.join(abs_path, "../../results")
     path = self.controller.getOutputDir(apiclient.getCurrentPentest())
     path = apiclient.getResult(self.controller.getDbId(),
                                os.path.join(outputDir, path))
     dialog.destroy()
     if path is not None:
         if os.path.isfile(path):
             dialog = ChildDialogQuestion(
                 self.appliViewFrame,
                 "Download completed",
                 "The file has been downloaded.\n Would you like to open it?",
                 answers=["Open", "Cancel"])
             self.appliViewFrame.wait_window(dialog.app)
             if dialog.rvalue == "Open":
                 Utils.openPathForUser(path)
                 return
             else:
                 return
         path = None
     if path is None:
         tkinter.messagebox.showerror(
             "Download failed", "the file does not exist on sftp server")
示例#3
0
 def viewProof(self, _event, obj):
     """Callback when view proof is clicked.
     Download and display the file 
     Args
         _event: mandatory but not used
         obj: the clicked index proof
     """
     proof_local_path = self.controller.getProof(obj)
     if proof_local_path is not None:
         if os.path.isfile(proof_local_path):
             res = Utils.openPathForUser(proof_local_path)
             if not res:
                 tk.messagebox.showerror("Could not open",
                                         "Failed to open this file.")
                 proof_local_path = None
                 return
     if proof_local_path is None:
         tk.messagebox.showerror("Download failed",
                                 "the file does not exist on sftp server")