Exemple #1
0
	def GetTarget(self):
		if FieldEnabled(self.ti_target):
			return self.ti_target.GetValue()

		for target in self.grp_targets:
			if target.GetId() != inputid.CUSTOM and target.GetValue():
				return target.GetLabel()
Exemple #2
0
    def Destroy(self, *args, **kwargs):
        # Re-enable parent/main window if previously disabled
        # ???: May not be necessary
        main_window = GetMainWindow()

        if not FieldEnabled(main_window):
            Logger.Debug(__name__, u'Re-enabling main window')

            main_window.Enable()

        if self.Parent and not FieldEnabled(self.Parent):
            Logger.Debug(__name__, u'Re-enabling parent')

            self.Parent.Enable()

        if wx.MAJOR_VERSION < 3:
            self.EndModal(0)

        return wx.ProgressDialog.Destroy(self, *args, **kwargs)
Exemple #3
0
def SetPageToolTips(parent, page_id=None):
	control_list = []

	if not page_id:
		page_id = parent.GetId()

	# Recursively set tooltips for children
	for FIELD in parent.GetChildren():
		control_list.append(FIELD)

		sub_children = FIELD.GetChildren()
		if sub_children:
			SetPageToolTips(FIELD, page_id)

	if page_id in TT_pages:
		for FIELD in control_list:
			tooltip = None

			# Use ID first
			field_id = FIELD.GetId()
			if field_id in TT_pages[page_id]:
				tooltip = TT_pages[page_id][field_id]

			else:
				try:
					name = FIELD.tt_name.lower()

				except AttributeError:
					try:
						name = FIELD.GetName().lower()

					except AttributeError:
						Logger.Warn(__name__, u'Object has no name, not setting tooltip: {}'.format(type(FIELD)))

						continue

				required = False
				if name:
					if u'*' in name[-2:]:
						required = True

					# The » character causes a different tooltip to be set for disabled fields
					if u'»' in name[-2:] and not FieldEnabled(FIELD):
						name = u'{}_disabled'.format(name)

					name = name.replace(u'*', u'')
					name = name.replace(u'»', u'')

				if name in TT_pages[page_id]:
					tooltip = TT_pages[page_id][name]

			if tooltip:
				SetToolTip(tooltip, FIELD, required)
Exemple #4
0
    def OnBuild(self, event=None):
        # Build preparation
        ret_code, build_prep = self.BuildPrep()

        if ret_code == dbrerrno.ECNCLD:
            return

        if ret_code == dbrerrno.FEMPTY:
            err_dia = DetailedMessageDialog(
                GetMainWindow(),
                GT(u'Cannot Continue'),
                ICON_EXCLAMATION,
                text=u'{}\n{}'.format(
                    GT(u'One of the required fields is empty:'), build_prep))
            err_dia.ShowModal()
            err_dia.Destroy()

            return

        if ret_code == dbrerrno.SUCCESS:
            task_list, build_path, filename = build_prep

            # Actual build
            ret_code, result = self.Build(task_list, build_path, filename)

            # FIXME: Check .deb package timestamp to confirm build success
            if ret_code == dbrerrno.SUCCESS:
                DetailedMessageDialog(
                    GetMainWindow(),
                    GT(u'Success'),
                    ICON_INFORMATION,
                    text=GT(u'Package created successfully')).ShowModal()

                # Installing the package
                if FieldEnabled(
                        self.chk_install) and self.chk_install.GetValue():
                    self.InstallPackage(result)

                return

            if result:
                ShowErrorDialog(GT(u'Package build failed'), result)

            else:
                ShowErrorDialog(GT(u'Package build failed with unknown error'))

            return

        if build_prep:
            ShowErrorDialog(GT(u'Build preparation failed'), build_prep)

        else:
            ShowErrorDialog(GT(u'Build preparation failed with unknown error'))
Exemple #5
0
    def OnCatSelect(self, event=None):
        btn_cat_clr = GetField(self, wx.ID_CLEAR)
        lst_cat = GetField(self, listid.CAT)

        if btn_cat_clr and lst_cat:
            if FieldEnabled(btn_cat_clr):
                if not lst_cat.HasSelected():
                    btn_cat_clr.Disable()

            else:
                if lst_cat.HasSelected():
                    btn_cat_clr.Enable()
Exemple #6
0
 def ShowPage(self, pageId):
     for p in self.Pages:
         if p.GetId() != pageId:
             p.Hide()
         
         else:
             p.Show()
             self.txt_title.SetLabel(p.GetTitle())
     
     if pageId == self.ID_FIRST:
         self.btn_prev.Enable(False)
     
     elif not FieldEnabled(self.btn_prev):
         self.btn_prev.Enable(True)
     
     if pageId == self.ID_LAST:
         self.btn_next.Enable(False)
     
     elif not FieldEnabled(self.btn_next):
         self.btn_next.Enable(True)
     
     self.Layout()
     
     wx.PostEvent(GetMainWindow(), ChangePageEvent(0))
Exemple #7
0
    def OnOtherRemove(self, event=None):
        pnl_other = GetField(self, inputid.OTHER)

        # FIXME: Show confirmation dialog

        if pnl_other:
            if pnl_other.HasSelected():
                remove = ConfirmationDialog(
                    GetMainWindow(), GT(u'Custom Fields'),
                    GT(u'Remove all selected custom fields?'))

                if remove.Confirmed():
                    pnl_other.RemoveSelected()

            btn_remove = GetField(self, wx.ID_REMOVE)

            if btn_remove and FieldEnabled(btn_remove):
                btn_remove.Enable(pnl_other.HasSelected())
