コード例 #1
0
ファイル: create.py プロジェクト: liudger/dpa-pipe
    def _create_product(self):

        existing = Product.list(
            name=self._name,
            category=self._category,
            ptask=self._ptask.spec,
        )
        
        if len(existing) == 1:
            self._product = existing.pop()
            self._product.update(description=self._description)
            if self.interactive:
                print "\nBase product exists: " + \
                    Style.bright + self._product.spec + Style.reset
        else:
            try:
                self._product = Product.create(
                    ptask=self._ptask.spec,
                    name=self._name,
                    category=self._category,
                    description=self._description,
                    creator=current_username(),
                )
            except ProductError as e:
                raise ActionError("Unable to create product: " + str(e))
            else:
                if self.interactive:
                    print "\nCreated base product: " + \
                        Style.bright + self._product.spec + Style.reset
コード例 #2
0
ファイル: imports.py プロジェクト: liudger/dpa-pipe
    def _query_products(self):
        # find all available published products based on input
        products = Product.list(category=self.query_values['category'],
                                search=self.query_values['spec'],
                                name=self.query_values['name'])

        self._importable_products = []

        for product in products:
            print product.spec
            print self.query_values['official']
            print self.query_values['published']
            print self.query_values['deprecated']

            if self.query_values['published']:
                if self.query_values['official']:
                    if not self.query_values['deprecated']:
                        product_versions = ProductVersion.list(
                            product=product.spec,
                            published=self.query_values['published'],
                            is_official=self.query_values['official'],
                            deprecated=self.query_values['deprecated'])

            print product_versions
            for pv in product_versions:
                print pv
                self._importable_products.append(pv)

        print self.importable_products
        self._product_widget = EntityTreeWidget(self.importable_products)
        self._product_widget.setFocusPolicy(QtCore.Qt.NoFocus)
コード例 #3
0
ファイル: imports.py プロジェクト: chippey/dpa-pipe
    def _query_products(self):
        # find all available published products based on input
        products = Product.list(category=self.query_values['category'],
            search=self.query_values['spec'],
            name=self.query_values['name'])

        self._importable_products = []

        for product in products:
            print product.spec
            print self.query_values['official']
            print self.query_values['published']
            print self.query_values['deprecated']

            if self.query_values['published']:
                if self.query_values['official']:
                    if not self.query_values['deprecated']:
                        product_versions = ProductVersion.list(
                            product=product.spec,
                            published=self.query_values['published'],
                            is_official=self.query_values['official'],
                            deprecated=self.query_values['deprecated'])

            print product_versions
            for pv in product_versions:
                print pv
                self._importable_products.append(pv)

        print self.importable_products
        self._product_widget = EntityTreeWidget(self.importable_products)
        self._product_widget.setFocusPolicy(QtCore.Qt.NoFocus)
コード例 #4
0
    def _process_ptask(self, ptask):

        print " PTASK: " + ptask.spec + " ..."

        ptask_type = ptask.type

        self._data.ptasks[ptask_type] += 1

        for ptask_ver in ptask.versions:

            #if ptask_ver.number > 2: continue  # speed up testing XXX

            print "  VER: " + ptask_ver.spec

            self._data.ptask_versions[ptask_type] += 1

            for sub in ptask_ver.subscriptions:

                print "   SUB: " + sub.product_version_spec

                sub_product = sub.product_version.product
                self._data.ptask_subscriptions[ptask_type] += 1

        for product in Product.list(ptask=ptask.spec):

            print "  PRODUCT: " + product.name_spec

            category = product.category
            self._data.ptask_products[ptask_type] += 1
            self._data.products[category] += 1

            for product_ver in product.versions:

                print "   PRODUCT VER: " + product_ver.spec

                self._data.ptask_product_versions[ptask_type] += 1
                self._data.product_versions[category] += 1

                for product_repr in product_ver.representations:

                    print "    PRODUCT REPR: " + product_repr.spec

                    file_type = product_repr.type
                    self._data.product_representations[category] += 1

                    if os.path.exists(product_repr.area.path):
                        for file_name in os.listdir(product_repr.area.path):
                            if file_name.endswith(file_type):
                                print "          FILE: " + file_name
                                self._data.product_repr_files[category] += 1
                                self._data.product_repr_files_by_type[
                                    file_type] += 1

        # recursively iterate over all children
        for child_ptask in ptask.children:
            self._process_ptask(child_ptask)
