Ejemplo n.º 1
0
 def Move():
     p = Player1.get()
     self.main_data = p.split(" ")
     self.main_dict = dict.fromkeys(word_dict, 0)
     for word in self.main_data:
         check = self.main_dict.get(word)
         if check != None:
             self.main_dict[word] += 1
     self.array_distance = Find.Distance(word_dict, data_dict,
                                         self.main_dict)
     self.place = Find.Find_Min(self.array_distance)
     self.destroy()
     Result(self.parent, self.place, path_file)
Ejemplo n.º 2
0
def runScript():
    for x in arrayValue:
        x = x.replace("\n", "")
        print x
        sshOutput = SSH.connectToDevice(x, command)
        valueFound = Find.findString(findSomething, sshOutput)
        WriteOutput.appendOutput(valueFound, x, 'output.txt')
def runScript(findsomething):
    command = 'show system info\n'
    inputValue = text_entry.get("1.0", "end-1c")
    arrayValue = ReadFile.openFile("file.txt")
    inputArray = inputValue.splitlines()
    for x in inputArray:
        print x
        sshOutput = SSH.connectToDevice(x, command)
        valueFound = Find.findString(findsomething, sshOutput)
        WriteOutput.appendOutput(valueFound, x, 'output.txt')
        print "Output written to output.txt"
Ejemplo n.º 4
0
    def __init__(self, rho_l, u_l, p_l, rho_r, u_r, p_r, gamma):
        """Constructor of a Riemann Problem"""
        self.W_left = State("Left", gamma, rho_l, u_l, p_l)
        self.W_right = State("Right", gamma, rho_r, u_r, p_r)
        self.gamma = gamma
        self.P_star = Find.Find_P(self.W_left, self.W_right, gamma)
        self.U_star = Find.Find_U(self.W_left, self.W_right, self.P_star,
                                  gamma)

        if (self.P_star < self.W_right.pressure):
            #Rarefaction wave
            rho_star_r = self.W_right.rho * (
                self.P_star / self.W_right.pressure)**(1 / gamma)
            self.W_right_star = State("Right star", gamma, rho_star_r,
                                      self.U_star, self.P_star)
        else:
            #Shock wave
            rho_star_r = self.W_right.rho * (
                self.P_star / self.W_right.pressure + (gamma - 1) /
                (gamma + 1)) / (
                    (gamma - 1) /
                    (gamma + 1) * self.P_star / self.W_right.pressure + 1)
            self.W_right_star = State("Right star", gamma, rho_star_r,
                                      self.U_star, self.P_star)

        if (self.P_star < self.W_left.pressure):
            #Rarefaction wave
            rho_star_l = self.W_left.rho * (self.P_star /
                                            self.W_left.pressure)**(1 / gamma)
            self.W_left_star = State("Left star", gamma, rho_star_l,
                                     self.U_star, self.P_star)
        else:
            #Shock wave
            rho_star_l = self.W_left.rho * (
                self.P_star / self.W_left.pressure + (gamma - 1) /
                (gamma + 1)) / (
                    (gamma - 1) /
                    (gamma + 1) * self.P_star / self.W_left.pressure + 1)
            self.W_left_star = State("Left star", gamma, rho_star_l,
                                     self.U_star, self.P_star)
Ejemplo n.º 5
0
 def __findInFiles(self):
     findWin = Find(self, self.libMgr)
     findWin.findInFiles()
     findWin.exec_()
Ejemplo n.º 6
0
    def FindWidget(self, event=None):
        '''Display find GUI window when user clicks find option or presses Ctrl+F'''

        Find.Find(self.master, self.TextWidget)
Ejemplo n.º 7
0
    def determineCommand(self):
        # self.command_split[0] is the key word to determine what jarvis should do
        cmd_key = self.command_split[0].lower()

        if cmd_key == "quit":
            Dialogue.selfDestruct()
            sys.exit()

        elif cmd_key == "help":
            Dialogue.printHelpScreen(self.program_names)

        elif cmd_key == "rerun":
            self.setCommand(self.lastCommand)
            self.determineCommand()

        elif cmd_key == "find":
            flag = self.command_split[1]
            if flag == "-f":  # find a file
                print("Looking for files '{}'".format(
                    Find.prepareName(2, self.command_split)))
                Dialogue.fileResults(
                    Find.findFile(expanduser("~"),
                                  Find.prepareName(2, self.command_split)))
            elif flag == "-d":  # find a directory
                print("Looking for files '{}'".format(
                    Find.prepareName(2, self.command_split)))
                Dialogue.fileResults(
                    Find.findDirectory(expanduser("~"),
                                       Find.prepareName(2,
                                                        self.command_split)))
            else:
                Dialogue.printWithColor(
                    "Jarvis didn't recognize the flag for the 'find' command.",
                    'red')
                Dialogue.printWithColor(
                    "The syntax should look like $find -f|-d.. file_name'",
                    'red')
                Dialogue.printWithColor(
                    "For more information please type help", 'red')

        elif cmd_key == "open":
            try:
                subprocess.check_call(
                    ['open', Find.prepareName(1, self.command_split)])
            except RuntimeError as e:
                Dialogue.printWithColor(
                    "subprocess.check_call() ran into an error.", 'red')
                Dialogue.printWithColor(e, 'red')

        elif cmd_key == "google":
            webbrowser.open(Google.commandToURL(self.command_split))

        elif cmd_key == "close":
            name = Find.prepareName(1, self.command_split)
            display_results = []
            Dialogue.printWithColor(
                "Searching for processes that contain {}".format(name), 'cyan')
            for process in psutil.process_iter():
                process_pid = process.pid
                process_name = process.name()
                process_status = process.status()
                if name in process_name.lower():
                    display_results.append(
                        [process_pid, process_name, process_status])

            if len(display_results) > 1:
                Dialogue.printWithColor("Jarvis found multiple results",
                                        'cyan')
                for results in display_results:
                    Dialogue.printWithColor(
                        "PID: {}\t Name: {}\t Status: {}\t".format(
                            results[0], results[1], results[2]), 'yellow')
                response = input(
                    "Please enter the PID you would like to close: ")
                if response.lower() == "all":
                    for results in display_results:
                        try:
                            print("Jarvis is killing PID {}".format(
                                results[0]))
                            os.kill(results[0], signal.SIGKILL)
                        except ProcessLookupError as e:
                            print(
                                "Jarvis ran into a runtime error trying to kill {}"
                                .format(results))
                else:
                    for results in display_results:
                        if str(results[0]) == response:
                            try:
                                print("Jarvis is killing PID {}".format(
                                    results[0]))
                                os.kill(results[0], signal.SIGKILL)
                            except RuntimeError as e:
                                print(
                                    "Jarvis ran into a runtime error trying to kill {}"
                                    .format(results))
                            return

            elif len(display_results) == 1:
                try:
                    print("Jarvis is killing PID {}".format(
                        display_results[0]))
                    os.kill(display_results[0][0], signal.SIGKILL)
                except RuntimeError as e:
                    print("Jarvis ran into a runtime error trying to kill {}".
                          format(display_results[0]))
                return
            else:
                Dialogue.noResultsFound(name)

        else:
            print("Error command not found")
