Exemplo n.º 1
0
 def load(self):
     """Load a gipsy set. It could be loaded from a fits file or directly from a set file.
     Reads the properties and comments of the set and then it displays them in the 
     corresponding fields of the view
     
     Returns
     ------------
     output: String
         Return the log obtained from load the set
     
     Raises
     ---------
     gipsyException
         Raise a gipsyException when gets some error accesing to the set
     """
     
     try:
         #log=self.gSet.loadSet(self.setname,self.fitsname)
         log=self.gSet.loadSet(self.setname)
     except gipsyException as g:
         raise g
         return
     
    
     
     #Adding the comment Area
     self.commentsArea=MyEditArea()
     self.commentsArea.setReadOnly(False)
     self.commentsArea.setMaximumHeight(50)
     sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
     sizePolicy.setHorizontalStretch(0)
     sizePolicy.setVerticalStretch(0)
     sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
     self.commentsArea.setSizePolicy(sizePolicy)
     self.horizontalLayout.addWidget(self.commentsArea)
     self.connect(self.commentsArea, SIGNAL("editingFinished"),self.emitCommentsChanged)
     self.connect(self.historyButton,  SIGNAL("clicked()"), self.emitShowHistory)
     self.connect(self.headerButton,  SIGNAL("clicked()"), self.showHeaders)
     self.connect(self.sampButton, SIGNAL("clicked()"), self.emitSendToSamp )
     
     try:
         #self.PropertiesText.setText(unicode(self.gSet.getProperties()))
         text=unicode(self.gSet.getProperties())
     except gipsyException as g:
         raise g
         return
     self.PropertiesText.insertHtml("<pre>"+text+"</pre>")
     cursor=self.PropertiesText.textCursor()
     cursor.setPosition(0)
     self.PropertiesText.setTextCursor(cursor)
         
     try:
        self.commentsArea.setText(unicode(self.gSet.getComments()))
     except gipsyException as g:
         raise g
         return
     
     return log
Exemplo n.º 2
0
    def __init__(self):
        
        super(workflow, self).__init__()
        self.setupUi(self)

        
        #The log variable stores the python command except import and gipsy command
        self.log=""

        #workflowArea variable is the textArea where show the logs
        self.workflowArea=MyEditArea()
        highlight = PythonHighlighter(self.workflowArea.document())
        self.verticalLayout.addWidget(self.workflowArea)
        self.connect(self.workflowArea, SIGNAL("editingFinished"),self.updateWorkflow)
        self.connect(self.saveButton,SIGNAL("clicked()"), self.save)
Exemplo n.º 3
0
    def __init__(self):
        """
        This class keeps the logs from the execution of gipsy task. This logs are python sentences which, in case to be executed, they  will reproduce the gipsy task action
        ATTRIBUTES:
        - self.log: it contains the plain text with the logs and other python sentences which build a python script that can be executed in HERMES command line.
        - self.workflowArea: The area which shows the logs.
        """
        super(workflow, self).__init__()
        self.setupUi(self)

        
        #The log variable stores the python command except import and gipsy command
        self.log=""

        #workflowArea variable is the textArea where show the logs
        self.workflowArea=MyEditArea()
        highlight = PythonHighlighter(self.workflowArea.document())
        self.verticalLayout.addWidget(self.workflowArea)
        self.connect(self.workflowArea, SIGNAL("editingFinished"),self.updateWorkflow)
        self.connect(self.saveButton,SIGNAL("clicked()"), self.save)
