本文整理汇总了Python中modules.common.showerror函数的典型用法代码示例。如果您正苦于以下问题:Python showerror函数的具体用法?Python showerror怎么用?Python showerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
def connect(self):
self.running = True
site = self.pref.sites_info[self.pref.ftp_sites[self.cmbSite.GetSelection()]]
self.ftp = FTP()
#connect
try:
common.setmessage(self.mainframe, tr('Connecting to %s (%s:%s)...') % (site['name'],site['ip'], site['port']))
self.ftp.connect(site['ip'], site['port'])
flag, user, password = self.getuserpassword(self.cmbSite.GetSelection(), self.txtUser.GetValue(), self.txtPassword.GetValue())
if not flag:
common.setmessage(self.mainframe, tr('Connection canceled'))
self.ftp = None
self.alive = False
self.running = False
return
common.setmessage(self.mainframe, tr('Logging in...'))
self.ftp.login(user, password)
except socket.error, msg:
error.traceback()
common.showerror(self, msg[1])
self.ftp = None
self.running = False
return
示例2: OnDjangoFunc
def OnDjangoFunc(win, event):
_id = event.GetId()
try:
if hasattr(win, "IDPM_DJANGO_STARTAPP") and _id == win.IDPM_DJANGO_STARTAPP:
OnDjangoStartApp(win)
elif hasattr(win, "IDPM_DJANGO_INSTALLAPP") and _id == win.IDPM_DJANGO_INSTALLAPP:
d = Casing.Casing(OnDjangoInstallApp, win)
v = Casing.new_obj()
v.count = 0
# d.onprocess(onprocess, v=v, timestep=0.1)
# d.onsuccess(onsuccess)
# d.onexception(onsuccess)
d.start_thread()
elif hasattr(win, "IDPM_DJANGO_INSTALLSYSAPP_ADMIN") and _id == win.IDPM_DJANGO_INSTALLSYSAPP_ADMIN:
d = Casing.Casing(OnDjangoInstallConApp, win, "admin")
v = Casing.new_obj()
# d.onprocess(onprocess, v=v, timestep=0.1)
# d.onsuccess(onsuccess)
# d.onexception(onsuccess)
d.start_thread()
elif hasattr(win, "IDPM_DJANGO_RUNSERVER") and _id == win.IDPM_DJANGO_RUNSERVER:
OnDjangoRunServer(win)
elif hasattr(win, "IDPM_DJANGO_RUNSHELL") and _id == win.IDPM_DJANGO_RUNSHELL:
OnDjangoRunShell(win)
elif hasattr(win, "IDPM_DJANGO_DOT") and _id == win.IDPM_DJANGO_DOT:
OnCreateDot(win)
except:
error.traceback()
common.showerror(win, tr("There is some wrong as executing the menu."))
示例3: OnScriptItems
def OnScriptItems(win, event):
import wx.lib.dialogs
import traceback
from modules import common
eid = event.GetId()
index = win.scriptmenu_ids.index(eid)
filename = win.pref.scripts[index][1]
try:
scripttext = open(common.encode_path(filename), 'rU').read()
except:
common.showerror(win, tr("Can't open the file %s.") % filename)
return
try:
code = compile((scripttext + '\n'), common.encode_path(filename), 'exec')
except:
d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error compiling script.\n\nTraceback:\n\n") +
''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300))
d.ShowModal()
d.Destroy()
return
try:
namespace = locals()
exec code in namespace
except:
d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error running script.\n\nTraceback:\n\n") +
''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300))
d.ShowModal()
d.Destroy()
return
示例4: OnReplace
def OnReplace(self, event):
pos = self._get_insert_pos()
try:
b = re.compile(self._get_find(), re.DOTALL)
except Exception, e:
common.showerror(self, str(e))
return
示例5: OnApply
def OnApply(self, event):
dlg = wx.MessageDialog(self, tr("Do you want to apply these changes?\nThese changes will not be undo."), tr("Confirm"), wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
ret = dlg.ShowModal()
dlg.Destroy()
if ret == wx.ID_CANCEL:
return
for i in range(self.filenames.GetItemCount()-1, -1, -1):
if not self.filenames.getFlag(i):
continue
filename = self.fileinfos[self.filenames.GetItemData(i)]
path = os.path.dirname(filename)
if self.chk_remainsufix.GetValue():
ext = os.path.splitext(filename)[1]
else:
ext = ''
f = self.filenames.getCell(i, 2)
if f:
newf = os.path.join(path, f+ext)
try:
os.rename(filename, newf)
self.filenames.delline(i)
except Exception, e:
common.showerror(self, str(e))
self.filenames.setFlag(i, False)
else:
self.filenames.setFlag(i, False)
示例6: readfile
def readfile(mainframe, filename, siteno, user=None, password=None):
if siteno >= len(mainframe.pref.ftp_sites):
common.showerror(mainframe, tr("Can't find the FTP site."))
return
site = mainframe.pref.sites_info[mainframe.pref.ftp_sites[siteno]]
if not user:
user = site['user']
if not password:
password = site['password']
flag, user, password = getuserpassword(mainframe, siteno)
if not flag:
common.setmessage(mainframe, tr('Connection canceled'))
return
ftp = FTP()
try:
ftp.connect(site['ip'], site['port'])
ftp.login(user, password)
ftp.set_pasv(site['pasv'])
data = []
def getdata(d, data=data):
data.append(d)
ftp.retrbinary("RETR %s" % common.decode_string(filename), getdata)
ftp.quit()
ftp.close()
text = ''.join(data)
return text
except Exception, msg:
error.traceback()
common.showerror(mainframe, msg)
示例7: OnConnect
def OnConnect(self, event=None):
if not self.status:
if not self.me or self.me == '*':
common.showerror(self, tr("Username should not be empty or '*'"))
self.txtName.SetFocus()
return
ip = self.txtIP.GetValue()
if not ip:
common.showerror(self, tr("Host address cannot be empty!"))
self.txtIP.SetFocus()
return
port = int(self.txtPort.GetValue())
self.pref.pairprog_host = ip
self.pref.pairprog_port = port
self.pref.pairprog_username = self.me
self.pref.save()
# try:
self.client = Client.start_client(ip, port, self.clientcommands)
if self.client:
self.client.call('join', self.me)
self.change_status('connectserver')
self.callplugin('start', self, 'client')
# except:
# common.warn(tr("Connect to server error!"))
# error.traceback()
else:
self.client.close()
self.client = None
self.change_status('disconnectserver')
self.callplugin('stop', self, 'client')
示例8: OnStart
def OnStart(self, event=None):
if not self.status:
if not self.me or self.me == '*':
common.showerror(self, tr("Username should not be empty or '*'"))
self.txtName.SetFocus()
return
ip = self.txtIP.GetValue()
if not ip:
common.showerror(self, tr("Host address cannot be empty!"))
self.txtIP.SetFocus()
return
port = int(self.txtPort.GetValue())
self.pref.pairprog_host = ip
self.pref.pairprog_port = port
self.pref.pairprog_username = self.me
self.pref.save()
try:
self.server = Server.start_server(ip, port, self.servercommands)
if self.server:
self.AddUser(self.me, manager=True)
self.change_status('startserver')
self.callplugin('start', self, 'server')
except:
common.warn(tr("Start server error!"))
error.traceback()
else:
self.server.shut_down()
self.server = None
self.change_status('stopserver')
self.callplugin('stop', self, 'server')
示例9: OnBlogWindow
def OnBlogWindow(win, event):
try:
win.mainframe.createBlogWindow()
win.panel.showPage('Blog')
except:
error.traceback()
common.showerror(win, tr('There is something wrong as running Blog Edit'))
示例10: OnDocbookEnclose
def OnDocbookEnclose(editor):
#find the docbook.acp file
docbookini = common.getConfigPathFile('docbook_xml.ini')
from modules import dict4ini
x = dict4ini.DictIni(docbookini)
taglist = x.default.taglist
taglist.sort()
#popup a selection win
if taglist:
from modules.EasyGuider import EasyDialog
dialog = [
('single', 'tagname', taglist[0], tr('Select a tag:'), taglist),
]
dlg = EasyDialog.EasyDialog(editor, tr('Select a DocBook Element Name'), dialog)
values = None
if dlg.ShowModal() == wx.ID_OK:
values = dlg.GetValue()
dlg.Destroy()
if values:
tagname = values['tagname']
text = editor.GetSelectedText()
editor.BeginUndoAction()
if text:
editor.ReplaceSelection('')
if x.tag_values.has_key(tagname):
settext(editor, [x.tag_values[tagname]])
else:
editor.AddText('<%s>%s</%s>' % (tagname, text, tagname))
pos = editor.GetCurrentPos() - len(values['tagname']) - 3
editor.GotoPos(pos)
editor.EndUndoAction()
else:
common.showerror(editor, tr("There are not tags defined in conf/docbook_xml.ini."))
示例11: OnDelete
def OnDelete(self, event):
item = self.tree.GetSelection()
if not self.is_ok(item): return
parent = self.tree.GetItemParent(item)
filename = self.get_node_filename(item)
dlg = wx.MessageDialog(self, tr('Do you want to delete %s ?') % filename, tr("Message"), wx.YES_NO | wx.ICON_INFORMATION)
if dlg.ShowModal() == wx.ID_YES:
if os.path.exists(filename):
if os.path.isdir(filename):
try:
shutil.rmtree(filename)
except:
error.traceback()
common.showerror(self, tr('Cannot delete directory %s!') % filename)
return
else:
try:
os.remove(filename)
except:
error.traceback()
common.showerror(self, tr('Cannot delete file %s!') % filename)
return
self.tree.Delete(item)
if self.tree.GetChildrenCount(parent) == 0:
self.tree.Collapse(parent)
self.tree.SetItemImage(parent, self.close_image, wx.TreeItemIcon_Normal)
dlg.Destroy()
示例12: writefile
def writefile(mainframe, filename, siteno, text, user=None, password=None):
if siteno >= len(mainframe.pref.ftp_sites):
common.showerror(mainframe, tr("Can't find the FTP site."))
return
site = mainframe.pref.sites_info[mainframe.pref.ftp_sites[siteno]]
if not user:
user = site['user']
if not password:
password = site['password']
flag, user, password = getuserpassword(mainframe, siteno)
if not flag:
common.setmessage(mainframe, tr('Connection canceled'))
return
ftp = FTP()
#connect
try:
ftp.connect(site['ip'], site['port'])
ftp.login(user, password)
ftp.set_pasv(site['pasv'])
import StringIO
f = StringIO.StringIO(text)
ftp.storbinary("STOR %s" % common.decode_string(filename), f)
ftp.quit()
ftp.close()
return True
except Exception, msg:
error.traceback()
common.showerror(mainframe, msg)
示例13: copy_mo
def copy_mo(self):
langpath = os.path.join(self.mainframe.workpath, 'lang')
dirs = [d for d in os.listdir(langpath) if os.path.isdir(os.path.join(langpath, d))]
files = glob.glob(os.path.join(self.mainframe.workpath, 'plugins/*/*.mo'))
import shutil
for f in files:
fname = os.path.splitext(os.path.basename(f))[0]
flag = False
for lang in dirs:
if fname.endswith(lang):
flag = True
break
if not flag:
lang = fname[-5:]
try:
os.makedirs(os.path.join(self.mainframe.workpath, 'lang', fname[-5:]))
except Exception, e:
error.traceback()
common.showerror(self, str(e))
continue
dst = os.path.join(self.mainframe.workpath, 'lang', lang, os.path.basename(f))
try:
shutil.copyfile(f, dst)
except Exception, e:
error.traceback()
common.showerror(self, str(e))
continue
示例14: OnDocumentVoiceConfig
def OnDocumentVoiceConfig(win, event):
if not win.pytts:
try:
import pyTTS
win.pytts = pyTTS.Create()
win.pytts_flag = pyTTS.tts_is_xml, pyTTS.tts_async
win.pytts.OnEndStream = win.OnTTSEndStream
except:
error.traceback()
common.showerror(win, tr("Can't import pyTTS module, please install it first."))
return
voices = win.pytts.GetVoiceNames()
if not voices:
common.showerror(win, tr("There is no available voices installed"))
return
if not win.pref.voice_name:
win.pref.voice_name = voices[0]
dialog = [
('single', 'voice_name', win.pref.voice_name, tr('Voice names:'), zip(voices, voices)),
('int', 'tts_rate', win.pref.tts_rate, tr('TTS speak rate:'), None)
]
from modules.EasyGuider import EasyDialog
dlg = EasyDialog.EasyDialog(win, title=tr("Text to Speech setting"), elements=dialog)
values = None
if dlg.ShowModal() == wx.ID_OK:
values = dlg.GetValue()
dlg.Destroy()
win.pref.tts_rate = values['tts_rate']
win.pref.voice_name = values['voice_name']
win.pref.save()
示例15: delete
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)