Ejemplo n.º 8
0
class SiftFlow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        #If we were opened from the base sift (not the gui) setup the app internaly
        if (parent == None):
            self.app = QtGui.QApplication(sys.argv)
            self.app.setOrganizationName("Hewlett-Packard")
            self.app.setOrganizationDomain("hp.com")
            self.app.setApplicationName("SiftFlow")

            if (sys.platform.startswith("darwin")):
                self.app.setStyle("Cleanlooks")

        #Setup the window
        QtGui.QMainWindow.__init__(self)
        self.parent = parent

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        #Declare interface object with backend
        self.libMgr = SFLibManager(self, self.ui)

        #Do additional Window setup
        self.__initMainWindow()

        #Only want one reference window at a time
        self.refWin = None
        self.aboutWin = None
        self.findWin = None
        self.repWin = None

        #Set up actions and signals
        QtCore.QObject.connect(self.ui.actionAbout,
                               QtCore.SIGNAL("triggered()"), self.__about)
        QtCore.QObject.connect(self.ui.actionFind,
                               QtCore.SIGNAL("triggered()"), self.__find)
        QtCore.QObject.connect(self.ui.actionFindInFiles,
                               QtCore.SIGNAL("triggered()"),
                               self.__findInFiles)
        QtCore.QObject.connect(self.ui.actionReference,
                               QtCore.SIGNAL("triggered()"), self.reference)
        QtCore.QObject.connect(self.ui.actionReferenceInFiles,
                               QtCore.SIGNAL("triggered()"),
                               self.referenceInFiles)
        QtCore.QObject.connect(self.ui.actionCut, QtCore.SIGNAL("triggered()"),
                               self.__cut)
        QtCore.QObject.connect(self.ui.actionCopy,
                               QtCore.SIGNAL("triggered()"), self.__copy)
        QtCore.QObject.connect(self.ui.actionUndo,
                               QtCore.SIGNAL("triggered()"), self.__undo)
        QtCore.QObject.connect(self.ui.actionRedo,
                               QtCore.SIGNAL("triggered()"), self.__redo)
        QtCore.QObject.connect(self.ui.actionGoto,
                               QtCore.SIGNAL("triggered()"), self.__goto)
        QtCore.QObject.connect(self.ui.actionIndent,
                               QtCore.SIGNAL("triggered()"), self.__indent)
        QtCore.QObject.connect(self.ui.actionUnindent,
                               QtCore.SIGNAL("triggered()"), self.__unindent)
        QtCore.QObject.connect(self.ui.actionComment,
                               QtCore.SIGNAL("triggered()"), self.__comment)
        QtCore.QObject.connect(self.ui.actionUncomment,
                               QtCore.SIGNAL("triggered()"), self.__uncomment)
        QtCore.QObject.connect(self.ui.actionPaste,
                               QtCore.SIGNAL("triggered()"), self.__paste)
        QtCore.QObject.connect(self.ui.actionDownload,
                               QtCore.SIGNAL("triggered()"), self.__download)

        QtCore.QObject.connect(self.ui.treeWidget_proj,
                               QtCore.SIGNAL("itemSelectionChanged()"),
                               self.__projSelectionChanged)
        QtCore.QObject.connect(self.ui.treeWidget_nonProj,
                               QtCore.SIGNAL("itemSelectionChanged()"),
                               self.__nonProjSelectionChanged)
        QtCore.QObject.connect(self.ui.splitter_leftright,
                               QtCore.SIGNAL("splitterMoved(int, int)"),
                               self.__resizeAll)

        #QtCore.QObject.connect(self.ui.actionNewFlow, QtCore.SIGNAL("triggered()"), self.__newFlow)
        QtCore.QObject.connect(self.ui.actionOpen,
                               QtCore.SIGNAL("triggered()"), self.__open)
        QtCore.QObject.connect(self.ui.actionSave,
                               QtCore.SIGNAL("triggered()"), self.__save)
        #QtCore.QObject.connect(self.ui.actionSave_All, QtCore.SIGNAL("triggered()"), self.__saveAll)
        QtCore.QObject.connect(self.ui.menuRecent,
                               QtCore.SIGNAL("aboutToShow()"),
                               self.__fillMenuRecent)
        QtCore.QObject.connect(self.ui.menuBuild,
                               QtCore.SIGNAL("aboutToShow()"),
                               self.__fillMenuBuild)

        #SiftFlow, show thyself!!
        if (parent == None): self.show()

    def run(self):
        """Run the main QT event loop"""
        self.app.exec_()

    #--- Child Windows ---#
    def __about(self):
        if (self.aboutWin == None or self.aboutWin.isHidden()):
            self.aboutWin = About(self, self.libMgr)
            self.aboutWin.exec_()

    def __find(self):
        if (self.findWin == None or self.findWin.isHidden()):
            self.findWin = Find(self, self.libMgr)
            self.findWin.show()

    def reference(self, text='none', flags=None, isCurrent=True):
        if (self.refWin == None or not self.refWin.isVisible()):
            self.refWin = Reference(self, self.libMgr)
            result = self.refWin.addSearch(text, flags, isCurrent)
            if (isinstance(result, str) and result == 'noselection'):
                QtGui.QMessageBox.about(self, "Selection Status",
                                        "There is no text selected.")
            elif (result):
                self.refWin.show()
            else:
                QtGui.QMessageBox.about(self, "Match Status",
                                        "There are no more matches.")
        elif (self.refWin.isVisible()):  #the window is open, reset
            if (not self.refWin.addSearch(text, flags, isCurrent)):
                QtGui.QMessageBox.about(self, "Match Status",
                                        "There are no more matches.")

    def referenceInFiles(self):
        self.reference(isCurrent='all')

    #--- Signal Handlers ---#
    def __projSelectionChanged(self):
        self.libMgr.tvProjUpdate()

    def __nonProjSelectionChanged(self):
        self.libMgr.tvNonProjUpdate()

    def __cut(self):
        self.libMgr.cut()

    def __copy(self):
        self.libMgr.copy()

    def __paste(self):
        self.libMgr.paste()

    def __findInFiles(self):
        findWin = Find(self, self.libMgr)
        findWin.findInFiles()
        findWin.exec_()

    def __undo(self):
        self.libMgr.undo()

    def __redo(self):
        self.libMgr.redo()

    def __goto(self):
        lineNum, ok = QtGui.QInputDialog.getText(self, 'Go to..',
                                                 'Go To Line: ')
        if ok:
            self.libMgr.setCursorToReference(int(lineNum) - 1, 0)

    def __indent(self):
        self.libMgr.indent()

    def __unindent(self):
        self.libMgr.unindent()

    def __comment(self):
        self.libMgr.comment()

    def __uncomment(self):
        self.libMgr.uncomment()

    def __newFlow(self):
        print 'new flow'

    def __save(self):
        result = self.libMgr.saveCurrentTab()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        if (self.refWin and self.refWin.isVisible()):  #the window is open
            self.refWin.resetTabs()

    #def __saveAll(self):
    #For now I am removing save all from the ui, but will leave the functionality in.
    #Save All would rarely be used and caused a few hard to solve cunundrums with file conflicts
    #when a user had unsaved changes in both fmls and flows from those fmls. If in the future, this
    #feature is demanded, then all that needs to be done is to reattach the action to the toolbar and
    #uncomment this function, the signal and file menu entry near the bottom of this file

    #result = self.libMgr.saveAllTabs()

    #Reset the reference window if it is open, to reflect any changes in the files after saving
    #if(self.refWin and self.refWin.isVisible()): #the window is open
    #self.refWin.resetTabs()

    def __download(self):
        #Cannot download if there is no project loaded
        if (not self.libMgr.isProjLoaded()):
            self.libMgr.printError("Download failed!", 10)
            QtGui.QMessageBox.about(self, "Download Failed",
                                    "No Project Loaded.")
            return

        #Get a list of all files changed since .all was build
        dList = self.libMgr.getDownloadFileList()

        #If files have changed since the .all was built, download them to printer
        if (len(dList) > 0):
            #Turn that list into the command string
            cmd = "download " + " ".join(dList)

            #Send command to sift
            self.parent.parse(cmd)

        #If no files have changed, tell user and do nothing
        else:
            self.libMgr.out("No changed files to download", 6)

    #--- Event Handlers ---#
    def showEvent(self, se):
        self.__resizeAll(0, 0)

    def __resizeAll(self, index, pos):
        self.libMgr.resizeTreeview()

    def closeEvent(self, e):
        #If there are any unsaved changes, ask user what they want to do
        if (self.libMgr.anyUnsavedChanges()):
            msg = "There are unsaved changes. Quitting will discharges these changes."

            reply = QtGui.QMessageBox.question(self, "Warning", msg,
                                               QtGui.QMessageBox.Save,
                                               QtGui.QMessageBox.Discard,
                                               QtGui.QMessageBox.Cancel)

            if reply == QtGui.QMessageBox.Save:
                self.libMgr.saveAnyUnsavedChanges()
            elif reply == QtGui.QMessageBox.Cancel:
                e.ignore()
                return

        #Save window size, treeview width, output box height
        self.libMgr.saveWindowState(
            self.width(), self.height(),
            self.ui.splitter_leftright.widget(0).width())

        #Close any open dialogs
        if (self.aboutWin != None and not self.aboutWin.isHidden()):
            self.aboutWin.close()
        if (self.findWin != None and not self.findWin.isHidden()):
            self.findWin.close()
        if (self.repWin != None and not self.repWin.isHidden()):
            self.repWin.close()
        if (self.refWin != None and not self.refWin.isHidden()):
            self.refWin.close()

        if (self.parent != None):
            self.parent.ui.edit.setEnabled(True)

    #--- Opening Files ---#
    # Signal handler for open file action
    def __open(self):
        #Get the last dir opened by the user (from config file)
        lastDir = self.libMgr.getLastOpenDir()

        #Use file dialog to allow user to select one or more .fmls
        ofDialog = QtGui.QFileDialog(self)
        files = ofDialog.getOpenFileNames(caption='Open file(s)',
                                          directory=lastDir,
                                          filter='Files (*.fml *.lua)')

        #Only load files if the user select any
        if not files.isEmpty():
            #Place the chosen directory in the config file
            self.libMgr.setLastOpenDir(os.path.split(str(files[0]))[0])

            #Load the files
            self.loadFiles(files)

    #Loads a project file provided by sift
    def loadProject(self, fileDirs, projPath, projName, projType):
        #If not in linux or project_dir is not pointed to a build directory (ie bound to repo) or file_dirs is empty
        #Use the project_dir as the file_dirs since the project files will be with the .hlg
        if (not sys.platform.startswith('linux')
                or not re.search("obj_\w+_\w+", projPath)
                or len(fileDirs) == 0):
            fileDirs = projPath

        try:
            self.libMgr.loadProject(fileDirs, projPath, projName, projType)
        except:
            print "SiftFlow Load Error: "
            print "file_dirs: " + str(fileDirs)
            print "project_dir: " + str(projPath)
            print "project_name: " + str(projName)
            print "project_type: " + str(projType)
            print "".join(
                traceback.format_exception(sys.exc_info()[0],
                                           sys.exc_info()[1],
                                           sys.exc_info()[2]))
            return

        #Add the .all name and the repo name (None if not in repo) to the window title
        self.setWindowTitle('SiftFlow (' + (projName or "None") + ') (Repo: ' +
                            self.libMgr.getRepo() + ')')

    #Loads files not associated with a project file
    def loadFiles(self, args):
        #If no loaded project, set window title
        if (self.libMgr.getLoadedProjName() == ''):
            self.setWindowTitle('SiftFlow (No Project)')

        fileList = []
        #Load files the user has specified from command line args rather than a project from sift
        if (len(args) == 0):
            #If no args were given, check cwd for any .fmls and open them
            cwd = os.getcwd()
            for infile in glob.glob(os.path.join(cwd, '*.fml')):
                fileList.append(infile)

        elif (len(args) > 0):
            #Loop through the args and open files if they exist
            for x in range(len(args)):
                arg = str(args[x])
                if ((arg.endswith('.fml') or arg.endswith('.lua'))
                        and os.path.exists(arg)):
                    fileList.append(arg)
                else:
                    print arg + ' is not an fml or does not exist'

        #If there are files, open them
        if (len(fileList) > 0):
            try:
                self.libMgr.loadFiles(fileList)
            except:
                print "SiftFlow Load Error: "
                print "file list: " + str(fileList)
                print "".join(
                    traceback.format_exception(sys.exc_info()[0],
                                               sys.exc_info()[1],
                                               sys.exc_info()[2]))
                return

    def displayFlowFromSift(self, funcName, projName):
        #Use project name to get the correct filename for the function
        fileName = self.libMgr.getFileNameFromFuncName(projName, funcName)

        if not fileName:
            print "There was an error displaying the flow."
            return

        self.libMgr.displayFlow(fileName, projName, funcName)

    def __displayFromRecent(self, todisplay):
        fileName = todisplay[0]
        path = todisplay[1]
        proj = todisplay[2]
        funcName = todisplay[3]
        dIndex = todisplay[4]

        #If file is not in the loaded file list, add it
        if (not self.libMgr.isFileLoaded(fileName, path)):
            self.libMgr.loadFiles([os.path.join(path, fileName)])

        #Set up pathOrProj
        if (self.libMgr.isProjLoaded(proj)):
            pathOrProj = proj
        else:
            pathOrProj = path

        #Display the thing
        if (not funcName):
            self.libMgr.displayFml(fileName, pathOrProj)
        else:
            self.libMgr.displayFlow(fileName,
                                    pathOrProj,
                                    funcName,
                                    dIndex=dIndex)

    #--- Setup Functions ---#
    def __initMainWindow(self):
        #Set Main Window starting size
        self.resize(self.libMgr.getWindowSize())

        #Treeview (navigation) Tab Control Init
        self.ui.tabWidget_treeview.setCurrentIndex(0)

        #Set all layout margins to zero
        self.ui.gridLayout.setMargin(0)
        self.ui.gridLayout_2.setMargin(0)
        self.ui.gridLayout_3.setMargin(0)
        self.ui.gridLayout_4.setMargin(0)
        self.ui.gridLayout_5.setMargin(0)

        #Set stretch factors so the resize widgets know what ratio each side can be
        self.ui.splitter_leftright.setStretchFactor(1, 2)

        #Set Left frame contents sizes
        self.ui.splitter_leftright.widget(0).setMinimumWidth(125)
        self.ui.splitter_leftright.setSizes([
            self.libMgr.getTreeviewWidth(),
            self.ui.splitter_leftright.widget(1).width()
        ])

        #setup main icon
        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "SiftTeal.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #setup find icon
        iconF = QtGui.QIcon()
        iconF.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "find.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionFind.setIcon(iconF)

        #setup reference icon
        iconRef = QtGui.QIcon()
        iconRef.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "findreference.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReference.setIcon(iconRef)

        #setup reference icon
        iconRefInFiles = QtGui.QIcon()
        iconRefInFiles.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(),
                             "findreferenceinfiles.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionReferenceInFiles.setIcon(iconRefInFiles)

        #setup undo icon
        iconU = QtGui.QIcon()
        iconU.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "undo.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUndo.setIcon(iconU)

        #setup redo icon
        iconRed = QtGui.QIcon()
        iconRed.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "redo.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionRedo.setIcon(iconRed)

        #setup comment icon
        iconCom = QtGui.QIcon()
        iconCom.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "comment.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionComment.setIcon(iconCom)

        #setup uncomment icon
        iconUncom = QtGui.QIcon()
        iconUncom.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "uncomment.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUncomment.setIcon(iconUncom)

        #setup indent icon
        iconIn = QtGui.QIcon()
        iconIn.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "indent.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionIndent.setIcon(iconIn)

        #setup unindent icon
        iconUnin = QtGui.QIcon()
        iconUnin.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "unindent.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUnindent.setIcon(iconUnin)

        #setup goto icon
        iconGoto = QtGui.QIcon()
        iconGoto.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "goto.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionGoto.setIcon(iconGoto)

        #setup open icon
        iconO = QtGui.QIcon()
        iconO.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "open.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionOpen.setIcon(iconO)

        #setup save icon
        iconSave = QtGui.QIcon()
        iconSave.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "save.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave.setIcon(iconSave)

        #setup saveall icon
        iconSaveAll = QtGui.QIcon()
        iconSaveAll.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "saveall.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionSave_All.setIcon(iconSaveAll)

        #setup download icon
        iconDownload = QtGui.QIcon()
        iconDownload.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "download.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionDownload.setIcon(iconDownload)

        #Create File menu
        #self.ui.menuNew = QtGui.QMenu('New')
        #self.ui.actionNewFlow = QtGui.QAction(self.ui.menuNew)
        #self.ui.actionNewFlow.setObjectName('actionNewFlow')
        #self.ui.actionNewFlow.setText('Flow')
        #self.ui.menuNew.addAction(self.ui.actionNewFlow)
        #self.ui.menuFile.addMenu(self.ui.menuNew)

        #self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionOpen)
        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionSave)
        #self.ui.menuFile.addAction(self.ui.actionSave_All)
        self.ui.menuFile.addSeparator()

        #build recent menu
        self.ui.menuRecent = QtGui.QMenu(self.ui.menuFile)
        self.ui.menuRecent.setTitle('Recent')
        self.ui.menuFile.addMenu(self.ui.menuRecent)

        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionExit)

        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)

    def __fillMenuRecent(self):
        list = self.libMgr.getRecentList()
        self.ui.menuRecent.clear()

        for item in reversed(list):
            action = QtGui.QAction(self.ui.menuRecent)

            #Display the flow name, or .fml if that all there is, tack on dIndex if there
            dIndex = ''
            if item[4]:
                dIndex = '(' + str(item[4]) + ')'

            action.setText((item[3] or item[0]) + dIndex)

            #Pass in path:flow to the display function when the action is clicked for easy displaying
            receiver = lambda todisplay=item: self.__displayFromRecent(
                todisplay)
            action.connect(action, QtCore.SIGNAL("triggered()"), receiver)
            self.ui.menuRecent.addAction(action)

    def __fillMenuBuild(self):
        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)
