コード例 #1
0
ファイル: iconset.py プロジェクト: BackupTheBerlios/nanoicq
    def _getIconType(self, ext):
        '''
        Determine icon's type from file extension
        '''
        if ext == '.ico': return wx.BITMAP_TYPE_ICO

        log().log("Passed wrong icon type: '%s'" % str(ext))
        raise IconSetException("Unknown file type: '%s'" % ext)
コード例 #2
0
ファイル: Plugin.py プロジェクト: BackupTheBerlios/nanoicq
def _test():
    p = load_plugins(connector = None)
    log().log(p)

    m = messageFactory("icq", 'user', '12121212', 'text', Outgoing)
    b = Buddy()
    b.uin = '12121212'

    for k in p:
        p[k].onIncomingMessage(buddy = b, message = m)
コード例 #3
0
ファイル: iconset.py プロジェクト: BackupTheBerlios/nanoicq
 def addPath(self, path, alias = None):
     ''' Add alias and path where to search icons '''
     npath = os.path.abspath(path)
     if os.path.isdir(npath):
         if npath not in self._path:
             if alias is None:
                 alias = os.path.basename(npath)
             self._path.append((alias, npath))
     else:
         log().log("Passed wrong icon set path: '%s'" % str(path))
         raise IconSetException("Wrong path")
コード例 #4
0
    def onIncomingMessage(self, buddy, message):

        if buddy.uin in self._trusted_uin:
            txt = message.getContents().lower().strip()
            if txt == 'winamp':
                log().log("WINAMP: '%s' is in trusted UINs" % buddy.uin)
                m = messageFactory("icq", buddy.name, buddy.uin, self.formatReport(), Outgoing)
                self.sendMessage(buddy, m)

                # Set 'blocked' flag - do not display message
                message.blocked(True)
        else:
            log().log("WINAMP: '%s' is NOT in trusted UINs" % buddy.uin)

        return message
コード例 #5
0
ファイル: iconset.py プロジェクト: BackupTheBerlios/nanoicq
            def loadIcon(icons, dir, entries):
                for e in entries:
                    fullName = os.path.join(dir, e)
                    name, ext = os.path.splitext(e)
                    ext = ext.lower()
                    if ext not in self._EXTENSIONS:
                        continue

                    name = name.lower()
                    if name not in self.FULL_SET:
                        continue

                    try:
                        img = wx.Image(fullName)
                        icon = wx.BitmapFromImage(img.Scale(16, 16))
                    except Exception, e:
                        log().log("Got exception while loading icon: %s" % str(e))
                        continue

                    icons[name] = icon
コード例 #6
0
ファイル: iconset.py プロジェクト: BackupTheBerlios/nanoicq
    def loadIcons(self, adjust_missing = True):
        '''
        Load icon sets and create null'ed icons if some of
        icons are missing in icon set
        '''

        for alias, path in self._path:

            def loadIcon(icons, dir, entries):
                for e in entries:
                    fullName = os.path.join(dir, e)
                    name, ext = os.path.splitext(e)
                    ext = ext.lower()
                    if ext not in self._EXTENSIONS:
                        continue

                    name = name.lower()
                    if name not in self.FULL_SET:
                        continue

                    try:
                        img = wx.Image(fullName)
                        icon = wx.BitmapFromImage(img.Scale(16, 16))
                    except Exception, e:
                        log().log("Got exception while loading icon: %s" % str(e))
                        continue

                    icons[name] = icon

            icons = {}
            os.path.walk(path, loadIcon, icons)

            if not self._isFullSet(icons):
                log().log("Loaded '%s' (not complete) icon set" % alias)

                if adjust_missing:
                    self._adjustMissing(icons)
            else:
                log().log("Loaded '%s' icon set" % alias)
コード例 #7
0
ファイル: Captcha.py プロジェクト: BackupTheBerlios/nanoicq
    def stage2StartProcessing(self):
        self.button1.Enable(False)
        self.Layout()

        busy = wx.BusyInfo("One moment ...")
        wx.Yield()

        attempts = 0
        maxAttempts = 5
        while True:
            try:
                attempts += 1
                self.startRegistration()
                break
            except Exception, exc:
                if attempts >= maxAttempts:
                    msg = "Unable to login to server: " + str(exc)
                    log().log(msg)
                    del busy
                    raise Exception(msg)
                log().log("Unsuccessful attempt, trying one more time: " + str(exc))
                time.sleep(1)
コード例 #8
0
ファイル: Plugin.py プロジェクト: BackupTheBerlios/nanoicq
def __load_plugins(plugin_dir, connector):
    plugins = {}

    for d in glob.glob(os.path.join(plugin_dir, '*')):
        dd = os.path.abspath(d)
        head, module = os.path.split(dd)

        # FIXME: temporary hack
        if module == 'CVS': continue

        try:
            b, booted = __import__(module).init_plugin(connector)
        except PluginException, exc:
            log().log("Error loading plugin '%s'" % module)
            log().log(str(exc))
        except (ImportError, AttributeError):
            log().log("Error loading plugin '%s'" % module)
            traceback.print_exc()
コード例 #9
0
ファイル: Captcha.py プロジェクト: BackupTheBerlios/nanoicq
 def postPictureText(self, evt):
     evt.Skip()
     txt = self.text.GetValue()
     if len(txt) == 0:
         return
     log().log('Posting captcha text (%s)...' % str(txt))
コード例 #10
0
ファイル: Plugin.py プロジェクト: BackupTheBerlios/nanoicq
        head, module = os.path.split(dd)

        # FIXME: temporary hack
        if module == 'CVS': continue

        try:
            b, booted = __import__(module).init_plugin(connector)
        except PluginException, exc:
            log().log("Error loading plugin '%s'" % module)
            log().log(str(exc))
        except (ImportError, AttributeError):
            log().log("Error loading plugin '%s'" % module)
            traceback.print_exc()
        else:
            if module is None or booted == False:
                log().log("Plugin '%s', not loaded" % module)
            else:
                log().log("Loaded '%s' plugin" % module)
                plugins[module] = (b)
    return plugins

def load_plugins(top = None, mp = None, connector = None):
    if top is None:
        top = 'plugins'
    if mp is None:
        m_path = __my_path()
    else:
        m_path = mp
    sys.path = [os.path.join(m_path, top)] + sys.path
    return __load_plugins(top, connector)