コード例 #5
0
ファイル: action.py プロジェクト: chippey/dpa-pipe
    def _process_ptask(self, ptask):

        print " PTASK: " + ptask.spec + " ..."

        ptask_type = ptask.type

        self._data.ptasks[ptask_type] += 1

        for ptask_ver in ptask.versions:

            #if ptask_ver.number > 2: continue  # speed up testing XXX

            print "  VER: " + ptask_ver.spec

            self._data.ptask_versions[ptask_type] += 1
            
            for sub in ptask_ver.subscriptions:

                print "   SUB: " + sub.product_version_spec

                sub_product = sub.product_version.product
                self._data.ptask_subscriptions[ptask_type] += 1 

        for product in Product.list(ptask=ptask.spec):

            print "  PRODUCT: " + product.name_spec

            category = product.category
            self._data.ptask_products[ptask_type] += 1
            self._data.products[category] += 1

            for product_ver in product.versions:

                print "   PRODUCT VER: " + product_ver.spec

                self._data.ptask_product_versions[ptask_type] += 1
                self._data.product_versions[category] += 1
        
                for product_repr in product_ver.representations:

                    print "    PRODUCT REPR: " + product_repr.spec
                    
                    file_type = product_repr.type
                    self._data.product_representations[category] += 1

                    if os.path.exists(product_repr.area.path):
                        for file_name in os.listdir(product_repr.area.path):
                            if file_name.endswith(file_type):
                                print "          FILE: " + file_name
                                self._data.product_repr_files[category] += 1
                                self._data.product_repr_files_by_type[file_type] += 1

        # recursively iterate over all children
        for child_ptask in ptask.children:
            self._process_ptask(child_ptask)
コード例 #6
0
ファイル: action.py プロジェクト: josh-t/dpa-pipe
    def _process_ptask(self, ptask):

        ptask_type = ptask.type

        self._data.ptasks[ptask_type] += 1

        for ptask_ver in ptask.versions:

            #if ptask_ver.number > 2: continue  # speed up testing XXX

            self._data.ptask_versions[ptask_type] += 1
            
            for sub in ptask_ver.subscriptions:

                sub_product = sub.product_version.product
                self._data.ptask_subscriptions[ptask_type] += 1 

        for product in Product.list(ptask=ptask.spec):

            category = product.category
            self._data.ptask_products[ptask_type] += 1
            self._data.products[category] += 1

            for product_ver in product.versions:

                self._data.ptask_product_versions[ptask_type] += 1
                self._data.product_versions[category] += 1
        
                for product_repr in product_ver.representations:

                    file_type = product_repr.type
                    self._data.product_representations[category] += 1

                    if os.path.exists(product_repr.area.path):
                        for file_name in os.listdir(product_repr.area.path):
                            if file_name.endswith(file_type):
                                self._data.product_repr_files[category] += 1
                                self._data.product_repr_files_by_type[file_type] += 1

        # recursively iterate over all children
        for child_ptask in ptask.children:
            self._process_ptask(child_ptask)
