Beispiel #1
0
    def delete(self, postid=''):
        if not postid:
            index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
            if index == -1:
                common.showmessage(self.mainframe, tr('You should select on entry first!'))
                return
            filename = self.data[index]
            tree = Tree()
            tree.read_from_xml(file(filename).read())
            data = tree['entry']

            postid = data['postid']

        common.setmessage(self.mainframe, tr('Deleting entry...'))
        site = self.pref.blog_sites_info[self.pref.blog_sites[self.cmbSite.GetSelection()]]
        try:
            server = xmlrpclib.ServerProxy(site['url'])
            result = server.blogger.deletePost('', postid, site['user'], site['password'], False)
            if result:
                common.showmessage(self.mainframe, tr('Delete is successful!'))
                self.list.DeleteItem(index)
            else:
                common.showerror(self.mainframe, tr('Delete error!'))

        except Exception, msg:
            error.traceback()
            common.showerror(self.mainframe, msg)
    def OnOK(self, event):
        for v, flag in self.list.GetValue():
            self.state[v[0]] = flag
        text = file(self.mainframe.plugin_initfile).read()
        pos1 = text.find('from')
        pos2 = text.find('import')
        pos = min([pos1, pos2])
        if pos:
            text = text[:pos]
        file(self.mainframe.plugin_initfile,
             'w').write(text +
                        "from modules.Debug import error\nflag=False\n" +
                        '\n'.join([
                            """
try:
    import %s
except:
    error.traceback()
    flag = True
""" % s for s in self.plugins if self.state[s]
                        ]) + """
if flag:
    raise Exception
""")
        self.copy_mo()
        common.showmessage(
            self,
            tr("If you changed plugins selection, you should restart again"))
        event.Skip()
Beispiel #3
0
    def delete(self, postid=''):
        if not postid:
            index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
            if index == -1:
                common.showmessage(self.mainframe, tr('You should select on entry first!'))
                return
            filename = self.data[index]
            tree = Tree()
            tree.read_from_xml(file(filename).read())
            data = tree['entry']

            postid = data['postid']

        common.setmessage(self.mainframe, tr('Deleting entry...'))
        site = self.pref.blog_sites_info[self.pref.blog_sites[self.cmbSite.GetSelection()]]
        try:
            server = xmlrpclib.ServerProxy(site['url'])
            result = server.blogger.deletePost('', postid, site['user'], site['password'], False)
            if result:
                common.showmessage(self.mainframe, tr('Delete is successful!'))
                self.list.DeleteItem(index)
            else:
                common.showerror(self.mainframe, tr('Delete error!'))

        except Exception, msg:
            error.traceback()
            common.showerror(self.mainframe, msg)
Beispiel #4
0
 def _f():
     if version > Version.version:
         dlg = UpdateDialog(Globals.mainframe, version)
         dlg.ShowModal()
         dlg.Destroy()
     else:
         if force:
             common.showmessage(tr("There is no newer version."))
Beispiel #5
0
 def _f():
     if version > Version.version:
         dlg = UpdateDialog(Globals.mainframe, version)
         dlg.ShowModal()
         dlg.Destroy()
     else:
         if force:
             common.showmessage(tr("There is no newer version."))
Beispiel #6
0
 def login(self):
     try:
         server = xmlrpclib.ServerProxy(self.obj_ID_URL.GetValue())
         result = server.metaWeblog.getCategories('', self.obj_ID_USER.GetValue(), self.obj_ID_PASSWORD.GetValue())
         if result:
             self.categories = result
             common.showmessage(self.mainframe, tr('Login is successful!'))
         else:
             self.categories = {}
             common.showerror(self.maiframe, tr('Login is faild!'))
         return True
     except Exception, msg:
         error.traceback()
         common.showerror(self.mainframe, msg)
         return False
Beispiel #7
0
 def login(self):
     try:
         server = xmlrpclib.ServerProxy(self.obj_ID_URL.GetValue())
         result = server.metaWeblog.getCategories('', self.obj_ID_USER.GetValue(), self.obj_ID_PASSWORD.GetValue())
         if result:
             self.categories = result
             common.showmessage(self.mainframe, tr('Login is successful!'))
         else:
             self.categories = {}
             common.showerror(self.maiframe, tr('Login is faild!'))
         return True
     except Exception, msg:
         error.traceback()
         common.showerror(self.mainframe, msg)
         return False