Exemplo n.º 4
0
class view_gipsySet(QScrollArea,Ui_setWidget):
    
    """ This class inherits from Ui_gipsySet. The Ui_gipsySet class contains the graphical part
    and view_gipsySet class contains the operational part. 
    This class provides the view to show the information of the set and the methods for interacting with it.
    
    **Parameters**
    
    setname: String
        The pathname of the set
    fitsname: String, Optional
        The pathname of the fits file containing the set. 
    
    **Attributes**
    
    gSet: :class:`gipsyClasses.gipsySet.gipsySet`
        It is an instance of gipsySet class. This class implement the interaction 
        with gipsy software.
    setname: String
        Pathname of the set
    fitsname: String
        Pathname of the set
    commentsArea: :class:`help.view_help.helpContainer`
        Inherited from UI_gipsySet class
    PropertiesText: :class:`PyQt4.QtGui.QTextEdi`
        Inherited from UI_gipsySet class
    historyButton: :class:`PyQt4.QtGui.QPushButton`
        Inherited from UI_gipsySet class
    headerButton: :class:`PyQt4.QtGui.QPushButton`
        Inherited from UI_gipsySet class
    
    """
    #def __init__(self, setname,  fitsname=None):
    def __init__(self, setname):
        super(view_gipsySet, self).__init__()
        self.setupUi(self)
        self.gSet=gipsySet()
        self.setname=setname
        #self.fitsname=fitsname
        
    def load(self):
        """Load a gipsy set. It could be loaded from a fits file or directly from a set file.
        Reads the properties and comments of the set and then it displays them in the 
        corresponding fields of the view
        
        **Returns**

        output: String
            Return the log obtained from load the set
        
        **Raises**
        
        gipsyException
            Raise a gipsyException when gets some error accesing to the set
        """
        
        try:
            #log=self.gSet.loadSet(self.setname,self.fitsname)
            log=self.gSet.loadSet(self.setname)
        except gipsyException as g:
            raise g
            return
        
       
        
        #Adding the comment Area
        self.commentsArea=MyEditArea()
        self.commentsArea.setReadOnly(False)
        self.commentsArea.setMaximumHeight(50)
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
        self.commentsArea.setSizePolicy(sizePolicy)
        self.horizontalLayout.addWidget(self.commentsArea)
        self.connect(self.commentsArea, SIGNAL("editingFinished"),self.emitCommentsChanged)
        self.connect(self.historyButton,  SIGNAL("clicked()"), self.emitShowHistory)
        self.connect(self.headerButton,  SIGNAL("clicked()"), self.showHeaders)
        self.connect(self.sampButton, SIGNAL("clicked()"), self.emitSendToSamp )
        
        if len(self.setname)>79:
            self.sampButton.setEnabled(False)
        
        try:
            #self.PropertiesText.setText(unicode(self.gSet.getProperties()))
            text=unicode(self.gSet.getProperties())
        except gipsyException as g:
            raise g
            return
        self.PropertiesText.insertHtml("<pre>"+text+"</pre>")
        cursor=self.PropertiesText.textCursor()
        cursor.setPosition(0)
        self.PropertiesText.setTextCursor(cursor)
            
        try:
           self.commentsArea.setText(unicode(self.gSet.getComments()))
        except gipsyException as g:
            raise g
            return
        
        return log
   
    def delete(self):
        log=""
        try:
            log=self.gSet.deleteSet()
        except gipsyException as g:
            raise g
            return log
        
        return log
    def deleteTable(self, tabname, subset):
        output=self.gSet.deleteTable(tabname, subset)
        return output
        
    def closeSet(self):
        log=self.gSet.closeSet()
        return log
        
    def emitCommentsChanged(self):
        """Update the comments when the editing finish in the comments text area.
        Emit the corresponding signal with the log as parameter in order to update workflow text
        
        """
        
        comments=self.commentsArea.toPlainText()
        log=self.gSet.updateComments(comments)
        self.emit(SIGNAL("commentsChanged"), log)
  

    
    def emitShowHistory(self):
        """Show in a dialog the history text of the set
        **Raises**
        
        gipsyException
            Raise a gipsyException when gets some error accesing to the set
         """
        try:
            history=self.gSet.getHistory()
        except gipsyException as g:
            QMessageBox.warning(self, "Show history failed", QString(g.msj))
            return
        
        if(history=="") : 
            history="There is not any HISTORY item "

        Dlg=historyDlg(history)
        Dlg.exec_()
        
    def emitSendToSamp(self):
        self.emit(SIGNAL("settosamp"), self.setname)
    def showHeaders(self):
        """Show in a dialog a form with the header items. This form allow edit/delete and add header items.
        When the dialog is closed, it updates the header items properly
        
        **Raises**
        
        gipsyException
            Raise a gipsyException when gets some error accesing to the set
        """
        try:
            items=self.gSet.getHeaderItems()
        except gipsyException as g:
            QMessageBox.warning(self, "Read Header Set Failed", QString(g.msj))
            return
        self.ghd=gipsyHeadersDlg(items)
        self.ghd.load()
        self.connect(self.ghd, SIGNAL("headerKeyDeleted"),self.deleteHeaderKey)
        self.connect(self.ghd, SIGNAL("headerKeyChanged"),self.changeHeaderKey)
        self.connect(self.ghd, SIGNAL("headerKeyAdded"), self.addHeaderKey)
        self.ghd.exec_()
 
            

    def deleteHeaderKey(self, key):
        try:
            log=self.gSet.deleteHeaderKey(key)
        except gipsyException as g:
            QMessageBox.warning(self, "Delete Header Item Failed ", QString(g.msj))
            return
        self.emit(SIGNAL("headersChanged"), log)
        
    def changeHeaderKey(self, key, newval):
        key=str(key)
        newval=str(newval)
    
        try:
            log=self.gSet.updateHeaderKey(key,newval)
        except gipsyException as g:
            QMessageBox.warning(self, "Update Header Item Failed ", QString(g.msj))
            if hasattr(self, 'ghd'):
                self.ghd.done(0)
                try:
                    items=self.gSet.getHeaderItems()
                except gipsyException as g:
                    QMessageBox.warning(self, "Read Header Set Failed", QString(g.msj))
                    return
                self.ghd=gipsyHeadersDlg(items)
                self.ghd.load()
                self.connect(self.ghd, SIGNAL("headerKeyDeleted"),self.deleteHeaderKey)
                self.connect(self.ghd, SIGNAL("headerKeyChanged"),self.changeHeaderKey)
                self.connect(self.ghd, SIGNAL("headerKeyAdded"), self.addHeaderKey)
                self.ghd.exec_()
            return
        self.emit(SIGNAL("headersChanged"), log)
    
    def addHeaderKey(self, key, value):
        
        try:
            log=self.gSet.newHeaderKey(str(key), str(value))
        except gipsyException as g:
            QMessageBox.warning(self, "Add New Header Item Failed", QString(g.msj))
            return
        except UnicodeEncodeError:
            QMessageBox.warning(self, "ASCII encode error", QString("Unable encode "+unicode(key)+" "+unicode(value)))
            return
        self.emit(SIGNAL("headersChanged"), log)

        
    def getInfo(self):
        """Return some information about the set: the size in KB, the dimension and the axes
        
        **Returns**
        
        output: String
            The size in KB, the dimension and the axes of the set
            
        """
        
        #Get the size of the file
        try:
            size=os.path.getsize(self.setname+".image")
        except OSError:
            return
        
        output=unicode(size/1024)+" KBytes\n"
        output=output+self.gSet.getInfo()
        return output
    def getTablesInfo(self):
        return self.gSet.getTablesInfo()

    def getTableData(self,numTable):
        return self.gSet.getTableData(numTable)


    def reload(self):
       
        log=""
        log=log+self.gSet.closeSet()
        del self.gSet
        self.gSet=gipsySet()
        try:
            log=log+self.gSet.loadSet(self.setname)
        except gipsyException as g:
            raise g
            return
        
        
        try:
            text=unicode(self.gSet.getProperties())
        except gipsyException as g:
            raise g
            return
        self.PropertiesText.setHtml("")
        self.PropertiesText.insertHtml("<pre>"+text+"</pre>")
        cursor=self.PropertiesText.textCursor()
        cursor.setPosition(0)
        self.PropertiesText.setTextCursor(cursor)
            
        try:
           self.commentsArea.setText(unicode(self.gSet.getComments()))
        except gipsyException as g:
            raise g
            return
        
        return log