コード例 #7
0
ファイル: list.py プロジェクト: josh-t/dpa-pipe
def _get_products(wild_spec):

    ptask_spec = PTaskArea.current().spec
    full_spec = PTaskSpec.get(wild_spec, relative_to=ptask_spec)

    if PTaskSpec.WILDCARD in full_spec:

        search_str = ",".join(
            filter(None, full_spec.strip().split(PTaskSpec.WILDCARD))
        )

    # no wildcard, match all products under current location
    else:
        search_str = full_spec

    # XXX this is inefficient. need better filtering on the backend
    products = Product.list(search=search_str)

    matching_products = []

    # the rest api's search filter isn't that great. it doesn't maintain any
    # knowledge of order for the supplied filters. So, it will return products
    # that match all of the search terms, but not necessarily in the order
    # supplied. Do one more match against the returned products specs keeping
    # the order of the supplied wildcard spec. 

    regex_spec = "^" + \
        full_spec.replace(PTaskSpec.WILDCARD, "([\w:]+)?") + "$"

    regex_spec = re.compile(regex_spec)

    for product in products:
        if regex_spec.match(product.spec):
            matching_products.append(product)

    return matching_products
コード例 #8
0
def _get_products(wild_spec):

    ptask_spec = PTaskArea.current().spec
    full_spec = PTaskSpec.get(wild_spec, relative_to=ptask_spec)

    if PTaskSpec.WILDCARD in full_spec:

        search_str = ",".join(
            filter(None,
                   full_spec.strip().split(PTaskSpec.WILDCARD)))

    # no wildcard, match all products under current location
    else:
        search_str = full_spec

    # XXX this is inefficient. need better filtering on the backend
    products = Product.list(search=search_str)

    matching_products = []

    # the rest api's search filter isn't that great. it doesn't maintain any
    # knowledge of order for the supplied filters. So, it will return products
    # that match all of the search terms, but not necessarily in the order
    # supplied. Do one more match against the returned products specs keeping
    # the order of the supplied wildcard spec.

    regex_spec = "^" + \
        full_spec.replace(PTaskSpec.WILDCARD, "([\w=]+)?") + "$"

    regex_spec = re.compile(regex_spec)

    for product in products:
        if regex_spec.match(product.spec):
            matching_products.append(product)

    return matching_products
コード例 #9
0
    def export_confirm_page(self):

        if hasattr(self, '_export_confirm_page'):
            return self._export_confirm_page

        self._descriptions = defaultdict(dict)

        ptask_version = self.session.ptask_version
        ptask = ptask_version.ptask

        layout = QtGui.QVBoxLayout()

        note_lbl = QtGui.QLabel(
            "Describe the work you did on the entities being exported:   (required)"
        )
        self._note_edit = QtGui.QLineEdit()
        self._note_edit.setFocus()

        self._note_edit.textChanged.connect(
            lambda t: self._check_descriptions())

        layout.addWidget(note_lbl)
        layout.addWidget(self._note_edit)
        layout.addSpacing(5)

        products_layout = QtGui.QFormLayout()

        # get this ptask's products
        products = Product.list(ptask=ptask.spec)

        for entity_item in self.entity_widget.entity_items:

            entity = entity_item.entity

            existing_products = [
                p for p in products if p.name == entity.display_name
                and p.category == entity.category
            ]

            product_desc = QtGui.QLineEdit()
            if existing_products:
                product_desc.setText(existing_products[0].description)

            product_lbl = QtGui.QLabel(
                "<b>{n}</b>".format(n=entity.product_name))

            products_layout.addRow(product_lbl, product_desc)

            self._descriptions[entity]['label'] = product_lbl
            self._descriptions[entity]['widget'] = product_desc

            product_desc.textChanged.connect(
                lambda t: self._check_descriptions())

        products_widget = QtGui.QWidget()
        products_widget.setLayout(products_layout)

        scroll_area = QtGui.QScrollArea()
        scroll_area.setFocusPolicy(QtCore.Qt.NoFocus)
        scroll_area.setWidgetResizable(True)
        scroll_area.setWidget(products_widget)

        product_lbl = QtGui.QLabel(
            "Enter/update descriptions for the products:   (required)")
        product_lbl.setWordWrap(True)

        layout.addWidget(product_lbl)
        layout.addWidget(scroll_area)
        layout.addSpacing(5)

        self._publish_check = QtGui.QCheckBox("Publish all after Export")
        self._publish_check.setChecked(True)

        self._version_check = QtGui.QCheckBox("Version up after Publish")
        self._version_check.setChecked(True)

        # if publish gets toggled, update the version check accordingly
        self._publish_check.toggled.connect(
            lambda s: self._version_check.setEnabled(
                s) or self._version_check.setChecked(s))

        layout.addWidget(self._publish_check)
        layout.addWidget(self._version_check)
        layout.addSpacing(5)

        confirm_lbl = QtGui.QLabel("<b>Export to {p} v{v}?</b>".\
            format(p=ptask.spec, v=ptask_version.number))
        confirm_lbl.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(confirm_lbl)

        self._export_confirm_page = QtGui.QWizardPage()
        self._export_confirm_page.setTitle("Confirm")
        self._export_confirm_page.setSubTitle(
            "Describe and confirm the folowing exports :")
        self._export_confirm_page.setLayout(layout)

        return self._export_confirm_page