Ejemplo n.º 9
0
 def __findInFiles(self):
     findWin = Find(self, self.libMgr)
     findWin.findInFiles()
     findWin.exec_()
Ejemplo n.º 10
0
 def __find(self):
     if (self.findWin == None or self.findWin.isHidden()):
         self.findWin = Find(self, self.libMgr)
         self.findWin.show()
Ejemplo n.º 11
0
def init():
    Find.findChannel(0)
Ejemplo n.º 12
0
class SiftFlow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        #If we were opened from the base sift (not the gui) setup the app internaly
        if (parent == None):
            self.app = QtGui.QApplication(sys.argv)
            self.app.setOrganizationName("Hewlett-Packard")
            self.app.setOrganizationDomain("hp.com")
            self.app.setApplicationName("SiftFlow")
    
            if (sys.platform.startswith("darwin")):
                self.app.setStyle("Cleanlooks")

        #Setup the window
        QtGui.QMainWindow.__init__(self)
        self.parent = parent

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        #Declare interface object with backend
        self.libMgr = SFLibManager(self, self.ui)

        #Do additional Window setup
        self.__initMainWindow()

        #Only want one reference window at a time
        self.refWin = None
        self.aboutWin = None
        self.findWin = None
        self.repWin = None

        #Set up actions and signals
        QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL("triggered()"), self.__about)
        QtCore.QObject.connect(self.ui.actionFind, QtCore.SIGNAL("triggered()"), self.__find)
        QtCore.QObject.connect(self.ui.actionFindInFiles, QtCore.SIGNAL("triggered()"), self.__findInFiles)
        QtCore.QObject.connect(self.ui.actionReference, QtCore.SIGNAL("triggered()"), self.reference)
        QtCore.QObject.connect(self.ui.actionReferenceInFiles, QtCore.SIGNAL("triggered()"), self.referenceInFiles)
        QtCore.QObject.connect(self.ui.actionCut, QtCore.SIGNAL("triggered()"), self.__cut)
        QtCore.QObject.connect(self.ui.actionCopy, QtCore.SIGNAL("triggered()"), self.__copy)
        QtCore.QObject.connect(self.ui.actionUndo, QtCore.SIGNAL("triggered()"), self.__undo)
        QtCore.QObject.connect(self.ui.actionRedo, QtCore.SIGNAL("triggered()"), self.__redo)
        QtCore.QObject.connect(self.ui.actionGoto, QtCore.SIGNAL("triggered()"), self.__goto)
        QtCore.QObject.connect(self.ui.actionIndent, QtCore.SIGNAL("triggered()"), self.__indent)
        QtCore.QObject.connect(self.ui.actionUnindent, QtCore.SIGNAL("triggered()"), self.__unindent)
        QtCore.QObject.connect(self.ui.actionComment, QtCore.SIGNAL("triggered()"), self.__comment)
        QtCore.QObject.connect(self.ui.actionUncomment, QtCore.SIGNAL("triggered()"), self.__uncomment)
        QtCore.QObject.connect(self.ui.actionPaste, QtCore.SIGNAL("triggered()"), self.__paste)
        QtCore.QObject.connect(self.ui.actionDownload, QtCore.SIGNAL("triggered()"), self.__download)

        QtCore.QObject.connect(self.ui.treeWidget_proj, QtCore.SIGNAL("itemSelectionChanged()"), self.__projSelectionChanged)
        QtCore.QObject.connect(self.ui.treeWidget_nonProj, QtCore.SIGNAL("itemSelectionChanged()"), self.__nonProjSelectionChanged)
        QtCore.QObject.connect(self.ui.splitter_leftright, QtCore.SIGNAL("splitterMoved(int, int)"), self.__resizeAll)

        #QtCore.QObject.connect(self.ui.actionNewFlow, QtCore.SIGNAL("triggered()"), self.__newFlow)
        QtCore.QObject.connect(self.ui.actionOpen, QtCore.SIGNAL("triggered()"), self.__open)
        QtCore.QObject.connect(self.ui.actionSave, QtCore.SIGNAL("triggered()"), self.__save)
        #QtCore.QObject.connect(self.ui.actionSave_All, QtCore.SIGNAL("triggered()"), self.__saveAll)
        QtCore.QObject.connect(self.ui.menuRecent, QtCore.SIGNAL("aboutToShow()"), self.__fillMenuRecent)
        QtCore.QObject.connect(self.ui.menuBuild, QtCore.SIGNAL("aboutToShow()"), self.__fillMenuBuild)

        #SiftFlow, show thyself!!
        if(parent == None): self.show()

    def run(self):
        """Run the main QT event loop"""
        self.app.exec_()

    #--- Child Windows ---#
    def __about(self):
        if(self.aboutWin == None or self.aboutWin.isHidden()):
            self.aboutWin = About(self, self.libMgr)
            self.aboutWin.exec_()

    def __find(self):
        if(self.findWin == None or self.findWin.isHidden()):
            self.findWin = Find(self, self.libMgr)
            self.findWin.show()

    def reference(self, text='none', flags=None, isCurrent=True):
        if(self.refWin == None or not self.refWin.isVisible()):
            self.refWin = Reference(self, self.libMgr)
            result = self.refWin.addSearch(text, flags, isCurrent)
            if(isinstance(result, str) and result == 'noselection'):
                QtGui.QMessageBox.about(self, "Selection Status", "There is no text selected.")
            elif(result):
                self.refWin.show()
            else:
                QtGui.QMessageBox.about(self, "Match Status", "There are no more matches.")
        elif(self.refWin.isVisible()): #the window is open, reset
            if(not self.refWin.addSearch(text, flags, isCurrent)):
                QtGui.QMessageBox.about(self, "Match Status", "There are no more matches.")

    def referenceInFiles(self):
        self.reference(isCurrent='all')

    #--- Signal Handlers ---#
    def __projSelectionChanged(self):
        self.libMgr.tvProjUpdate()

    def __nonProjSelectionChanged(self):
        self.libMgr.tvNonProjUpdate()

    def __cut(self):
        self.libMgr.cut()

    def __copy(self):
        self.libMgr.copy()

    def __paste(self):
        self.libMgr.paste()

    def __findInFiles(self):
        findWin = Find(self, self.libMgr)
        findWin.findInFiles()
        findWin.exec_()

    def __undo(self):
        self.libMgr.undo()

    def __redo(self):
        self.libMgr.redo()

    def __goto(self):
        lineNum, ok = QtGui.QInputDialog.getText(self, 'Go to..', 'Go To Line: ')
        if ok:
            self.libMgr.setCursorToReference(int(lineNum) - 1, 0)

    def __indent(self):
        self.libMgr.indent()

    def __unindent(self):
        self.libMgr.unindent()

    def __comment(self):
        self.libMgr.comment()

    def __uncomment(self):
        self.libMgr.uncomment()

    def __newFlow(self):
        print 'new flow'

    def __save(self):
        result = self.libMgr.saveCurrentTab()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        if(self.refWin and self.refWin.isVisible()): #the window is open
            self.refWin.resetTabs()

    #def __saveAll(self):
        #For now I am removing save all from the ui, but will leave the functionality in.
        #Save All would rarely be used and caused a few hard to solve cunundrums with file conflicts
        #when a user had unsaved changes in both fmls and flows from those fmls. If in the future, this 
        #feature is demanded, then all that needs to be done is to reattach the action to the toolbar and
        #uncomment this function, the signal and file menu entry near the bottom of this file
        
        #result = self.libMgr.saveAllTabs()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        #if(self.refWin and self.refWin.isVisible()): #the window is open
            #self.refWin.resetTabs()

    def __download(self):
        #Cannot download if there is no project loaded
        if(not self.libMgr.isProjLoaded()):
            self.libMgr.printError("Download failed!", 10)
            QtGui.QMessageBox.about(self, "Download Failed", "No Project Loaded.")
            return

        #Get a list of all files changed since .all was build
        dList = self.libMgr.getDownloadFileList()

        #If files have changed since the .all was built, download them to printer
        if(len(dList) > 0):
            #Turn that list into the command string
            cmd = "download " + " ".join(dList)

            #Send command to sift
            self.parent.parse(cmd)

        #If no files have changed, tell user and do nothing
        else:
            self.libMgr.out("No changed files to download", 6)

    #--- Event Handlers ---#
    def showEvent(self, se):
        self.__resizeAll(0, 0)

    def __resizeAll(self, index, pos):
        self.libMgr.resizeTreeview()

    def closeEvent(self, e):
        #If there are any unsaved changes, ask user what they want to do
        if(self.libMgr.anyUnsavedChanges()):
            msg = "There are unsaved changes. Quitting will discharges these changes."

            reply = QtGui.QMessageBox.question(self, "Warning", msg, QtGui.QMessageBox.Save, 
                                                QtGui.QMessageBox.Discard, QtGui.QMessageBox.Cancel)
    
            if reply == QtGui.QMessageBox.Save:
                self.libMgr.saveAnyUnsavedChanges()
            elif reply == QtGui.QMessageBox.Cancel:
                e.ignore()
                return

        #Save window size, treeview width, output box height
        self.libMgr.saveWindowState(self.width(), self.height(), 
                                    self.ui.splitter_leftright.widget(0).width())

        #Close any open dialogs
        if(self.aboutWin != None and not self.aboutWin.isHidden()):
            self.aboutWin.close()
        if(self.findWin != None and not self.findWin.isHidden()):
            self.findWin.close()
        if(self.repWin != None and not self.repWin.isHidden()):
            self.repWin.close()
        if(self.refWin != None and not self.refWin.isHidden()):
            self.refWin.close()

        if (self.parent != None):
            self.parent.ui.edit.setEnabled(True)

    #--- Opening Files ---#
    # Signal handler for open file action
    def __open(self):
        #Get the last dir opened by the user (from config file)
        lastDir = self.libMgr.getLastOpenDir()
        
        #Use file dialog to allow user to select one or more .fmls
        ofDialog = QtGui.QFileDialog(self)
        files = ofDialog.getOpenFileNames(caption='Open file(s)', 
                                          directory=lastDir, 
                                          filter='Files (*.fml *.lua)')

        #Only load files if the user select any
        if not files.isEmpty():
            #Place the chosen directory in the config file
            self.libMgr.setLastOpenDir(os.path.split(str(files[0]))[0])

            #Load the files
            self.loadFiles(files)

    #Loads a project file provided by sift
    def loadProject(self, fileDirs, projPath, projName, projType):
        #If not in linux or project_dir is not pointed to a build directory (ie bound to repo) or file_dirs is empty
        #Use the project_dir as the file_dirs since the project files will be with the .hlg
        if(not sys.platform.startswith('linux') or 
           not re.search("obj_\w+_\w+", projPath) or
           len(fileDirs) == 0):
            fileDirs = projPath

        try:
            self.libMgr.loadProject(fileDirs, projPath, projName, projType)
        except:
            print "SiftFlow Load Error: "
            print "file_dirs: " + str(fileDirs)
            print "project_dir: " + str(projPath)
            print "project_name: " + str(projName)
            print "project_type: " + str(projType)
            print "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
            return

        #Add the .all name and the repo name (None if not in repo) to the window title
        self.setWindowTitle('SiftFlow (' + (projName or "None") + ') (Repo: ' + self.libMgr.getRepo() + ')')

    #Loads files not associated with a project file
    def loadFiles(self, args):
        #If no loaded project, set window title
        if(self.libMgr.getLoadedProjName() == ''):
            self.setWindowTitle('SiftFlow (No Project)') 

        fileList = []
        #Load files the user has specified from command line args rather than a project from sift
        if(len(args) == 0):
            #If no args were given, check cwd for any .fmls and open them
            cwd = os.getcwd()
            for infile in glob.glob(os.path.join(cwd, '*.fml')):
                fileList.append(infile)

        elif(len(args) > 0):
            #Loop through the args and open files if they exist
            for x in range(len(args)):
                arg = str(args[x]) 
                if ((arg.endswith('.fml') or arg.endswith('.lua')) and 
                     os.path.exists(arg)):
                    fileList.append(arg)
                else:
                    print arg + ' is not an fml or does not exist'

        #If there are files, open them
        if(len(fileList) > 0):
            try:
                self.libMgr.loadFiles(fileList)
            except:
                print "SiftFlow Load Error: "
                print "file list: " + str(fileList)
                print "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
                return

    def displayFlowFromSift(self, funcName, projName):
        #Use project name to get the correct filename for the function
        fileName = self.libMgr.getFileNameFromFuncName(projName, funcName)

        if not fileName:
            print "There was an error displaying the flow."
            return

        self.libMgr.displayFlow(fileName, projName, funcName)

    def __displayFromRecent(self, todisplay):
        fileName = todisplay[0] 
        path = todisplay[1]
        proj = todisplay[2]
        funcName = todisplay[3]
        dIndex = todisplay[4]

        #If file is not in the loaded file list, add it
        if(not self.libMgr.isFileLoaded(fileName, path)):
            self.libMgr.loadFiles([os.path.join(path,fileName)])

        #Set up pathOrProj
        if(self.libMgr.isProjLoaded(proj)):
            pathOrProj = proj
        else:
            pathOrProj = path

        #Display the thing
        if(not funcName):
            self.libMgr.displayFml(fileName, pathOrProj)
        else:
            self.libMgr.displayFlow(fileName, pathOrProj, funcName, dIndex=dIndex)

    #--- Setup Functions ---#
    def __initMainWindow(self):
        #Set Main Window starting size
        self.resize(self.libMgr.getWindowSize())

        #Treeview (navigation) Tab Control Init
        self.ui.tabWidget_treeview.setCurrentIndex(0)

        #Set all layout margins to zero
        self.ui.gridLayout.setMargin(0)
        self.ui.gridLayout_2.setMargin(0)
        self.ui.gridLayout_3.setMargin(0)
        self.ui.gridLayout_4.setMargin(0)
        self.ui.gridLayout_5.setMargin(0)

        #Set stretch factors so the resize widgets know what ratio each side can be
        self.ui.splitter_leftright.setStretchFactor(1, 2)

        #Set Left frame contents sizes
        self.ui.splitter_leftright.widget(0).setMinimumWidth(125)
        self.ui.splitter_leftright.setSizes([self.libMgr.getTreeviewWidth(), self.ui.splitter_leftright.widget(1).width()])

        #setup main icon
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "SiftTeal.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #setup find icon
        iconF = QtGui.QIcon()
        iconF.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "find.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionFind.setIcon(iconF)

        #setup reference icon
        iconRef = QtGui.QIcon()
        iconRef.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "findreference.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReference.setIcon(iconRef)

        #setup reference icon
        iconRefInFiles = QtGui.QIcon()
        iconRefInFiles.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "findreferenceinfiles.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReferenceInFiles.setIcon(iconRefInFiles)

        #setup undo icon
        iconU = QtGui.QIcon()
        iconU.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "undo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUndo.setIcon(iconU)

        #setup redo icon
        iconRed = QtGui.QIcon()
        iconRed.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "redo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionRedo.setIcon(iconRed)

        #setup comment icon
        iconCom = QtGui.QIcon()
        iconCom.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "comment.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionComment.setIcon(iconCom)

        #setup uncomment icon
        iconUncom = QtGui.QIcon()
        iconUncom.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "uncomment.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUncomment.setIcon(iconUncom)

        #setup indent icon
        iconIn = QtGui.QIcon()
        iconIn.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "indent.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionIndent.setIcon(iconIn)

        #setup unindent icon
        iconUnin = QtGui.QIcon()
        iconUnin.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "unindent.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUnindent.setIcon(iconUnin)

        #setup goto icon
        iconGoto = QtGui.QIcon()
        iconGoto.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "goto.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionGoto.setIcon(iconGoto)

        #setup open icon
        iconO = QtGui.QIcon()
        iconO.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionOpen.setIcon(iconO)

        #setup save icon
        iconSave = QtGui.QIcon()
        iconSave.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "save.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave.setIcon(iconSave)

        #setup saveall icon
        iconSaveAll = QtGui.QIcon()
        iconSaveAll.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "saveall.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave_All.setIcon(iconSaveAll)

        #setup download icon
        iconDownload = QtGui.QIcon()
        iconDownload.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "download.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionDownload.setIcon(iconDownload)

        #Create File menu
        #self.ui.menuNew = QtGui.QMenu('New')
        #self.ui.actionNewFlow = QtGui.QAction(self.ui.menuNew)
        #self.ui.actionNewFlow.setObjectName('actionNewFlow')
        #self.ui.actionNewFlow.setText('Flow')
        #self.ui.menuNew.addAction(self.ui.actionNewFlow)
        #self.ui.menuFile.addMenu(self.ui.menuNew)

        #self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionOpen)
        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionSave)
        #self.ui.menuFile.addAction(self.ui.actionSave_All) 
        self.ui.menuFile.addSeparator()

        #build recent menu
        self.ui.menuRecent = QtGui.QMenu(self.ui.menuFile)
        self.ui.menuRecent.setTitle('Recent')
        self.ui.menuFile.addMenu(self.ui.menuRecent)

        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionExit)

        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)

    def __fillMenuRecent(self):
        list = self.libMgr.getRecentList()
        self.ui.menuRecent.clear()

        for item in reversed(list):
            action = QtGui.QAction(self.ui.menuRecent)

            #Display the flow name, or .fml if that all there is, tack on dIndex if there
            dIndex = ''
            if item[4]:
                dIndex = '(' + str(item[4]) + ')'

            action.setText((item[3] or item[0]) + dIndex)

            #Pass in path:flow to the display function when the action is clicked for easy displaying
            receiver = lambda todisplay=item: self.__displayFromRecent(todisplay)
            action.connect(action, QtCore.SIGNAL("triggered()"), receiver)
            self.ui.menuRecent.addAction(action)

    def __fillMenuBuild(self):
        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)