Exemplo n.º 5
0
class workflow(QWidget,Ui_workflow):
    def __init__(self):
        """
        This class keeps the logs from the execution of gipsy task. This logs are python sentences which, in case to be executed, they  will reproduce the gipsy task action
        ATTRIBUTES:
        - self.log: it contains the plain text with the logs and other python sentences which build a python script that can be executed in HERMES command line.
        - self.workflowArea: The area which shows the logs.
        """
        super(workflow, self).__init__()
        self.setupUi(self)

        
        #The log variable stores the python command except import and gipsy command
        self.log=""

        #workflowArea variable is the textArea where show the logs
        self.workflowArea=MyEditArea()
        highlight = PythonHighlighter(self.workflowArea.document())
        self.verticalLayout.addWidget(self.workflowArea)
        self.connect(self.workflowArea, SIGNAL("editingFinished"),self.updateWorkflow)
        self.connect(self.saveButton,SIGNAL("clicked()"), self.save)

        
    def getWorkflowText(self):
        return self.log
    
    def setWorkflowText(self, log):
        self.log=log
        #text="#!/usr/bin/env/python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"+log+"\n\ngipsy.finis()"
        self.workflowArea.setPlainText(self.log)
    
    def appendWorkflowText(self, log):
        self.log=self.log+log+"\n"
        #text="#!/usr/bin/env/python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"+self.log+"\n\ngipsy.finis()"
        self.workflowArea.setPlainText(self.log)
        
    
    def updateWorkflow(self):
        self.log=self.workflowArea.toPlainText()
        self.emit(SIGNAL("updateWorkflow"))
    def clearWorkflow(self):
        self.log=""
        self.workflowArea.setPlainText("")
    
    def save(self):
        newFile = unicode(QFileDialog.getSaveFileName(self,"Save workflow", "workflow.py",".py", "Choose a file"))
        if newFile=="":
            return False
        
        try:
            fh=open(newFile, "wb")
        except IOError as e:
            fh.close()
            raise e
            return
        pre="#!/usr/bin/env python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"
        post="\n\ngipsy.finis()"
        text=pre+unicode(self.workflowArea.toPlainText())+post
        try:
            fh.write(text)
        except UnicodeEncodeError as e:
            fh.close()
            raise e
            return
