Example #1
0
def __launch(delegate):
    ''' 
   Runs the given (no-argument) delegate method in a 'safe' script environment.
   This environment will take care of all error handling, logging/debug stream,
   and other standard initialization behaviour before delegate() is called, and
   it will take care of cleaning everything up afterwards.
   '''
    try:
        # initialize the application resources (import directories, etc)
        Resources.initialize()

        # fire up the debug logging system
        log.install(ComicRack.MainWindow)

        # install a handler to catch uncaught Winforms exceptions
        def exception_handler(sender, event):
            del sender  #unused
            log.handle_error(event.Exception)
        Application.ThreadException \
           += ThreadExceptionEventHandler(exception_handler)

        # fire up the localization/internationalization system
        i18n.install(ComicRack)

        # see if we're in a valid environment
        if __validate_environment():
            delegate()

    except Exception, ex:
        log.handle_error(ex)
def __launch(delegate):
   ''' 
   Runs the given (no-argument) delegate method in a 'safe' script environment.
   This environment will take care of all error handling, logging/debug stream,
   and other standard initialization behaviour before delegate() is called, and
   it will take care of cleaning everything up afterwards.
   ''' 
   try:
      # initialize the application resources (import directories, etc)
      Resources.initialize()
      
      # fire up the debug logging system
      log.install(ComicRack.MainWindow)
      
      # install a handler to catch uncaught Winforms exceptions
      def exception_handler(sender, event):
         log.handle_error(event.Exception)
      Application.ThreadException \
         += ThreadExceptionEventHandler(exception_handler)
         
      # fire up the localization/internationalization system
      i18n.install(ComicRack)
      
      # see if we're in a valid environment
      if __validate_environment():
         delegate()
         
   except Exception, ex:
      log.handle_error(ex)
Example #3
0
def test_conflict():
    import i18n, logfile
    
    logfile.install("stdout")
    i18n.install("../lang", ['en_US'])
    class MyFrame(wx.Frame):
        def __init__(self, parent, ID, pos=wx.DefaultPosition,
                size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):

            wx.Frame.__init__(self, parent, ID, "Test", pos, size, style)
            panel = wx.Panel(self, -1)

            button = wx.Button(panel, 1003, "Go")
            button.SetPosition((15, 15))
            self.Bind(wx.EVT_BUTTON, self.OnGo, button)
            self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        def OnGo(self, event):
            dlg = SyncConflictDialog(self, data)
            if dlg.ShowModal() == wx.ID_OK:
                pass

            dlg.Destroy()

        def OnCloseWindow(self, event):
            self.Destroy()

    data = {'haha': [['id', 'name'], [['1', 'zhaowei']], [['1', 'bobo']]],
            'category':[['id', 'name', 'parent'], [['1', 'gogo', '3']], []]}

    app = wx.PySimpleApp()
    frame = MyFrame(None, -1)
    frame.Show() 
    app.MainLoop()