Ejemplo n.º 13
0
 def __find(self):
     if(self.findWin == None or self.findWin.isHidden()):
         self.findWin = Find(self, self.libMgr)
         self.findWin.show()
Ejemplo n.º 14
0
import argparse
from Find import *
def parseArgs():
	parser = argparse.ArgumentParser(
		description='A Python script that searches directories/filenames for a given pattern and prints out the filepath. Recursively goes through all directories from starting location.'
	)
	parser.add_argument(
		'search',
		type=str,
		help='Pattern to search for in filenames/directories.',
		default=None
	)
	parser.add_argument(
		'directory',
		nargs='?',
		help='Directory to search. Uses current directory by default.',
		default='.'
	)

	return vars(parser.parse_args())

if __name__ == '__main__':
	commandLineArgs = parseArgs()
	find = Find(commandLineArgs['search'], commandLineArgs['directory'])	
	find.find(find.getFilepath())
Ejemplo n.º 15
0
        Player1.pack()
        Player1.place(x=POSX, y=POSY)
        button = tk.Button(self,
                           relief=GROOVE,
                           text='Find',
                           width=7,
                           height=3,
                           command=Move)
        button.pack()
        button.place(x=POSX + 720, y=POSY - 5)


# Delete screen and move to MENU
class GUI(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("Search Engine")
        self.board = Screen(parent)
        self.pack()


data, word_dict, path_file = Find.Load_Data()
data_dict = Find.Save_Value(data, word_dict)
data_dict, sum_word = Find.Calculate(data_dict, word_dict)
root = Tk()
text = tk.Text(root)
root.geometry(("%dx%d+0+0") % (WIDTH, HEIGHT))
ex = GUI(root)
root.mainloop()
Ejemplo n.º 16
0
#By calling other methods this app will ssh into a Palo Alto Firewall(May work on other boxes) run a command and pull information from the command that was run
#@author Jordan Packham [email protected]
#version .082 (This is the current version)
#Since    .000001 (Version number that this method was added to the PaloAltoParamikoLogin class)
#@param arrayValue will read and store the contents of file.txt
#@param findSomething will be used to search for this string in some of the received input from other methods
#@param command this value will be sent to sshOutput and is a command that will be sent to the device that sshOutput logs into.
#@param valueFound This is the information we received from the method findString we will output this to the file output.txt


import SSH
import paramiko
import time
import ReadFile
import Find
import WriteOutput

arrayValue = ReadFile.openFile("file.txt")
findSomething = 'serial'
command = 'show system info\n'
#print arrayValue

for x in arrayValue:
			x = x.replace("\n","")
			print x
			sshOutput = SSH.connectToDevice(x, command)
			valueFound = Find.findString(findSomething, sshOutput)
			WriteOutput.appendOutput(valueFound, x, 'output.txt')
			
			
Ejemplo n.º 17
0
 def find(self, event=None):
     if self.findDialog is None:
         self.findDialog = Find.Window(self, self.editor.text)
     else:
         self.findDialog.deiconify(
         )  # TODO make sure that it repositions correctly