示例#1
0
    def OnExportLauncher(self, event=None):
        Logger.Debug(__name__, u'Export launcher ...')

        export = GetFileSaveDialog(GetMainWindow(), GT(u'Save Launcher'))

        if ShowDialog(export):
            target = export.GetPath()

            # Create a backup file
            # FIXME: Create backup files in WriteFile function?
            overwrite = False
            if os.path.isfile(target):
                backup = u'{}.backup'.format(target)
                shutil.copy(target, backup)
                overwrite = True

            try:
                self.ExportToFile(target)

                if overwrite:
                    os.remove(backup)

            except UnicodeEncodeError:
                detail1 = GT(
                    u'Unfortunately Debreate does not support unicode yet.')
                detail2 = GT(
                    u'Remove any non-ASCII characters from your project.')

                ShowErrorDialog(GT(u'Save failed'),
                                u'{}\n{}'.format(detail1, detail2),
                                title=GT(u'Unicode Error'))

                os.remove(target)
                # Restore from backup
                shutil.move(backup, target)
示例#2
0
	def Export(self, out_dir, executable=True, build=False):
		if not os.path.isdir(out_dir):
			Logger.Error(__name__, GT(u'Directory not available: {}'.format(out_dir)))

			return (ERR_DIR_NOT_AVAILABLE, __name__)

		if build:
			absolute_filename = ConcatPaths((out_dir, self.FileName))

		else:
			filename = u'{}-{}'.format(page_ids[self.Parent.GetId()].upper(), self.FileName)
			absolute_filename = ConcatPaths((out_dir, filename))

		script_text = u'{}\n\n{}'.format(self.GetShebang(), self.ScriptBody.GetValue())

		WriteFile(absolute_filename, script_text)

		if not os.path.isfile(absolute_filename):
			Logger.Error(__name__, GT(u'Could not write to file: {}'.format(absolute_filename)))

			return (ERR_FILE_WRITE, __name__)

		if executable:
			os.chmod(absolute_filename, 0755)

		return (0, None)
示例#3
0
    def OnMenuChangePage(self, event=None):
        page_id = None

        if event:
            page_id = event.GetId()

            Logger.Debug(__name__,
                         GT(u'Page ID from menu event: {}').format(page_id))

        else:
            for M in self.GetMenu(menuid.PAGE).GetMenuItems():
                if M.IsChecked():
                    page_id = M.GetId()

                    Logger.Debug(
                        __name__,
                        GT(u'Page ID from menu item: {}').format(page_id))

                    break

        if page_id == None:
            Logger.Error(__name__, GT(u'Could not get page ID'))

            return

        self.Wizard.ShowPage(page_id)
示例#4
0
    def Build(self, stage, target):
        completed_status = (0, GT(u'errors'))

        try:
            output = BuildDebPackage(stage, target)
            if output[0] == dbrerrno.SUCCESS:
                completed_status = (GAUGE_MAX, GT(u'finished'))

            else:
                self.build_error = (
                    GT(u'Could not build .deb package'),
                    GT(u'Is the staged directory formatted correctly?'),
                    stage,
                    output[1],
                )

        except:
            self.build_error = (
                GT(u'An unhandled error occured'),
                traceback.format_exc(),
            )

        self.timer.Stop()
        self.gauge.SetValue(completed_status[0])
        self.SetTitle(u'{} ({})'.format(self.title, completed_status[1]))
        self.Enable()
