def copyAll(self):
     """ copy all messages to clipboard """
     texts = []
     for i in range(self.list.count()):
         texts.append(self.list.item(i).data(32))
     text = "\n".join(texts)
     get_vistrails_application().clipboard().setText(text)
Example #2
0
def switch_to_mashup_view():
    """switch_to_mashup_view():

    Changes current viewing mode to mashup view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['mashup'].trigger()
Example #3
0
 def copyAll(self):
     """ copy all messages to clipboard """
     texts = []
     for i in range(self.list.count()):
         texts.append(self.list.item(i).data(32))
     text = '\n'.join(texts)
     get_vistrails_application().clipboard().setText(text)
Example #4
0
def switch_to_query_view():
    """switch_to_query_view():

    Changes current viewing mode to query view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['search'].trigger()
Example #5
0
def switch_to_pipeline_view():
    """switch_to_pipeline_view():

    Changes current viewing mode to pipeline view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['pipeline'].trigger()
Example #6
0
def switch_to_mashup_view():
    """switch_to_mashup_view():

    Changes current viewing mode to mashup view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['mashup'].trigger()
Example #7
0
def switch_to_pipeline_view():
    """switch_to_pipeline_view():

    Changes current viewing mode to pipeline view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['pipeline'].trigger()
Example #8
0
def switch_to_query_view():
    """switch_to_query_view():

    Changes current viewing mode to query view in the builder window.

    """
    get_vistrails_application().builderWindow.qactions['search'].trigger()
Example #9
0
    def clicked_on_login(self):
        """
        Attempts to log into web repository
        stores auth cookie for session
        """
        from vistrails.gui.application import get_vistrails_application

        self.dialog.loginUser = self.loginUser.text()
        params = urllib.urlencode({
            'username': self.dialog.loginUser,
            'password': self.loginPassword.text()
        })
        self.dialog.cookiejar = cookielib.CookieJar()

        # set base url used for cookie
        self.dialog.cookie_url = self.config.webRepositoryURL

        self.loginOpener = urllib2.build_opener(
            urllib2.HTTPCookieProcessor(self.dialog.cookiejar))

        # FIXME doesn't use https
        login_url = "%s/account/login/" % self.config.webRepositoryURL
        request = urllib2.Request(login_url, params)
        url = self.loginOpener.open(request)

        # login failed
        if not 'sessionid' in [
                cookie.name for cookie in self.dialog.cookiejar
        ]:
            debug.critical("Incorrect username or password")
            self.dialog.cookiejar = None
        else:  # login successful

            self._login_status = "login successful"

            self.loginUser.setEnabled(False)
            self.loginPassword.setEnabled(False)
            self._login_button.setEnabled(False)
            self.saveLogin.setEnabled(False)

            # add association between VisTrails user and web repository user
            if self.saveLogin.checkState():
                if not (self.config.check('webRepositoryUser')
                        and self.config.webRepositoryUser
                        == self.loginUser.text()):
                    self.config.webRepositoryUser = str(self.loginUser.text())
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryUser = self.config.webRepositoryUser
                    get_vistrails_application().save_configuration()

            # remove association between VisTrails user and web repository user
            else:
                if self.config.check(
                        'webRepositoryUser') and self.config.webRepositoryUser:
                    self.config.webRepositoryUser = ""
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryUser = ""
                    get_vistrails_application().save_configuration()
            self.close_dialog(0)
Example #10
0
    def clicked_on_login(self):
        """
        Attempts to log into web repository
        stores auth cookie for session
        """
        from vistrails.gui.application import get_vistrails_application

        self.dialog.loginUser = self.loginUser.text()
        params = urllib.urlencode({'username':self.dialog.loginUser,
                                   'password':self.loginPassword.text()})
        self.dialog.cookiejar = cookielib.CookieJar()

        # set base url used for cookie
        self.dialog.cookie_url = self.config.webRepositoryURL

        self.loginOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.dialog.cookiejar))

        # FIXME doesn't use https
        login_url = "%s/account/login/" % self.config.webRepositoryURL
        request = urllib2.Request(login_url, params)
        url = self.loginOpener.open(request)

        # login failed
        if not 'sessionid' in [cookie.name for cookie in self.dialog.cookiejar]:
            debug.critical("Incorrect username or password")
            self.dialog.cookiejar = None
        else: # login successful

            self._login_status = "login successful"

            self.loginUser.setEnabled(False)
            self.loginPassword.setEnabled(False)
            self._login_button.setEnabled(False)
            self.saveLogin.setEnabled(False)

            # add association between VisTrails user and web repository user
            if self.saveLogin.checkState():
                if not (self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin == self.loginUser.text()):
                    self.config.webRepositoryLogin = str(self.loginUser.text())
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = self.config.webRepositoryLogin
                    get_vistrails_application().save_configuration()

            # remove association between VisTrails user and web repository user
            else:
                if self.config.check('webRepositoryLogin') and self.config.webRepositoryLogin:
                    self.config.webRepositoryLogin = ""
                    pers_config = get_vistrails_persistent_configuration()
                    pers_config.webRepositoryLogin = ""
                    get_vistrails_application().save_configuration()
            self.close_dialog(0)
Example #11
0
    def write(self, s):
        """write(s) -> None
        adds the string s to the message list and displays it
        """
        # adds the string s to the list and
        s = s.strip()
        msgs = s.split('\n')

        if len(msgs) <= 3:
            msgs.append('Error logging message: invalid log format')
            s += '\n' + msgs[3]
        if not len(msgs[3].strip()):
            msgs[3] = "Unknown Error"
            s = '\n'.join(msgs)
        text = msgs[3]
        item = QtGui.QListWidgetItem(text)
        item.setData(32, s)
        item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
        self.list.addItem(item)
        item.setForeground(CurrentTheme.DEBUG_COLORS[msgs[0]])
        self.list.setItemHidden(item, not self.levels[msgs[0]].isChecked())
        alwaysShowDebugPopup = getattr(get_vistrails_configuration(),
                                       'showDebugPopups', False)
        if msgs[0] == 'CRITICAL':
            if self.isVisible() and not alwaysShowDebugPopup:
                self.raise_()
                self.activateWindow()
                modal = get_vistrails_application().activeModalWidget()
                if modal:
                    # need to beat modal window
                    self.showMessageBox(item)
            else:
                self.showMessageBox(item)
Example #12
0
    def write(self, s):
        """write(s) -> None
        adds the string s to the message list and displays it
        """
        # adds the string s to the list and
        s = s.strip()
        msgs = s.split("\n")

        if len(msgs) <= 3:
            msgs.append("Error logging message: invalid log format")
            s += "\n" + msgs[3]
        if not len(msgs[3].strip()):
            msgs[3] = "Unknown Error"
            s = "\n".join(msgs)
        text = msgs[3]
        item = QtGui.QListWidgetItem(text)
        item.setData(32, s)
        item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
        self.list.addItem(item)
        item.setForeground(CurrentTheme.DEBUG_COLORS[msgs[0]])
        self.list.setItemHidden(item, not self.levels[msgs[0]].isChecked())
        alwaysShowDebugPopup = getattr(get_vistrails_configuration(), "alwaysShowDebugPopup", False)
        if msgs[0] == "CRITICAL":
            if self.isVisible() and not alwaysShowDebugPopup:
                self.raise_()
                self.activateWindow()
                modal = get_vistrails_application().activeModalWidget()
                if modal:
                    # need to beat modal window
                    self.showMessageBox(item)
            else:
                self.showMessageBox(item)
Example #13
0
 def test_new_vistrail_button_states(self):
     assert get_vistrails_application().builderWindow.qactions['newVistrail'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['closeVistrail'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['saveFile'].isEnabled()
     assert not get_vistrails_application().builderWindow.qactions['saveFileAs'].isEnabled()
     view = new_vistrail()
     assert get_vistrails_application().builderWindow.qactions['newVistrail'].isEnabled()
     assert get_vistrails_application().builderWindow.qactions['closeVistrail'].isEnabled()
     self.assertEqual(get_vistrails_application().builderWindow.qactions['saveFile'].isEnabled(),
                      view.has_changes())
     assert get_vistrails_application().builderWindow.qactions['saveFileAs'].isEnabled()
Example #14
0
def get_current_vistrail_view():
    """get_current_vistrail():

    Returns the currently selected vistrail view.

    """
    view = get_vistrails_application().builderWindow.get_current_view()
    if view is None:
        raise NoVistrail
    return view    
Example #15
0
def get_current_vistrail_view():
    """get_current_vistrail():

    Returns the currently selected vistrail view.

    """
    view = get_vistrails_application().builderWindow.get_current_view()
    if view is None:
        raise NoVistrail
    return view
Example #16
0
def get_builder_window():
    """get_builder_window():

    returns the main VisTrails GUI window

    raises NoGUI.

    """
    try:
        return get_vistrails_application().builderWindow
    except AttributeError:
        raise NoGUI
Example #17
0
def get_builder_window():
    """get_builder_window():

    returns the main VisTrails GUI window

    raises NoGUI.

    """
    try:
        return get_vistrails_application().builderWindow
    except AttributeError:
        raise NoGUI
Example #18
0
def get_current_controller():
    """get_current_controller():

    returns the VistrailController of the currently selected vistrail.

    raises NoVistrail.

    """
    try:
        return get_vistrails_application().builderWindow.get_current_controller()
    except AttributeError:
        raise NoVistrail
Example #19
0
def get_current_controller():
    """get_current_controller():

    returns the VistrailController of the currently selected vistrail.

    raises NoVistrail.

    """
    try:
        return get_vistrails_application(
        ).builderWindow.get_current_controller()
    except AttributeError:
        raise NoVistrail
Example #20
0
def getFileRelativeToCurrentVT(fname, curModule=None):
    #  This is three step approach:
    #  step 1: if fname exists assume it's the one we want and return it.
    #  step 2: Look for the file relative to the current VT.
    #        In effect loop through all the sibling and descendant folders
    #        of the vt file's parent directory and look for the base filename in each.
    #        If we find an identically named file hope for the best and return it.
    #  step 3: Do what we did in step 2 but relative to the current session folder.
    #
    #  If no fname is found in the above three steps raise an error.
    def couldntFindFile():
        msg = "Could not find file: " + fname + "\nPlease point to valid location for this file."
        if curModule is None:
            raise Exception(msg)
        else:
            raise ModuleError(curModule, msg)

    try:
        fname = fname.replace("\\", "/")
        #  step 1
        if os.path.exists(fname):
            return fname
        elif fname == '':
            return fname

        #  step 2 (and then step3)
        try:
            app = application.get_vistrails_application()()
            curlocator = app.get_vistrail().locator.name
            curVTdir = os.path.split(curlocator)[0]
        except:
            curVTdir = ""

        root_dir, justfname = os.path.split(fname)
        if justfname.lower() == "hdr.adf":
            justfname = os.path.sep.join(
                [os.path.split(root_dir)[1], justfname])
        for rootdir in [curVTdir, get_root_dir()]:
            if os.path.exists(os.path.join(rootdir, justfname)):
                return os.path.join(rootdir, justfname)
            for root, dirnames, filenames in os.walk(rootdir):
                for dirname in dirnames:
                    if os.path.exists(os.path.join(root, dirname, justfname)):
                        return os.path.join(root, dirname, justfname)

        #  we did our best but couldn't find the file
        couldntFindFile()

    except Exception, e:
        #  if something goes wrong we couldn't find the file throw an error
        couldntFindFile()
Example #21
0
def getFileRelativeToCurrentVT(fname, curModule=None):
    #  This is three step approach:
    #  step 1: if fname exists assume it's the one we want and return it.
    #  step 2: Look for the file relative to the current VT.
    #        In effect loop through all the sibling and descendant folders
    #        of the vt file's parent directory and look for the base filename in each.
    #        If we find an identically named file hope for the best and return it.
    #  step 3: Do what we did in step 2 but relative to the current session folder.
    #
    #  If no fname is found in the above three steps raise an error.
    def couldntFindFile():
        msg = "Could not find file: " + fname + "\nPlease point to valid location for this file."
        if curModule is None:
            raise Exception(msg)
        else:
            raise ModuleError(curModule, msg)

    try:
        fname = fname.replace ("\\", "/")
        #  step 1
        if os.path.exists(fname):
            return fname
        elif fname == '':
            return fname

        #  step 2 (and then step3)
        try:
            app = application.get_vistrails_application()()
            curlocator = app.get_vistrail().locator.name
            curVTdir = os.path.split(curlocator)[0]
        except:
            curVTdir = ""

        root_dir, justfname = os.path.split(fname)
        if justfname.lower() == "hdr.adf":
            justfname = os.path.sep.join([os.path.split(root_dir)[1], justfname])
        for rootdir in [curVTdir, get_root_dir()]:
            if os.path.exists(os.path.join(rootdir, justfname)):
                return os.path.join(rootdir, justfname)
            for root, dirnames, filenames in os.walk(rootdir):
                for dirname in dirnames:
                    if os.path.exists(os.path.join(root, dirname, justfname)):
                        return os.path.join(root, dirname, justfname)

        #  we did our best but couldn't find the file
        couldntFindFile()

    except Exception, e:
        #  if something goes wrong we couldn't find the file throw an error
        couldntFindFile()
Example #22
0
 def test_new_vistrail_button_states(self):
     assert get_vistrails_application(
     ).builderWindow.qactions['newVistrail'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['closeVistrail'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['saveFile'].isEnabled()
     assert not get_vistrails_application(
     ).builderWindow.qactions['saveFileAs'].isEnabled()
     view = new_vistrail()
     assert get_vistrails_application(
     ).builderWindow.qactions['newVistrail'].isEnabled()
     assert get_vistrails_application(
     ).builderWindow.qactions['closeVistrail'].isEnabled()
     self.assertEqual(
         get_vistrails_application().builderWindow.qactions['saveFile'].
         isEnabled(), view.has_changes())
     assert get_vistrails_application(
     ).builderWindow.qactions['saveFileAs'].isEnabled()
Example #23
0
    def write(self, s):
        """write(s) -> None
        adds the string s to the message list and displays it
        """
        # adds the string s to the list and 
        s = s.strip()
        msgs = s.split('\n')

        if len(msgs)<=3:
            msgs.append('Unknown Error')
            s += '\n' + msgs[3]
        if not len(msgs[3].strip()):
            msgs[3] = "Unknown Error"
            s = '\n'.join(msgs)
        text = msgs[3]
        item = QtGui.QListWidgetItem(text)
        item.setData(32, s)
        item.setFlags(item.flags()&~QtCore.Qt.ItemIsEditable)
        self.list.addItem(item)
        if msgs[0] == "INFO":
            item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_INFO_COLOR))
            self.list.setItemHidden(item, not self.infoFilter.isChecked())
        elif msgs[0] == "WARNING":
            item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_WARNING_COLOR))
            self.list.setItemHidden(item, not self.warningFilter.isChecked())
        elif msgs[0] == "CRITICAL":
            item.setForeground(QtGui.QBrush(CurrentTheme.DEBUG_CRITICAL_COLOR))
            self.list.setItemHidden(item, not self.criticalFilter.isChecked())
        if self.isVisible() and not \
          getattr(get_vistrails_configuration(),'alwaysShowDebugPopup',False):
            self.raise_()
            self.activateWindow()
            modal = get_vistrails_application().activeModalWidget()
            if modal:
                # need to beat modal window
                self.showMessageBox(item)
        else:
            self.showMessageBox(item)
Example #24
0
 def copyMessage(self):
     """ copy selected message to clipboard """
     items = self.list.selectedItems()
     if len(items) > 0:
         text = items[0].data(32)
         get_vistrails_application().clipboard().setText(text)
Example #25
0
 def copyMessage(self):
     """ copy selected message to clipboard """
     items = self.list.selectedItems()
     if len(items) > 0:
         text = items[0].data(32)
         get_vistrails_application().clipboard().setText(text)
Example #26
0
 def test_detach_vistrail(self):
     view = new_vistrail()
     get_vistrails_application().builderWindow.detach_view(view)
     get_vistrails_application().builderWindow.attach_view(view)
     close_vistrail(view)
Example #27
0
def close_current_vistrail(quiet=False):
    get_vistrails_application().builderWindow.close_vistrail(
        get_current_vistrail_view(), quiet=quiet)
Example #28
0
def new_vistrail():
    # Returns VistrailView - remember to be consistent about it..
    get_vistrails_application().builderWindow.new_vistrail(False)
    result = get_vistrails_application().builderWindow.get_current_view()
    return result
Example #29
0
def close_current_vistrail(quiet=False):
    get_vistrails_application().builderWindow.close_vistrail(get_current_vistrail_view(), quiet=quiet)
Example #30
0
def new_vistrail():
    # Returns VistrailView - remember to be consistent about it..
    get_vistrails_application().builderWindow.new_vistrail(False)
    result = get_vistrails_application().builderWindow.get_current_view()
    return result
Example #31
0
 def test_detach_vistrail(self):
     view = new_vistrail()
     get_vistrails_application().builderWindow.detach_view(view)
     get_vistrails_application().builderWindow.attach_view(view)
     close_vistrail(view)