Exemple #8
0
    def InitDefaultSettings(self):
        self.build_options = []

        option_list = (
            (
                self.chk_md5,
                GetExecutable(u'md5sum'),
            ),
            (
                self.chk_strip,
                GetExecutable(u'strip'),
            ),
            (
                self.chk_rmstage,
                True,
            ),
            (
                self.chk_lint,
                GetExecutable(u'lintian'),
            ),
            (
                self.chk_install,
                GetSystemInstaller(),
            ),
        )

        for option, command in option_list:
            # FIXME: Commands should be updated globally
            if not isinstance(command, bool):
                command = CommandExists(command)

            option.Enable(bool(command))
            option.SetValue(FieldEnabled(option) and option.Default)

            if bool(command):
                self.build_options.append(option)
Exemple #9
0
 def SetValue(self, value):
     if FieldEnabled(self):
         return wx.CheckBox.SetValue(self, value)
Exemple #10
0
 def GetValue(self):
     if not FieldEnabled(self):
         return False
     
     return wx.CheckBox.GetValue(self)
Exemple #11
0
    def NotifyMainWindow(self, event=None):
        if event:
            event.Skip(True)

        if AppInitialized() and FieldEnabled(self):
            GetMainWindow().OnProjectChanged(event)
Exemple #12
0
    def GetCtrlInfo(self):
        pg_depends = GetPage(pgid.DEPENDS)

        ctrl_list = []
        synopsis = None
        description = None
        # Email will be set if maintainer changed to True
        maintainer = False

        # Text input fields
        for field in self.grp_input:
            field_name = field.GetName().title()
            field_value = field.GetValue()

            if FieldEnabled(field) and not TextIsEmpty(field_value):
                Logger.Debug(__name__,
                             GT(u'Exporting {} field').format(field_name))

                # Strip leading & trailing spaces, tabs, & newlines
                field_value = field_value.strip(u' \t\n')

                if field_name == u'Synopsis':
                    synopsis = u'{}: {}'.format(u'Description', field_value)
                    continue

                if field_name == u'Description':
                    description = field_value.split(u'\n')
                    for line_index in range(len(description)):
                        # Remove trailing whitespace
                        description[line_index] = description[
                            line_index].rstrip()

                        if TextIsEmpty(description[line_index]):
                            # Empty lines are formatted with one space indentation & a period
                            description[line_index] = u' .'

                        else:
                            # All other lines are formatted with one space indentation
                            description[line_index] = u' {}'.format(
                                description[line_index])

                    description = u'\n'.join(description)
                    continue

                if field_name in (u'Package', u'Version'):
                    # Don't allow whitespace in package name & version
                    ctrl_list.append(u'{}: {}'.format(
                        field_name, u'-'.join(field_value.split(u' '))))
                    continue

                if field_name == u'Email':
                    if maintainer and ctrl_list:
                        # Append email to end of maintainer string
                        for ctrl_index in range(len(ctrl_list)):
                            if ctrl_list[ctrl_index].startswith(
                                    u'Maintainer: '):
                                Logger.Debug(__name__, u'Found maintainer')
                                ctrl_list[ctrl_index] = u'{} <{}>'.format(
                                    ctrl_list[ctrl_index], field_value)
                                break

                    continue

                # Don't use 'continue' on this statement
                if field_name == u'Maintainer':
                    maintainer = True

                # The rest of the fields
                ctrl_list.append(u'{}: {}'.format(field_name, field_value))

        # Selection box fields
        for field in self.grp_select:
            field_name = field.GetName().title()
            field_value = field.GetStringSelection()

            if FieldEnabled(field) and not TextIsEmpty(field_value):
                Logger.Debug(__name__,
                             GT(u'Exporting {} field').format(field_name))

                # Strip leading & trailing spaces, tabs, & newlines
                field_value = field_value.strip(u' \t\n')

                ctrl_list.append(u'{}: {}'.format(field_name, field_value))

        if self.chk_essential.GetValue():
            ctrl_list.append(u'Essential: yes')

        # Dependencies & conflicts
        dep_list = []  # Depends
        pre_list = []  # Pre-Depends
        rec_list = []  # Recommends
        sug_list = []  # Suggests
        enh_list = []  # Enhances
        con_list = []  # Conflicts
        rep_list = []  # Replaces
        brk_list = []  # Breaks

        all_deps = {
            u'Depends': dep_list,
            u'Pre-Depends': pre_list,
            u'Recommends': rec_list,
            u'Suggests': sug_list,
            u'Enhances': enh_list,
            u'Conflicts': con_list,
            u'Replaces': rep_list,
            u'Breaks': brk_list,
        }

        # Get amount of items to add
        dep_area = GetField(pg_depends, inputid.LIST)
        dep_count = dep_area.GetItemCount()
        count = 0
        while count < dep_count:
            # Get each item from dependencies page
            dep_type = dep_area.GetItem(count, 0).GetText()
            dep_val = dep_area.GetItem(count, 1).GetText()
            for item in all_deps:
                if dep_type == item:
                    all_deps[item].append(dep_val)

            count += 1

        for item in all_deps:
            if len(all_deps[item]) != 0:
                ctrl_list.append(u'{}: {}'.format(item,
                                                  u', '.join(all_deps[item])))

        if synopsis:
            ctrl_list.append(synopsis)

            # Long description is only added if synopsis is not empty
            if description:
                ctrl_list.append(description)

        # dpkg requires empty newline at end of file
        return u'\n'.join(ctrl_list).strip(u'\n') + u'\n'
Exemple #13
0
	def IsRequired(self):
		if FieldEnabled(self) and self.Required:
			return True

		return False
Exemple #14
0
 def IsEnabled(self):
     return FieldEnabled(self.ScriptBody)