コード例 #10
0
ファイル: export.py プロジェクト: chippey/dpa-pipe
    def export_confirm_page(self):

        if hasattr(self, '_export_confirm_page'):
            return self._export_confirm_page

        self._descriptions = defaultdict(dict)

        ptask_version = self.session.ptask_version
        ptask = ptask_version.ptask

        layout = QtGui.QVBoxLayout()

        note_lbl = QtGui.QLabel(
            "Describe the work you did on the entities being exported:   (required)")
        self._note_edit = QtGui.QLineEdit()
        self._note_edit.setFocus()

        self._note_edit.textChanged.connect(
            lambda t: self._check_descriptions())

        layout.addWidget(note_lbl)
        layout.addWidget(self._note_edit)
        layout.addSpacing(5)

        products_layout = QtGui.QFormLayout()

        # get this ptask's products
        products = Product.list(ptask=ptask.spec)

        for entity_item in self.entity_widget.entity_items:

            entity = entity_item.entity

            existing_products = [p for p in products 
                if p.name == entity.display_name and 
                   p.category == entity.category]

            product_desc = QtGui.QLineEdit()
            if existing_products:
                product_desc.setText(existing_products[0].description)

            product_lbl = QtGui.QLabel("<b>{n}</b>".format(n=entity.product_name))
                
            products_layout.addRow(product_lbl, product_desc)

            self._descriptions[entity]['label'] = product_lbl
            self._descriptions[entity]['widget'] = product_desc

            product_desc.textChanged.connect(
                lambda t: self._check_descriptions())

        products_widget = QtGui.QWidget()
        products_widget.setLayout(products_layout)

        scroll_area = QtGui.QScrollArea()
        scroll_area.setFocusPolicy(QtCore.Qt.NoFocus)
        scroll_area.setWidgetResizable(True)
        scroll_area.setWidget(products_widget)

        product_lbl = QtGui.QLabel(
            "Enter/update descriptions for the products:   (required)")
        product_lbl.setWordWrap(True)

        layout.addWidget(product_lbl)
        layout.addWidget(scroll_area)
        layout.addSpacing(5)

        self._publish_check = QtGui.QCheckBox("Publish all after Export")
        self._publish_check.setChecked(True)

        self._version_check = QtGui.QCheckBox("Version up after Publish")
        self._version_check.setChecked(True)
        
        # if publish gets toggled, update the version check accordingly
        self._publish_check.toggled.connect(
            lambda s: self._version_check.setEnabled(s) or 
                      self._version_check.setChecked(s)
        )

        layout.addWidget(self._publish_check)
        layout.addWidget(self._version_check)
        layout.addSpacing(5)

        confirm_lbl = QtGui.QLabel("<b>Export to {p} v{v}?</b>".\
            format(p=ptask.spec, v=ptask_version.number))
        confirm_lbl.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(confirm_lbl)

        self._export_confirm_page = QtGui.QWizardPage()
        self._export_confirm_page.setTitle("Confirm")
        self._export_confirm_page.setSubTitle(
            "Describe and confirm the folowing exports :")
        self._export_confirm_page.setLayout(layout)

        return self._export_confirm_page