Exemplo n.º 6
0
class workflow(QWidget,Ui_workflow):
    """This class keeps the logs of the performed actions in GUIpsy.
    Most of these log lines will be python sentences, but sometimes the log time will be a commented line with the info of the action performed.
        
    Logged actions:
        - Every task of gipsy returns a log with the gipsy xeq command reproducing the task. 
          Some gipsy tasks create a new set from other set, and this second set inherits the settables of the first. 
          The settables in the second set could not represent the data of the new set, so it could be confusing. 
          This behaviour has been improved, and the settables inherited are deleted in the new set. Also the commands corresponding to delete these tables are returned as logs.
        - When a cola or python script is launched to HERMES, a log is returned with the gipsy xeq command which execute the script.
        - When headers / comments set are edited.
        
    **Attributes**
    
    log : String
        it contains the plain text with every log lines 
    workflowArea :  :class:`dialog.myeditarea.MyEditArea`
        The area which shows the logs.
            
    """
    
    def __init__(self):
        
        super(workflow, self).__init__()
        self.setupUi(self)

        
        #The log variable stores the python command except import and gipsy command
        self.log=""

        #workflowArea variable is the textArea where show the logs
        self.workflowArea=MyEditArea()
        highlight = PythonHighlighter(self.workflowArea.document())
        self.verticalLayout.addWidget(self.workflowArea)
        self.connect(self.workflowArea, SIGNAL("editingFinished"),self.updateWorkflow)
        self.connect(self.saveButton,SIGNAL("clicked()"), self.save)

        
    def getWorkflowText(self):
        return self.log
    
    def setWorkflowText(self, log):
        self.log=log
        #text="#!/usr/bin/env/python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"+log+"\n\ngipsy.finis()"
        self.workflowArea.setPlainText(self.log)
    
    def appendWorkflowText(self, log):
        self.log=self.log+log+"\n"
        #text="#!/usr/bin/env/python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"+self.log+"\n\ngipsy.finis()"
        self.workflowArea.setPlainText(self.log)
        
    
    def updateWorkflow(self):
        self.log=self.workflowArea.toPlainText()
        self.emit(SIGNAL("updateWorkflow"))
    def clearWorkflow(self):
        self.log=""
        self.workflowArea.setPlainText("")
    
    def save(self):
        newFile = unicode(QFileDialog.getSaveFileName(self,"Save workflow", "workflow.py",".py", "Choose a file"))
        if newFile=="":
            return False
        
        try:
            fh=open(newFile, "wb")
        except IOError as e:
            fh.close()
            raise e
            return
        pre="#!/usr/bin/env python\nimport gipsy\nfrom gipsy import *\ngipsy.init()\n\n"
        post="\n\ngipsy.finis()"
        text=pre+unicode(self.workflowArea.toPlainText())+post
        try:
            fh.write(text)
        except UnicodeEncodeError as e:
            fh.close()
            raise e
        else:
            fh.close
            os.chmod(newFile, 0744)
            return