本文整理汇总了Python中modules.common.showerror函数的典型用法代码示例。如果您正苦于以下问题:Python showerror函数的具体用法?Python showerror怎么用?Python showerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showerror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:25,代码来源:FtpClass.py
示例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."))
开发者ID:hfpiao,项目名称:ulipad,代码行数:29,代码来源:dirbrowser_ext.py
示例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
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:33,代码来源:mScript.py
示例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
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:7,代码来源:batchrename.py
示例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)
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:27,代码来源:batchrename.py
示例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)
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:32,代码来源:FtpClass.py
示例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')
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:32,代码来源:Concurrent.py
示例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')
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:31,代码来源:Concurrent.py
示例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'))
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:7,代码来源:__init__.py
示例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."))
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:33,代码来源:editor_ext.py
示例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()
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:27,代码来源:DirBrowser.py
示例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)
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:31,代码来源:FtpClass.py
示例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
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:27,代码来源:PluginDialog.py
示例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()
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:30,代码来源:__init__.py
示例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)
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:27,代码来源:BlogManageWindow.py
示例16: read_snippet_file
def read_snippet_file(self, filename, type, expand):
try:
e = ElementTree(file=filename)
def f():
title = e.find('snippet/properties/title')
nodes = e.find('snippet/content')
data = {'type':'root', 'filename':filename, 'element':nodes,
'etree':e, 'caption':title.text}
node = self.add_new_folder(self.root, title.text, data, modified=False)
def add_nodes(root, nodes):
for n in nodes:
if n.tag == 'node':
obj = self.add_new_node(root, n.attrib['caption'], data={'element':n}, modified=False)
elif n.tag == 'folder':
obj = self.add_new_folder(root, n.attrib['caption'], data={'element':n}, modified=False)
add_nodes(obj, n.getchildren())
if expand:
self.tree.Expand(root)
add_nodes(node, nodes)
wx.CallAfter(self.tree.SelectItem, node)
if type == 'new':
wx.CallAfter(self.tree.EditLabel, node)
self._save_files()
wx.CallAfter(f)
except:
error.traceback()
common.showerror(tr("There are some errors as openning the Snippet file"))
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:33,代码来源:CodeSnippet.py
示例17: delete
def delete(self):
index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
if index >= 0:
flag = self.list.GetItemData(index)
if flag == 2:
return
pathname = self.list.GetItemText(index)
dlg = wx.MessageDialog(self, tr("Do you want to delete %s?") % pathname, tr("Delete"), wx.YES_NO | wx.ICON_QUESTION)
answer = dlg.ShowModal()
if answer == wx.ID_YES:
if flag == 0: #dir
try:
self.ftp.rmd(common.decode_string(pathname))
except Exception, msg:
error.traceback()
common.showerror(self, msg)
return
elif flag == 1: #file
try:
self.ftp.delete(common.decode_string(pathname))
except Exception, msg:
error.traceback()
common.showerror(self, msg)
return
self.refresh(self.curpath)
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:25,代码来源:FtpClass.py
示例18: newfile
def newfile(self):
filename = ''
dlg = MyTextEntry(self, tr("Filename Input"), tr('Input a new filename:'), '')
answer = dlg.ShowModal()
if answer == wx.ID_OK:
filename = dlg.GetValue()
if not filename:
return
#check if the new name has existed
index = self.list.FindItem(-1, filename)
if index > -1:
common.showerror(self, tr('The filename already exists.\nPlease input another one.'))
return
from StringIO import StringIO
f = StringIO('')
try:
self.ftp.storbinary('STOR %s' % common.decode_string(filename), f)
except Exception, msg:
error.traceback()
common.showerror(self, msg)
return
if self.refresh(self.curpath):
index = self.list.FindItem(-1, filename)
self.list.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_MASK_STATE)
开发者ID:LinYuanLab,项目名称:ulipad,代码行数:25,代码来源:FtpClass.py
示例19: OnDjangoProjectFunc
def OnDjangoProjectFunc(win, event):
_id = event.GetId()
try:
if _id == win.IDPM_DJANGO_PROJECT_NEW_MODEL:
OnDjangoProjectNewModel(win)
except:
error.traceback()
common.showerror(win, tr("There is some wrong as executing the menu."))
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:8,代码来源:editor_ext.py
示例20: OnDocbookProjectFunc
def OnDocbookProjectFunc(win, event):
_id = event.GetId()
try:
if _id == win.IDPM_DOCBOOK_PROJECT_ENCLOSE:
OnDocbookEnclose(win)
except:
error.traceback()
common.showerror(win, tr("There is some wrong as executing the menu."))
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:8,代码来源:editor_ext.py
注:本文中的modules.common.showerror函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论