Пример #1
0
    def readItemNode(self):
        """ readItemNode() -> read a pickle into the items node object

        """
        filename = kfile.KFileDialog.getOpenFileName('', '*', self)
        filename = str(filename)
        if not filename:
            return

        item = self.context
        itemkey = str(item.text(0))
        parent = item.parent()
        if not parent:
            return

        parentnodey = parent.node
        if hasattr(parentnodey, itemkey):
            ## the parent node has the context label as an attribute
            ## open and load the file onto that
            try:
                graft_node = tools.load_object(filename)
            except (Exception, ), ex:
                #self.displayException('Error opening item', ex)
                util.displayException(self, 'Error opening item', ex)
                return
            else:
                setattr(parentnodey, itemkey, graft_node)
                parent.setOpen(False)
Пример #2
0
    def readItemNode(self):
        """ readItemNode() -> read a pickle into the items node object

        """
        filename = kfile.KFileDialog.getOpenFileName('', '*', self)
        filename = str(filename)
        if not filename:
            return

        item = self.context
        itemkey = str(item.text(0))
        parent = item.parent()
        if not parent:
            return

        parentnodey = parent.node
        if hasattr(parentnodey, itemkey):
            ## the parent node has the context label as an attribute
            ## open and load the file onto that
            try:
                graft_node = tools.load_object(filename)
            except (Exception, ), ex:
                #self.displayException('Error opening item', ex)
                util.displayException(self, 'Error opening item', ex)
                return
            else:
                setattr(parentnodey, itemkey, graft_node)
                parent.setOpen(False)
Пример #3
0
    def loadTickers(self, filename):
        obj = tools.load_object(filename)
        if obj.__class__.__name__ == 'TickerSupervisor':
            self.tickers = obj
            self.rebuiltTickers = {}
        else:
            print 'Could not load a pickled tickers from %s' % (filename, )
            return

        self.fileName = filename
        self.setCaption(self.title % filename)
        self.tickersListView.clear()

        for (tid, tsym), tobj in obj.items():
            item = qt.QListViewItem(self.tickersListView)
            item.setText(0, str(tid))
            item.setText(1, tsym)
            item.setText(2, str(len(tobj.series[1])))
Пример #4
0
    def loadTickers(self, filename):
        obj = tools.load_object(filename)
        if obj.__class__.__name__ == 'TickerSupervisor':
            self.tickers = obj
            self.rebuiltTickers = {}
        else:
            print 'Could not load a pickled tickers from %s' % (filename, )
            return

        self.fileName = filename
        self.setCaption(self.title % filename)
        self.tickersListView.clear()

        for (tid, tsym), tobj in obj.items():
            item = qt.QListViewItem(self.tickersListView)
            item.setText(0, str(tid))
            item.setText(1, tsym)
            item.setText(2, str(len(tobj.series[1])))
Пример #5
0
            ## the parent node has the context label as an attribute
            ## open and load the file onto that
            try:
                graft_node = tools.load_object(filename)
            except (Exception, ), ex:
                #self.displayException('Error opening item', ex)
                util.displayException(self, 'Error opening item', ex)
                return
            else:
                setattr(parentnodey, itemkey, graft_node)
                parent.setOpen(False)
        elif isinstance(item, (tuple, list, )):
            util.displayException(self, 'Cannot read file into this item', '')
        else:
            try:
                parentnodey[itemkey] = tools.load_object(filename)
            except (Exception, ), ex:
                util.displayException(self, 'Error opening item', ex)
            else:
                parent.setOpen(False)

    def contentsMouseDoubleClickEvent(self, event):
        """

            This probably breaks some kde/qt ui standard because the list view
            items are *not* expanded.  I just can't stand this list opening its
            items on a double click, so the event is sunk here and a signal is
            emitted just the same.
        """
        event.ignore()
        self.emit(util.sigDoubleClicked, (self.selectedItem(), ))
Пример #6
0
        strat = args[0]
        files = args[1:]
        files.sort(files_sorter)
        if not files:
            raise IndexError()
    except (IndexError, ):
        print_usage(name=sys.argv[0])
        return

    try:
        strat_session = session.Session(strategy_builder=strat)
    except (Exception, ), ex:
        msg = 'Exception loading strategy builder named "%s"' % (strat, )
        print_coverage_ex(msg)
        return

    try:
        supervisors = [(fn, tools.load_object(fn).values()) for fn in files]
        results = strategy_report(strat, supervisors)
    except (KeyboardInterrupt, ):
        print 'Keyboard interrupt'
    except (Exception, ), ex:
        msg = 'Exception executing strategy "%s"' % (ex, )
        print_coverage_ex(msg)
        return
    return results


if __name__ == '__main__':
    data = main()
Пример #7
0
                graft_node = tools.load_object(filename)
            except (Exception, ), ex:
                #self.displayException('Error opening item', ex)
                util.displayException(self, 'Error opening item', ex)
                return
            else:
                setattr(parentnodey, itemkey, graft_node)
                parent.setOpen(False)
        elif isinstance(item, (
                tuple,
                list,
        )):
            util.displayException(self, 'Cannot read file into this item', '')
        else:
            try:
                parentnodey[itemkey] = tools.load_object(filename)
            except (Exception, ), ex:
                util.displayException(self, 'Error opening item', ex)
            else:
                parent.setOpen(False)

    def contentsMouseDoubleClickEvent(self, event):
        """

            This probably breaks some kde/qt ui standard because the list view
            items are *not* expanded.  I just can't stand this list opening its
            items on a double click, so the event is sunk here and a signal is
            emitted just the same.
        """
        event.ignore()
        self.emit(util.sigDoubleClicked, (self.selectedItem(), ))
Пример #8
0
        strat = args[0]
        files = args[1:]
        files.sort(files_sorter)
        if not files:
            raise IndexError()
    except (IndexError, ):
        print_usage(name=sys.argv[0])
        return

    try:
        strat_session = session.Session(strategy_builder=strat)
    except (Exception, ), ex:
        msg = 'Exception loading strategy builder named "%s"' % (strat, )
        print_coverage_ex(msg)
        return

    try:
        supervisors = [(fn, tools.load_object(fn).values()) for fn in files]
        results = strategy_report(strat, supervisors)
    except (KeyboardInterrupt, ):
        print 'Keyboard interrupt'
    except (Exception, ), ex:
        msg = 'Exception executing strategy "%s"' % (ex, )
        print_coverage_ex(msg)
        return
    return results


if __name__ == '__main__':
    data = main()