Example #4
0
    def __init__(self,parent):
        #config file
        conf = config.Configure('hzdq.ini')
        lang = conf.getlocale()

        #i18n
        i18n.install(self, 'lang', lang)

        mainui_xrc.xrcmframe.__init__(self,parent)
        self.icon = wx.Icon('img/hzdq.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)
        self.txtmain = xrc.XRCCTRL(self, "txtmain")

        self.txtsearch = xrc.XRCCTRL(self, "txtsearch")
        self.txtsearch.SetValue('中'.decode('utf8'))

        s = self.txtsearch.GetValue().encode('utf8')

        #datafile
        self.data = data.HzdqData(idxfile, datafile)
        #index file
#        f = file('./data/hzidx.dat','rb')
#        self.hzidx = pk.load(f)
#        f.close()

        #self.procdict = procdict.procdict('../../data/unihan.zip','blog.csdn.net/ablo_zhou')
        #self.unihan = self.procdict.dicttxt

        #self.unihan = file('./data/unihan.dat','rb')
        #indx = '㐅'

        self.OnButton_btnsearch(None)
Example #5
0
def test_conflict():
    import i18n, logfile

    logfile.install("stdout")
    i18n.install("../lang", ['en_US'])

    class MyFrame(wx.Frame):
        def __init__(self,
                     parent,
                     ID,
                     pos=wx.DefaultPosition,
                     size=wx.DefaultSize,
                     style=wx.DEFAULT_FRAME_STYLE):

            wx.Frame.__init__(self, parent, ID, "Test", pos, size, style)
            panel = wx.Panel(self, -1)

            button = wx.Button(panel, 1003, "Go")
            button.SetPosition((15, 15))
            self.Bind(wx.EVT_BUTTON, self.OnGo, button)
            self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        def OnGo(self, event):
            dlg = SyncConflictDialog(self, data)
            if dlg.ShowModal() == wx.ID_OK:
                pass

            dlg.Destroy()

        def OnCloseWindow(self, event):
            self.Destroy()

    data = {
        'haha': [['id', 'name'], [['1', 'zhaowei']], [['1', 'bobo']]],
        'category': [['id', 'name', 'parent'], [['1', 'gogo', '3']], []]
    }

    app = wx.PySimpleApp()
    frame = MyFrame(None, -1)
    frame.Show()
    app.MainLoop()
Example #6
0
def getlocale():
	if len(sys.argv)>1:
		conf = DictIni(sys.argv[1])
	else:
		conf = DictIni("confbot.ini")
	try:
		loc = conf.general['language']
	except:
		loc = ''
	if not loc:
		loc = locale.getdefaultlocale()[0]
	if loc is None:
		loc = 'en'
	return loc

i18n.install('confbot', 'locale', getlocale())

conf = None	#global config object
userinfo = None
welcome = _("""Welcome to ConferenceBot %(version)s
By Isomer (Perry Lorier) and Limodou
This conference bot is set up to allow groups of people to chat.
")help" to list commands, ")quit" to quit
")lang en" for English, and ")lang zh_CN" for Chinese""")

xmllogf = open("xmpp.log","w")
last_activity=time.time()
#xmllogf = sys.stderr
lastlog = []

class ADMIN_COMMAND(Exception):pass
Example #7
0
    if len(sys.argv) > 1:
        conf = DictIni(sys.argv[1])
    else:
        conf = DictIni("confbot.ini")
    try:
        loc = conf.general["language"]
    except:
        loc = ""
    if not loc:
        loc = locale.getdefaultlocale()[0]
    if loc is None:
        loc = "en"
    return loc


i18n.install("confbot", "locale", getlocale())

conf = None  # global config object
userinfo = None
welcome = _(
    """Welcome to ConferenceBot %(version)s
By Isomer (Perry Lorier) and Limodou
This conference bot is set up to allow groups of people to chat.
")help" to list commands, ")quit" to quit
")lang en" for English, and ")lang zh_CN" for Chinese"""
)

xmllogf = open("xmpp.log", "w")
last_activity = time.time()
# xmllogf = sys.stderr
lastlog = []
Example #8
0
    if len(sys.argv) > 1:
        conf = DictIni(sys.argv[1])
    else:
        conf = DictIni("confbot.ini")
    try:
        loc = conf.general['language']
    except:
        loc = ''
    if not loc:
        loc = locale.getdefaultlocale()[0]
    if loc is None:
        loc = 'en'
    return loc


i18n.install('confbot', 'locale', getlocale())

conf = None  #global config object
userinfo = None
welcome = _("""Welcome to ConferenceBot %(version)s
By Isomer (Perry Lorier) and Limodou
This conference bot is set up to allow groups of people to chat.
")help" to list commands, ")quit" to quit
")lang en" for English, and ")lang zh_CN" for Chinese""")

xmllogf = open("xmpp.log", "w")
last_activity = time.time()
#xmllogf = sys.stderr
lastlog = []

Example #9
0
        return unicode(value)
    except:
        pass

    try:  # then try with utf-8
        return unicode(value, 'utf-8')
    except:
        pass

    try:  # then try with extened iso-8858
        return unicode(value, 'iso-8859-15')
    except:
        pass

    try:
        return ustr(str(value))
    except:
        value = " ".join([ustr(s) for s in value])

    # else use default system locale
    return value


__builtins__['ustr'] = ustr

import i18n

i18n.install()

# vim: ts=4 sts=4 sw=4 si et
Example #10
0
        pass

    try: # then try with extened iso-8858
        return unicode(value, 'iso-8859-15')
    except:
        pass

    try:
        return ustr(str(value))
    except:
        return " ".join([ustr(s) for s in value])

__builtins__['ustr'] = ustr

import i18n
i18n.install()

application = cherrypy.tree.mount(controllers._root.Root(), '/')
def enable_static_paths():
    ''' Enables handling of static paths by CherryPy:
    * /openobject/static
    * /favicon.ico
    * LICENSE.txt
    '''
    global WSGI_STATIC_PATHS
    WSGI_STATIC_PATHS = True

    static_dir = os.path.abspath(
            openobject.paths.root('openobject', 'static'))
    application.merge(
        {'/openobject/static': {