Beispiel #8
0
def RunCommand(win, command, redirect=True, hide=False, input_decorator=None,
        callback=None):
    """replace $file = current document filename"""
    global input_appendtext

    #test if there is already a running process
    if hasattr(win, 'messagewindow') and win.messagewindow and win.messagewindow.process:
        common.showmessage(win, tr("The last process didn't stop yet. Please stop it and try again."))
        return
    if input_decorator:
        input_appendtext = input_decorator(appendtext)
    else:
        input_appendtext = appendtext
    if redirect:
        win.createMessageWindow()
        win.panel.showPage(tr('Messages'))
        win.callplugin('start_run', win, win.messagewindow)
        win.messagewindow.SetReadOnly(0)
        win.messagewindow.callback = callback
        appendtext(win.messagewindow, '> ' + command + '\n')

        win.messagewindow.editpoint = win.messagewindow.GetLength()
        win.messagewindow.writeposition = win.messagewindow.GetLength()
        win.SetStatusText(tr("Running "), 0)
        try:
            win.messagewindow.process = wx.Process(win)
            win.messagewindow.process.Redirect()
            if wx.Platform == '__WXMSW__':
                if hide == False:
                    win.messagewindow.pid = wx.Execute(command, wx.EXEC_ASYNC|wx.EXEC_NOHIDE, win.messagewindow.process)
                else:
                    win.messagewindow.pid = wx.Execute(command, wx.EXEC_ASYNC, win.messagewindow.process)
            else:
                win.messagewindow.pid = wx.Execute(command, wx.EXEC_ASYNC|wx.EXEC_MAKE_GROUP_LEADER, win.messagewindow.process)
            if hasattr(win.messagewindow, 'inputstream') and win.messagewindow.inputstream:
                win.messagewindow.inputstream.close()
            win.messagewindow.inputstream = win.messagewindow.process.GetInputStream()
            win.messagewindow.outputstream = win.messagewindow.process.GetOutputStream()
            win.messagewindow.errorstream = win.messagewindow.process.GetErrorStream()
        except:
            win.messagewindow.process = None
            dlg = wx.MessageDialog(win, tr("There are some issues with running the program.\nPlease run it in the shell.") ,
                "Error", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command, wx.EXEC_ASYNC)