示例#5
0
	def __init__(self, parent):
		WizardPage.__init__(self, parent, pgid.GREETING)

		m1 = GT(u'Welcome to Debreate!')
		m2 = GT(u'Debreate aids in building packages for installation on Debian based systems. Use the arrows located in the top-right corner or the "Page" menu to navigate through the program. For some information on Debian packages use the reference links in the "Help" menu.')
		m3 = GT(u'For a video tutorial check the link below.')
		str_info = u'{}\n\n{}\n\n{}'.format(m1, m2, m3)

		# --- Information to be displayed about each mode
		txt_info = wx.StaticText(self, label=str_info)
		# Keep characters within the width of the window
		txt_info.Wrap(600)

		lnk_video = Hyperlink(self, wx.ID_ANY, GT(u'Building a Debian Package with Debreate'),
				u'http://www.youtube.com/watch?v=kx4D5eL6HKE')
		lnk_video.SetToolTipString(lnk_video.url)

		# *** Layout *** #

		lyt_info = wx.GridSizer()
		lyt_info.Add(txt_info, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL)

		lyt_main = BoxSizer(wx.VERTICAL)
		lyt_main.Add(lyt_info, 4, wx.ALIGN_CENTER|wx.ALL, 10)
		lyt_main.Add(lnk_video, 2, wx.ALIGN_CENTER)

		self.SetAutoLayout(True)
		self.SetSizer(lyt_main)
		self.Layout()
