Esempio n. 1
0
    def updateIndex(self):
        file_list = []

        def accumulate_files(flist, directory, files):
            for fname in [
                    afname for afname in files if afname.endswith('.h5')
            ]:
                flist.append(os.path.realpath(os.path.join(directory, fname)))

        os.path.walk(getPyphantPath(KM_PATH), accumulate_files, file_list)
        try:
            from wx import (ProgressDialog, PyNoAppError)
            try:
                pdial = ProgressDialog('Rebuilding index...',
                                       ' ' * 100,
                                       maximum=len(file_list))
            except PyNoAppError:
                pdial = None
        except ImportError:
            pdial = None
        count = 1
        for realname in file_list:
            if pdial is not None:
                pdial.Update(count, os.path.basename(realname))
                count += 1
            try:
                self.registerH5(realname)
            except:
                self.logger.warn("Could not extract meta data from '%s'."\
                                 % realname)
        if pdial is not None:
            pdial.Destroy()
Esempio n. 2
0
 def __init__(self, dlg_title, dlg_msg="Please wait..."):
     self.pdlg = ProgressDialog(message=dlg_msg,
                                title=dlg_title,
                                maximum=100#,
     )
     self.pdlg.Pulse()
     module_logger.info("Successfully initialized progressDialog.")
Esempio n. 3
0
class progressDialog(object):
    """Simple wrapper for wxPython's ProgressDialog,
    creates a pulsing progress bar to indicate busy status.
    Call close() when complete.  Recommended only when a
    very simple wait message is required.
    """

    def __init__(self, dlg_title, dlg_msg="Please wait..."):
        self.pdlg = ProgressDialog(message=dlg_msg,
                                   title=dlg_title,
                                   maximum=100#,
        )
        self.pdlg.Pulse()
        module_logger.info("Successfully initialized progressDialog.")

    def update(self):
        self.pdlg.UpdatePulse()

    def close(self):
        self.pdlg.Update(100)
        module_logger.info("Closing progressDialog.")
        self.pdlg.Destroy()
Esempio n. 4
0
    def reversePython(self, umlFrame: UmlClassDiagramsFrame,
                      directoryName: str, files: List[str]):
        """
        Reverse engineering Python files to OglClass's

        Args:
            umlFrame:       The uml frame to display on
            directoryName:  The directory name where the selected files reside
            files:          A list of files to parse
        """
        fileCount: int = len(files)
        dlg = ProgressDialog('Parsing Files',
                             'Starting',
                             parent=umlFrame,
                             style=PD_APP_MODAL | PD_ELAPSED_TIME)
        dlg.SetRange(fileCount)
        currentFileCount: int = 0

        onGoingParents: Parents = Parents({})
        for fileName in files:

            try:
                fqFileName: str = f'{directoryName}{osSep}{fileName}'
                self.logger.info(f'Processing file: {fqFileName}')
                dlg.Update(currentFileCount, f'Processing: {fileName}')

                fileStream: FileStream = FileStream(fqFileName)
                lexer: Python3Lexer = Python3Lexer(fileStream)

                stream: CommonTokenStream = CommonTokenStream(lexer)
                parser: Python3Parser = Python3Parser(stream)

                tree: Python3Parser.File_inputContext = parser.file_input()
                if parser.getNumberOfSyntaxErrors() != 0:
                    self.logger.error(
                        f"File {fileName} contains {parser.getNumberOfSyntaxErrors()} syntax errors"
                    )
                    # TODO:  Put up a dialog
                    continue

                self.visitor = PyutPythonVisitor()
                self.visitor.parents = onGoingParents
                self.visitor.visit(tree)
                self._generatePyutClasses()

                onGoingParents = self.visitor.parents
                currentFileCount += 1
            except (ValueError, Exception) as e:
                from org.pyut.errorcontroller.ErrorManager import ErrorManager
                eMsg: str = f'file: {fileName}\n{e} - {ErrorManager.getErrorInfo()}'
                self.logger.error(eMsg)
                dlg.Destroy()
                raise PythonParseException(eMsg)
        dlg.Destroy()
        self._generateOglClasses(umlFrame)
        self._layoutUmlClasses(umlFrame)
        self._generateInheritanceLinks(umlFrame)
Esempio n. 5
0
asr = '/usr/sbin/asr -source '

#path variables
os_path = '/Volumes/main'
ipath = '/net/server/image.dmg '
dpath = '-target /Volumes/main -erase -noprompt -noverify &'
reimage_cmd = "%s%s%s" % (asr, ipath, dpath)

#Reboot Variables
reboot = 'reboot'
bless = '/usr/sbin/bless -folder /Volumes/main/System/Library/CoreServices -setOF'

#wxpython portion
application = PySimpleApp()
dialog = ProgressDialog('Progress',
                        'Attempting Rebuild of Main Partition',
                        maximum=100,
                        style=PD_APP_MODAL | PD_ELAPSED_TIME)


def boot2main():
    """Blesses new partition and reboots"""
    subprocess.call(bless, shell=True)
    subprocess.call(reboot, shell=True)


def rebuild():
    """Rebuilds Partition"""
    try:
        time.sleep(5)  #Gives dialog time to run
        subprocess.call(reimage_cmd)
    except OSError:
Esempio n. 6
0
    def __setupProgressDialog(self) -> ProgressDialog:

        self._progressDlg: ProgressDialog = ProgressDialog(
            "Creating Tasks", "", parent=self, style=PD_ELAPSED_TIME)

        return self._progressDlg