Beispiel #9
0
 def OnRemove(self, event):
     lastitem = -1
     item = self.list.GetNextItem(lastitem, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
     while item > -1:
         if self.getItemText(item)[0] == tr('default'):
             common.showmessage(self, tr("You can't delete the default interpreter!"))
             return
         dlg = wx.MessageDialog(self, tr("Do you realy want to delete current item [%s]?") % self.getItemText(item)[0],
                 tr("Deleting Interpreter"), wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
         answer = dlg.ShowModal()
         if answer == wx.ID_YES:
             self.list.DeleteItem(item)
         elif answer == wx.ID_NO:
             lastitem = item
         else:
             return
         item = self.list.GetNextItem(lastitem, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
Beispiel #10
0
def OnConvertTextile2Html(win, event):
    try:
        import textile
    except:
        error.traceback()
        common.showmessage(win, tr("You should install textile module first!"))

    class MyTextiler(textile.Textiler):
        def process(self, head_offset=textile.HEAD_OFFSET):
            self.head_offset = head_offset

            # Process each block.
            self.blocks = self.split_text()

            text = []
            for [function, captures] in self.blocks:
                text.append(function(**captures))

            text = '\n\n'.join(text)

            # Add titles to footnotes.
            text = self.footnotes(text)

#           # Convert to desired output.
#           if encoding != 'unicode':
#               text = unicode(text, encoding)
#           if output != 'unicode':
#               text = text.encode(output, 'xmlcharrefreplace')

            return text
    try:
        text = win.document.GetSelectedText()
        t = MyTextiler(text)
        otext = t.process()

        output_text(win, otext)
    except Exception, msg:
        error.traceback()
        common.showerror(win, msg)
Beispiel #11
0
    def OnOK(self, event):
        for v, flag in self.list.GetValue():
            self.state[v[0]] = flag
        text = file(self.mainframe.plugin_initfile).read()
        pos1 = text.find('from')
        pos2 = text.find('import')
        pos = min([pos1, pos2])
        if pos:
            text = text[:pos]
        file(self.mainframe.plugin_initfile, 'w').write(text + "from modules.Debug import error\nflag=False\n" + '\n'.join(["""
try:
    import %s
except:
    error.traceback()
    flag = True
""" % s for s in self.plugins if self.state[s]]) + """
if flag:
    raise Exception
""")
        self.copy_mo()
        common.showmessage(self, tr("If you changed plugins selection, you should restart again"))
        event.Skip()
Beispiel #12
0
 def OnRemove(self, event):
     lastitem = -1
     item = self.list.GetNextItem(lastitem, wx.LIST_NEXT_ALL,
                                  wx.LIST_STATE_SELECTED)
     while item > -1:
         if self.getItemText(item)[0] == tr('default'):
             common.showmessage(
                 self, tr("You can't delete the default interpreter!"))
             return
         dlg = wx.MessageDialog(
             self,
             tr("Do you realy want to delete current item [%s]?") %
             self.getItemText(item)[0], tr("Deleting Interpreter"),
             wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
         answer = dlg.ShowModal()
         if answer == wx.ID_YES:
             self.list.DeleteItem(item)
         elif answer == wx.ID_NO:
             lastitem = item
         else:
             return
         item = self.list.GetNextItem(lastitem, wx.LIST_NEXT_ALL,
                                      wx.LIST_STATE_SELECTED)
Beispiel #13
0
    def OnEnter(self, event):
        i = self.tree.GetPyData(event.GetItem())
        if not i: return
        x = self.items[i]
        mod, path = importfile(x)
        datafile = ''
        if x.options.datafile == 'open':
            from modules import FileDialog
            datafile = FileDialog.openfiledlg(tr('Open'), tr('Input a data file:'))
        old_path = os.getcwd()
        try:
            os.chdir(path)
            try:
                if x.options.execute == 'wizard':
                    from modules.EasyGuider import EasyCommander
                    easy = EasyCommander.EasyCommander(parent=self, easyfile=mod, inline=True, cmdoption='', outputencoding=x.options.encoding)
                    easy.inipickle = datafile
                    if x.options.output == 'inline':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run():
                            self.mainframe.document.AddText(common.decode_string(buf.getvalue(), x.options.encoding))
                    elif x.options.output == 'save':
                        from modules import FileDialog
                        datafile = FileDialog.savefiledlg(tr('Save'), tr('Input saving filename:'))
                        if datafile:
                            easy.outputfile = datafile
                            if easy.run():
                                self.mainframe.editctrl.new(datafile, encoding=x.options.encoding)
                    elif x.options.output == 'newfile':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run():
                            document = self.mainframe.editctrl.new()
                            document.SetText(common.decode_string(buf.getvalue(), x.options.encoding))
                    else:
                        if easy.run():
                            common.showmessage(self, tr("Completed!"))
                elif x.options.execute == 'program':
                    easy = mod
                    easy.datafile = datafile
                    if x.options.output == 'inline':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run(self.mainframe, x):
                            self.mainframe.document.AddText(common.decode_string(buf.getvalue(), x.options.encoding))
                    elif x.options.output == 'save':
                        from modules import FileDialog
                        datafile = FileDialog.savefiledlg(tr('Save'), tr('Input saving filename:'))
                        if datafile:
                            easy.outputfile = datafile
                            if easy.run(self.mainframe, x):
                                self.mainframe.editctrl.new(datafile, encoding=x.options.encoding)
                    elif x.options.output == 'newfile':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run(self.mainframe, x):
                            document = self.mainframe.editctrl.new()
                            document.SetText(common.decode_string(buf.getvalue(), x.options.encoding))
                    else:
                        if easy.run(self.mainframe, x):
                            common.showmessage(self, tr("Completed!"))
            except:
                error.traceback()
                common.showerror(self, tr("There is something wrong, see the error.log!"))
        finally:
            os.chdir(old_path)

        if path:
            del sys.path[0]
Beispiel #14
0
    def OnEnter(self, event):
        i = self.tree.GetPyData(event.GetItem())
        if not i: return
        x = self.items[i]
        mod, path = importfile(x)
        datafile = ''
        if x.options.datafile == 'open':
            from modules import FileDialog
            datafile = FileDialog.openfiledlg(tr('Open'),
                                              tr('Input a data file:'))
        old_path = os.getcwd()
        try:
            os.chdir(path)
            try:
                if x.options.execute == 'wizard':
                    from modules.EasyGuider import EasyCommander
                    easy = EasyCommander.EasyCommander(
                        parent=self,
                        easyfile=mod,
                        inline=True,
                        cmdoption='',
                        outputencoding=x.options.encoding)
                    easy.inipickle = datafile
                    if x.options.output == 'inline':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run():
                            self.mainframe.document.AddText(
                                common.decode_string(buf.getvalue(),
                                                     x.options.encoding))
                    elif x.options.output == 'save':
                        from modules import FileDialog
                        datafile = FileDialog.savefiledlg(
                            tr('Save'), tr('Input saving filename:'))
                        if datafile:
                            easy.outputfile = datafile
                            if easy.run():
                                self.mainframe.editctrl.new(
                                    datafile, encoding=x.options.encoding)
                    elif x.options.output == 'newfile':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run():
                            document = self.mainframe.editctrl.new()
                            document.SetText(
                                common.decode_string(buf.getvalue(),
                                                     x.options.encoding))
                    else:
                        if easy.run():
                            common.showmessage(self, tr("Completed!"))
                elif x.options.execute == 'program':
                    easy = mod
                    easy.datafile = datafile
                    if x.options.output == 'inline':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run(self.mainframe, x):
                            self.mainframe.document.AddText(
                                common.decode_string(buf.getvalue(),
                                                     x.options.encoding))
                    elif x.options.output == 'save':
                        from modules import FileDialog
                        datafile = FileDialog.savefiledlg(
                            tr('Save'), tr('Input saving filename:'))
                        if datafile:
                            easy.outputfile = datafile
                            if easy.run(self.mainframe, x):
                                self.mainframe.editctrl.new(
                                    datafile, encoding=x.options.encoding)
                    elif x.options.output == 'newfile':
                        import StringIO
                        buf = StringIO.StringIO()
                        easy.outputfile = buf
                        if easy.run(self.mainframe, x):
                            document = self.mainframe.editctrl.new()
                            document.SetText(
                                common.decode_string(buf.getvalue(),
                                                     x.options.encoding))
                    else:
                        if easy.run(self.mainframe, x):
                            common.showmessage(self, tr("Completed!"))
            except:
                error.traceback()
                common.showerror(
                    self, tr("There is something wrong, see the error.log!"))
        finally:
            os.chdir(old_path)

        if path:
            del sys.path[0]
Beispiel #15
0
 def callback():
     common.showmessage(tr('Export completed!'))
Beispiel #16
0
def RunCommand(win,
               command,
               redirect=True,
               hide=False,
               input_decorator=None,
               callback=None):
    """replace $file = current document filename"""
    global input_appendtext

    #test if there is already a running process
    if hasattr(win, 'messagewindow'
               ) and win.messagewindow and win.messagewindow.process:
        common.showmessage(
            win,
            tr("The last process didn't stop yet. Please stop it and try again."
               ))
        return
    if input_decorator:
        input_appendtext = input_decorator(appendtext)
    else:
        input_appendtext = appendtext
    if redirect:
        win.createMessageWindow()
        win.panel.showPage(tr('Messages'))
        win.callplugin('start_run', win, win.messagewindow)
        win.messagewindow.SetReadOnly(0)
        win.messagewindow.callback = callback
        appendtext(win.messagewindow, '> ' + command + '\n')

        win.messagewindow.editpoint = win.messagewindow.GetLength()
        win.messagewindow.writeposition = win.messagewindow.GetLength()
        win.SetStatusText(tr("Running "), 0)
        try:
            win.messagewindow.process = wx.Process(win)
            win.messagewindow.process.Redirect()
            if wx.Platform == '__WXMSW__':
                if hide == False:
                    win.messagewindow.pid = wx.Execute(
                        command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE,
                        win.messagewindow.process)
                else:
                    win.messagewindow.pid = wx.Execute(
                        command, wx.EXEC_ASYNC, win.messagewindow.process)
            else:
                win.messagewindow.pid = wx.Execute(
                    command, wx.EXEC_ASYNC | wx.EXEC_MAKE_GROUP_LEADER,
                    win.messagewindow.process)
            if hasattr(win.messagewindow,
                       'inputstream') and win.messagewindow.inputstream:
                win.messagewindow.inputstream.close()
            win.messagewindow.inputstream = win.messagewindow.process.GetInputStream(
            )
            win.messagewindow.outputstream = win.messagewindow.process.GetOutputStream(
            )
            win.messagewindow.errorstream = win.messagewindow.process.GetErrorStream(
            )
        except:
            win.messagewindow.process = None
            dlg = wx.MessageDialog(
                win,
                tr("There are some issues with running the program.\nPlease run it in the shell."
                   ), "Error", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command, wx.EXEC_ASYNC)
 def callback():
     common.showmessage(tr("Export completed!"))
Beispiel #18
0
 def callback():
     common.showmessage(tr('Export completed!'))