示例#6
0
    def __init__(self, parent):
        # TODO: Add to Gettext locale files
        WizardPage.__init__(self, parent, pgid.MAN)

        ## Override default label
        self.Label = GT(u'Manual Pages')

        self.Tabs = MultiTemplate(self, ManPage)

        self.Tabs.RenameButton(btnid.ADD, GT(u'Add Manual'))
        self.Tabs.RenameButton(btnid.RENAME, GT(u'Rename Manual'))
        self.Tabs.AddTabButton(GT(u'Switch Mode'), u'mode', btnid.MODE,
                               self.OnChangeMode)

        # FIXME: Call after new page added???
        SetPageToolTips(self)

        # *** Layout *** #

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.Add(self.Tabs, 1, wx.EXPAND | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
示例#7
0
    def OnBuildCreatePackage(self, stage, targetFile):
        Logger.Debug(__name__,
                     GT(u'Creating {} from {}').format(targetFile, stage))

        packager = GetExecutable(u'dpkg-deb')
        fakeroot = GetExecutable(u'fakeroot')

        if not fakeroot or not packager:
            return (dbrerrno.ENOENT, GT(u'Cannot run "fakeroot dpkg'))

        packager = os.path.basename(packager)

        Logger.Debug(__name__, GT(u'System packager: {}').format(packager))

        # DEBUG:
        cmd = u'{} {} -b "{}" "{}"'.format(fakeroot, packager, stage,
                                           targetFile)
        Logger.Debug(__name__, GT(u'Executing: {}').format(cmd))

        output = GetCommandOutput(fakeroot, (
            packager,
            u'-b',
            stage,
            targetFile,
        ))

        Logger.Debug(__name__, GT(u'Build output: {}').format(output))

        return output
示例#8
0
def LaunchFirstRun(debreate_app):
    FR_dialog = FirstRun()
    debreate_app.SetTopWindow(FR_dialog)
    FR_dialog.ShowModal()

    init_conf_code = InitializeConfig()

    Logger.Debug(
        __name__, u'Configuration initialized: {}'.format(
            init_conf_code == ConfCode.SUCCESS))

    if (init_conf_code !=
            ConfCode.SUCCESS) or (not os.path.isfile(default_config)):
        msg_l1 = GT(
            u'An error occurred trying to create the configuration file:')
        msg_l2 = GT(u'Please report this error to Debreate\'s developers')
        ShowErrorDialog(u'{} {}\n\n{}'.format(msg_l1, default_config, msg_l2))

        return init_conf_code

    FR_dialog.Destroy()

    # Delete first run dialog from memory
    del (FR_dialog)

    return init_conf_code
示例#9
0
文件: md5.py 项目: sshyran/debreate
def WriteMD5(stage_dir, parent=None):
    CMD_md5sum = GetExecutable(u'md5sum')

    # Show an error if the 'md5sum' command does not exist
    # This is only a failsafe & should never actually occur
    if not CMD_md5sum:
        if not parent:
            parent = GetMainWindow()

        md5_label = GetField(pgid.BUILD, chkid.MD5).GetLabel()

        err_msg1 = GT(u'The "md5sum" command was not found on the system.')
        err_msg2 = GT(u'Uncheck the "{}" box.').format(md5_label)
        err_msg3 = GT(
            u'Please report this error to one of the following addresses:')
        err_url1 = u'https://github.com/AntumDeluge/debreate/issues'
        err_url2 = u'https://sourceforge.net/p/debreate/bugs/'

        Logger.Error(
            __name__,
            u'{} {} {}\n\t{}\n\t{}'.format(err_msg1, err_msg2, err_msg3,
                                           err_url1, err_url2))

        md5_error = ErrorDialog(parent,
                                text=u'{}\n{}\n\n{}'.format(
                                    err_msg1, err_msg2, err_msg3))
        md5_error.AddURL(err_url1)
        md5_error.AddURL(err_url2)
        md5_error.ShowModal()

        return None

    temp_list = []
    md5_list = []  # Final list used to write the md5sum file
    for ROOT, DIRS, FILES in os.walk(stage_dir):
        # Ignore the 'DEBIAN' directory
        if os.path.basename(ROOT) == u'DEBIAN':
            continue

        for F in FILES:
            F = u'{}/{}'.format(ROOT, F)

            md5 = GetCommandOutput(CMD_md5sum, (u'-t', F))

            Logger.Debug(__name__,
                         u'WriteMD5: GetCommandOutput: {}'.format(md5))

            temp_list.append(md5)

    for item in temp_list:
        # Remove [stage_dir] from the path name in the md5sum so that it has a
        # true unix path
        # e.g., instead of "/myfolder_temp/usr/local/bin", "/usr/local/bin"
        sum_split = item.split(u'{}/'.format(stage_dir))
        sum_join = u''.join(sum_split)
        md5_list.append(sum_join)

    # Create the md5sums file in the "DEBIAN" directory
    return WriteFile(u'{}/DEBIAN/md5sums'.format(stage_dir),
                     u'{}\n'.format(u'\n'.join(md5_list)))
示例#10
0
 def OnHelpButton(self, event=None):
     label = self.GetCurrentPage().GetTitle()
     page_help = MarkdownDialog(self, title=GT(u'Help'), readonly=True)
     
     page_help.SetText(GT(u'Help information for page "{}"'.format(label)))
     
     ShowDialog(page_help)
示例#11
0
def GetFieldValue(page, field_id, field_type=wx.Window):
    if isinstance(page, int):
        page = GetWizard().GetPage(page)

    if not isinstance(page, wx.Window):
        # FIXME: Should have error id
        err_msg = GT(
            u'Page retrieved was not instance of a window/widget: Page name: {}'
        ).format(page.GetName())
        return ErrorTuple(1, err_msg)

    field = GetField(page, field_id)

    if isinstance(field, ErrorTuple):
        return field

    if isinstance(field, wx.TextCtrl):
        return field.GetValue()

    if isinstance(field, wx.Choice):
        return field.GetStringSelection()

    # FIXME: Should have error id
    err_msg = GT(u'Unrecognized field type: {} (ID: {})').format(
        type(field), field_id)
    return ErrorTuple(1, err_msg)
示例#12
0
    def OnTimerStop(self, event=None):
        Logger.Debug(__name__, u'OnTimerStop')

        if not self.timer.IsRunning():
            Logger.Debug(__name__, GT(u'Timer is stopped'))

        else:
            Logger.Debug(__name__, GT(u'Timer is running'))

        if self.build_error:
            error_lines = self.build_error[:-1]
            error_output = self.build_error[-1]

            ShowErrorDialog(error_lines, error_output, self)

            # Needs to be reset or error dialog will successively show
            self.build_error = None

            return

        msg_lines = (
            GT(u'Quick build complete'),
            self.input_target.GetValue(),
        )

        ShowMessageDialog(msg_lines, GT(u'Build Complete'), module=__name__)
示例#13
0
    def __init__(self, parent, panelClass, winId=wx.ID_ANY):
        BoxSizer.__init__(self, wx.VERTICAL)

        self.Panel = panelClass

        self.Tabs = Notebook(parent, winId)

        self.TabButtonIds = []

        # *** Event Handling *** #

        self.Tabs.Bind(EVT_AUINOTEBOOK_PAGE_CLOSED, self.OnTabClosed)

        # *** Layout *** #

        lyt_buttons = BoxSizer(wx.HORIZONTAL)

        self.Add(lyt_buttons, 0, wx.EXPAND)
        self.Add(self.Tabs, 1, wx.EXPAND)

        # *** Post-Layout Actions *** #

        self.AddButton(GT(u'Add Tab'), u'add', btnid.ADD, self.OnButtonAdd)
        self.AddTabButton(GT(u'Rename Tab'), u'rename', btnid.RENAME,
                          self.OnRenameTab)
示例#14
0
    def ProjectSaveAs(self):
        wildcards = (
            u'{} (.{})'.format(GT(u'Debreate project files'), PROJECT_ext),
            u'*.{}'.format(PROJECT_ext),
        )

        save_dialog = GetFileSaveDialog(self, GT(u'Save Debreate Project'),
                                        wildcards, PROJECT_ext)

        if ShowDialog(save_dialog):
            project_path = save_dialog.GetPath()
            project_filename = save_dialog.GetFilename()

            Logger.Debug(__name__,
                         GT(u'Project save path: {}').format(project_path))
            Logger.Debug(
                __name__,
                GT(u'Project save filename: {}').format(project_filename))

            saved = self.ProjectSave(project_path)
            if saved == dbrerrno.SUCCESS:
                self.ProjectSetDirty(False)

            return saved

        Logger.Debug(__name__, GT(u'Not saving project'))

        return dbrerrno.ECNCLD
示例#15
0
    def __init__(self, parent):
        WizardPage.__init__(self, parent, pgid.LAUNCHERS)

        ## Override default label
        self.Label = GT(u'Menu Launchers')

        self.IgnoreResetIds = [
            inputid.OTHER,
            listid.CAT,
        ]

        templates = MultiTemplate(self, LauncherTemplate, pnlid.TABS)

        templates.RenameButton(btnid.ADD, GT(u'Add Launcher'))
        templates.RenameButton(btnid.RENAME, GT(u'Rename Launcher'))

        SetPageToolTips(self)

        # *** Event Handling *** #

        wx.EVT_BUTTON(self, wx.ID_ADD, self.OnAddTab)

        # *** Layout *** #

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.Add(templates, 1, wx.EXPAND | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
示例#16
0
    def SetSummary(self, event=None):
        pg_scripts = GetPage(pgid.SCRIPTS)

        # Make sure the page is not destroyed so no error is thrown
        if self:
            # Set summary when "Build" page is shown
            # Get the file count
            files_total = GetPage(pgid.FILES).GetFileCount()
            f = GT(u'File Count')
            file_count = u'{}: {}'.format(f, files_total)

            # Scripts to make
            scripts_to_make = []
            scripts = ((u'preinst', pg_scripts.chk_preinst),
                       (u'postinst', pg_scripts.chk_postinst),
                       (u'prerm', pg_scripts.chk_prerm),
                       (u'postrm', pg_scripts.chk_postrm))

            for script in scripts:
                if script[1].IsChecked():
                    scripts_to_make.append(script[0])

            s = GT(u'Scripts')
            if len(scripts_to_make):
                scripts_to_make = u'{}: {}'.format(s,
                                                   u', '.join(scripts_to_make))

            else:
                scripts_to_make = u'{}: 0'.format(s)

            self.summary.SetValue(u'\n'.join((file_count, scripts_to_make)))
示例#17
0
    def SetCategory(self, event=None):
        try:
            ID = event.GetKeyCode()

        except AttributeError:
            ID = event.GetEventObject().GetId()

        cat = GetField(self, inputid.CAT).GetValue()
        cat = cat.split()
        cat = u''.join(cat)

        lst_categories = GetField(self, listid.CAT)

        if ID in (wx.ID_ADD, wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
            lst_categories.InsertStringItem(lst_categories.GetItemCount(), cat)

        elif ID in (wx.ID_REMOVE, wx.WXK_DELETE):
            if lst_categories.GetItemCount(
            ) and lst_categories.GetSelectedItemCount():
                cur_cat = lst_categories.GetFirstSelected()
                lst_categories.DeleteItem(cur_cat)

        elif ID == wx.ID_CLEAR:
            if lst_categories.GetItemCount():
                if ConfirmationDialog(
                        GetMainWindow(), GT(u'Confirm'),
                        GT(u'Clear categories?')).ShowModal() in (wx.ID_OK,
                                                                  wx.OK):
                    lst_categories.DeleteAllItems()

        if event:
            event.Skip()
示例#18
0
	def OnHelpButton(self, event=None):
		al_help = MarkdownDialog(self, title=GT(u'Auto-Link Help'))
		description = GT(u'Debreate offers an Auto-Link Executables feature. What this does is finds any executables in the Files section and creates a postinst script that will create soft links to them in the specified path. This is useful if you are installing executables to a directory that is not found in the system PATH but want to access it from the PATH. For example, if you install an executable "bar" to the directory "/usr/share/foo" in order to execute "bar" from a terminal you would have to type /usr/share/foo/bar. Auto-Link can be used to place a link to "bar" somewhere on the system path like "/usr/bin". Then all that needs to be typed is bar to execute the program. Auto-Link also creates a prerm script that will delete the link upon removing the package.')
		instructions = GT(u'How to use Auto-Link: Press the IMPORT button to import any executables from the Files section. Then press the GENERATE button. Post-Install and Pre-Remove scripts will be created that will place symbolic links to your executables in the path displayed above.')

		al_help.SetText(u'{}\n\n{}'.format(description, instructions))

		ShowDialog(al_help)
示例#19
0
 def __init__(self, parent, logFile):
     wx.Dialog.__init__(self, parent, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     
     self.SetIcon(APP_logo)
     
     self.LogFile = FileItem(logFile)
     self.SetTitle()
     
     self.LogPollThread = Thread(self.PollLogFile)
     
     self.DspLog = TextAreaPanel(self, style=wx.TE_READONLY)
     self.DspLog.font_size = 8
     self.DspLog.SetFont(GetMonospacedFont(self.DspLog.font_size))
     
     btn_open = CreateButton(self, btnid.BROWSE, GT(u'Open and Display Log File'), u'browse')
     btn_font = CreateButton(self, btnid.ZOOM, GT(u'Zoom Text'), u'zoom')
     btn_refresh = CreateButton(self, btnid.REFRESH, GT(u'Refresh'), u'refresh')
     btn_hide = CreateButton(self, btnid.CLOSE, GT(u'Hide'), u'hide')
     
     # *** Event Handling *** #
     
     EVT_REFRESH_LOG(self, wx.ID_ANY, self.OnLogTimestampChanged)
     
     wx.EVT_BUTTON(self, btnid.BROWSE, self.OnOpenLogFile)
     wx.EVT_BUTTON(self, btnid.ZOOM, self.OnChangeFont)
     wx.EVT_BUTTON(self, btnid.REFRESH, self.RefreshLog)
     wx.EVT_BUTTON(self, btnid.CLOSE, self.OnClose)
     
     wx.EVT_CLOSE(self, self.OnClose)
     wx.EVT_SHOW(self, self.OnShow)
     wx.EVT_SHOW(GetMainWindow(), self.OnShowMainWindow)
     
     # *** Layout *** #
     
     layout_btnF1 = wx.FlexGridSizer(cols=5)
     layout_btnF1.AddGrowableCol(1, 1)
     layout_btnF1.Add(btn_open, 0, wx.LEFT, 5)
     layout_btnF1.AddStretchSpacer(1)
     layout_btnF1.Add(btn_font, 0, wx.RIGHT, 5)
     layout_btnF1.Add(btn_refresh, 0, wx.RIGHT, 5)
     layout_btnF1.Add(btn_hide, 0, wx.RIGHT, 5)
     
     layout_mainV1 = BoxSizer(wx.VERTICAL)
     layout_mainV1.Add(self.DspLog, 1, wx.ALL|wx.EXPAND, 5)
     layout_mainV1.Add(layout_btnF1, 0, wx.EXPAND|wx.BOTTOM, 5)
     
     self.SetAutoLayout(True)
     self.SetSizer(layout_mainV1)
     self.Layout()
     
     self.SetMinSize(self.GetSize())
     
     self.SetSize(wx.Size(600, 600))
     
     self.AlignWithMainWindow()
     
     # Make sure log window is not shown at initialization
     self.Show(False)
示例#20
0
def ExecuteCommand(cmd, args=[], elevate=False, pword=wx.EmptyString):
    if elevate and pword.strip(u' \t\n') == wx.EmptyString:
        return (None, GT(u'Empty password'))

    CMD_sudo = GetExecutable(u'sudo')

    if not CMD_sudo:
        return (None, GT(u'Super user command (sudo) not available'))

    main_window = GetMainWindow()

    if isinstance(args, (unicode, str)):
        cmd_line = [
            args,
        ]

    else:
        cmd_line = list(args)

    cmd_line.insert(0, cmd)

    main_window.Enable(False)

    # FIXME: Better way to execute commands
    if elevate:
        cmd_line.insert(0, u'sudo')
        cmd_line.insert(1, u'-S')

        cmd_line = u' '.join(cmd_line)

        cmd_output = os.popen(u'echo {} | {}'.format(pword, cmd_line)).read()

    else:
        cmd_output = subprocess.Popen(cmd_line, stdout=PIPE, stderr=PIPE)
        cmd_output.wait()

    main_window.Enable(True)

    stdout = wx.EmptyString

    if isinstance(cmd_output, subprocess.Popen):
        if cmd_output.stdout:
            stdout = cmd_output.stdout

        if cmd_output.stderr:
            if stdout == wx.EmptyString:
                stdout = cmd_output.stderr

            else:
                stdout = u'{}\n{}'.format(stdout, cmd_output.stderr)

        returncode = cmd_output.returncode

    else:
        stdout = cmd_output
        returncode = 0

    return (returncode, stdout)
示例#21
0
    def __init__(self):
        wx.Dialog.__init__(self,
                           None,
                           wx.ID_ANY,
                           GT(u'Debreate First Run'),
                           size=(450, 300))

        m2 = GT(
            u'This message only displays on the first run, or if\nthe configuration file becomes corrupted.'
        )
        m3 = GT(u'The default configuration file will now be created.')
        m4 = GT(
            u'To delete this file, type the following command in a\nterminal:')

        message1 = GT(u'Thank you for using Debreate.')
        message1 = u'{}\n\n{}'.format(message1, m2)

        message2 = m3
        message2 = u'{}\n{}'.format(message2, m4)

        # Set the titlebar icon
        self.SetIcon(APP_logo)

        # Display a message to create a config file
        text1 = wx.StaticText(self, label=message1)
        text2 = wx.StaticText(self, label=message2)

        rm_cmd = wx.TextCtrl(self,
                             value=u'rm -f ~/.config/debreate/config',
                             style=wx.TE_READONLY | wx.BORDER_NONE)
        rm_cmd.SetBackgroundColour(self.BackgroundColour)

        layout_V1 = BoxSizer(wx.VERTICAL)
        layout_V1.Add(text1, 1)
        layout_V1.Add(text2, 1, wx.TOP, 15)
        layout_V1.Add(rm_cmd, 0, wx.EXPAND | wx.TOP, 10)

        # Show the Debreate icon
        icon = wx.StaticBitmap(self, bitmap=GetBitmap(u'logo', 64, u'icon'))

        # Button to confirm
        self.button_ok = wx.Button(self, wx.ID_OK)

        # Nice border
        self.border = wx.StaticBox(self, -1)
        border_box = wx.StaticBoxSizer(self.border, wx.HORIZONTAL)
        border_box.AddSpacer(10)
        border_box.Add(icon, 0, wx.ALIGN_CENTER)
        border_box.AddSpacer(10)
        border_box.Add(layout_V1, 1, wx.ALIGN_CENTER)

        # Set Layout
        sizer = BoxSizer(wx.VERTICAL)
        sizer.Add(border_box, 1, wx.EXPAND | lyt.PAD_LR, 5)
        sizer.Add(self.button_ok, 0, wx.ALIGN_RIGHT | lyt.PAD_RB | wx.TOP, 5)

        self.SetSizer(sizer)
        self.Layout()
示例#22
0
    def OnClearCategories(self, event=None):
        cats = GetField(self, listid.CAT)

        if cats.HasSelected():
            clear = ConfirmationDialog(GetMainWindow(), GT(u'Confirm'),
                                       GT(u'Clear categories?'))

            if clear.Confirmed():
                cats.Clear()
示例#23
0
    def OnClearCategories(self, event=None):
        cats = GetField(self, listid.CAT)

        if cats.GetItemCount():
            clear = ConfirmationDialog(GetMainWindow(), GT(u'Confirm'),
                                       GT(u'Clear categories?'))

            if clear.Confirmed():
                cats.DeleteAllItems()
示例#24
0
 def DestroyLicenseText(self):
     if not TextIsEmpty(self.dsp_copyright.GetValue()):
         warn_msg = GT(u'This will destroy all license text.')
         warn_msg = u'{}\n\n{}'.format(warn_msg, GT(u'Continue?'))
         
         if ConfirmationDialog(GetMainWindow(), text=warn_msg).ShowModal() not in (wx.ID_OK, wx.OK):
             return False
     
     return True
示例#25
0
    def OnBuildMD5Sum(self, stage):
        Logger.Debug(__name__, GT(u'Creating MD5sum file in {}').format(stage))

        WriteMD5(stage)

        return GT(u'md5sums file created: {}'.format(
            os.path.isfile(ConcatPaths((
                stage,
                u'DEBIAN/md5sums',
            )))))
示例#26
0
    def OnClearList(self, event=None):
        if self.GetCheckedCount():
            warn_dialog = wx.MessageDialog(
                self,
                GT(u'Clear Lintian overrides list?'),
                GT(u'Warning'),
                style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING)
            warn_dialog.CenterOnParent()

            if warn_dialog.ShowModal() == wx.ID_YES:
                self.check_list.Clear()
示例#27
0
	def ImportFromFile(self, filename):
		Logger.Debug(__name__, GT(u'Importing page info from {}').format(filename))

		if not os.path.isfile(filename):
			return dbrerrno.ENOENT

		files_data = ReadFile(filename, split=True)

		# Lines beginning with these characters will be ignored
		ignore_characters = (
			u'',
			u' ',
			u'#',
		)

		target = None
		targets_list = []

		for L in files_data:
			if not TextIsEmpty(L) and L[0] not in ignore_characters:
				if u'[' in L and u']' in L:
					target = L.split(u'[')[-1].split(u']')[0]
					continue

				if target:
					executable = (len(L) > 1 and L[-2:] == u' *')
					if executable:
						L = L[:-2]

					targets_list.append((target, L, executable))

		missing_files = []

		for T in targets_list:
			# FIXME: Create method in FileList class to retrieve all missing files
			if not os.path.exists(T[1]):
				missing_files.append(T[1])

			source_file = os.path.basename(T[1])
			source_dir = os.path.dirname(T[1])

			self.lst_files.AddFile(source_file, source_dir, T[0], executable=T[2])

		if len(missing_files):
			main_window = GetMainWindow()

			err_line1 = GT(u'The following files/folders are missing from the filesystem.')
			err_line2 = GT(u'They will be highlighted on the Files page.')
			DetailedMessageDialog(main_window, title=GT(u'Warning'), icon=ICON_ERROR,
					text=u'\n'.join((err_line1, err_line2)),
					details=u'\n'.join(missing_files)).ShowModal()

		return 0
示例#28
0
 def OnOpenLogFile(self, event=None):
     log_select = GetFileOpenDialog(self, GT(u'Open Log'), directory=PATH_logs)
     
     if ShowDialog(log_select):
         logFile = log_select.GetPath()
         
         if os.path.isfile(logFile):
             self.SetLogFile(logFile)
             
             return
         
         ShowErrorDialog(u'{}: {}'.format(GT(u'File does not exist'), logFile),
                 parent=self)
示例#29
0
 def __init__(self,
              parent,
              title=GT(u'Error'),
              text=GT(u'An error has occurred'),
              details=wx.EmptyString,
              linewrap=0):
     DetailedMessageDialog.__init__(self,
                                    parent,
                                    title,
                                    ICON_ERROR,
                                    text,
                                    details,
                                    linewrap=linewrap)
示例#30
0
    def __init__(self, parent):
        WizardPage.__init__(self, parent, pgid.GREETING)

        # Bypass checking this page for build
        self.prebuild_check = False

        m1 = GT(u'Welcome to Debreate!')
        m2 = GT(
            u'Debreate aids in building packages for installation on Debian based systems. Use the arrows located in the top-right corner or the "Page" menu to navigate through the program. For some information on Debian packages use the reference links in the "Help" menu.'
        )
        m3 = GT(u'For a video tutorial check the link below.')
        txt_bin = u'{}\n\n{}\n\n{}'.format(m1, m2, m3)
        txt_src = u'This mode is not fully functional'
        txt_upd = u'This mode is not fully functional'

        self.mode_info = (
            (
                u'Build Package from Precompiled Files',
                txt_bin,
            ),
            (
                u'Build Debian Source Package',
                txt_src,
            ),
            (
                u'Update a Package',
                txt_upd,
            ),
        )

        # --- Information to be displayed about each mode
        self.txt_info = wx.StaticText(self)

        lnk_video = Hyperlink(self, wx.ID_ANY,
                              GT(u'Building a Debian Package with Debreate'),
                              u'http://www.youtube.com/watch?v=kx4D5eL6HKE')
        lnk_video.SetToolTipString(lnk_video.url)

        # *** Layout *** #

        lyt_info = wx.GridSizer()
        lyt_info.Add(self.txt_info, 1,
                     wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.Add(lyt_info, 4, wx.ALIGN_CENTER | wx.ALL, 10)
        lyt_main.Add(lnk_video, 2, wx.ALIGN_CENTER)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
示例#31
0
	def BuildPrep(self):
		wizard = GetWizard()
		prep_ids = []

		pages = wizard.GetAllPages()

		for P in pages:
			if P.prebuild_check:
				Logger.Debug(__name__, GT(u'Pre-build check for page "{}"'.format(P.GetName())))
				prep_ids.append(P.GetId())

		try:
			main_window = GetMainWindow()

			# List of page IDs to process during build
			pg_build_ids = []

			steps_count = len(prep_ids)
			current_step = 0

			msg_label1 = GT(u'Prepping page "{}"')
			msg_label2 = GT(u'Step {}/{}')
			msg_label = u'{} ({})'.format(msg_label1, msg_label2)

			prep_progress = ProgressDialog(main_window, GT(u'Preparing Build'),
					msg_label2.format(current_step, steps_count), maximum=steps_count,
					style=PD_DEFAULT_STYLE|wx.PD_CAN_ABORT)

			for P in pages:
				if prep_progress.WasCancelled():
					break

				p_id = P.GetId()
				p_label = P.GetTitle()

				if p_id in prep_ids:
					Logger.Debug(__name__, msg_label.format(p_label, current_step+1, steps_count))

					wx.Yield()
					prep_progress.Update(current_step, msg_label.format(p_label, current_step+1, steps_count))

					if P.IsOkay():
						pg_build_ids.append(p_id)

					current_step += 1

			if not prep_progress.WasCancelled():
				wx.Yield()
				prep_progress.Update(current_step, GT(u'Prepping finished'))

				# Show finished dialog for short period
				time.sleep(1)

			prep_progress.Destroy()

			return pg_build_ids

		except:
			prep_progress.Destroy()

			ShowErrorDialog(GT(u'Error occurred during pre-build'), traceback.format_exc())

		return None