Пример #1
0
    def __init__(self):
        app.screen='normal' # TODO check all app.xyz use
        app.directional_pad = False
        LABELS.set_locale(DB["language"])
        self.wp_icon = Icon(MIFFILE,16384+14,16384+14)
        self.blogs = json.loads(DB["blog_list"])
        items = [ (b["account"],b["blog"],self.wp_icon) for b in self.blogs ]
        menu = [(LABELS.loc.wm_menu_exit, self.close_app)] 
        Application.__init__(self,  u"Wordmobi", Listbox( items, self.check_update_value ))
        self._update_menu()

        # TODO
        # {
        # Temporary fix before changing how persistence is treated.
        # New persistence module must be created to avoid this line and e32db.
        __changed = False
        for n in range(len(self.blogs)):
            if not self.blogs[n].has_key("api_key"):
                self.blogs[n]["api_key"] = ""
                __changed = True
        if __changed:
            DB["blog_list"]=json.dumps(self.blogs)
            DB.save()
        #
        # }
        #
        self.dlg = None
        sel_access_point()

        if not TOUCH_ENABLED:
            self.bind(key_codes.EKeyRightArrow, self.check_update_value)
            self.bind(key_codes.EKeyLeftArrow, self.close_app)
Пример #2
0
 def blog_cbk(self):
     self.lock_ui()
     if not self.dlg.cancel:
         DB["blog_list"]=json.dumps(self.dlg.blogs)
         DB.save()
         BLOG.check_persistence(self.dlg.blogs)
     self.unlock_ui()
     self.refresh()
     return True
Пример #3
0
 def twitter_cbk(self):
     self.lock_ui()
     if not self.dlg.cancel:
         DB["twitter_enabled"]= self.dlg.twitter_enabled
         DB["twitter_user"] = self.dlg.twitter_user
         DB["twitter_pass"] = self.dlg.twitter_password
         DB.save()
     self.unlock_ui()
     self.refresh()
     return True
Пример #4
0
 def proxy_cbk(self):
     self.lock_ui()
     if not self.dlg.cancel:
         DB["proxy_enabled"]= self.dlg.proxy_enabled
         DB["proxy_addr"] = self.dlg.proxy_address
         DB["proxy_user"] = self.dlg.proxy_user
         DB["proxy_pass"] = self.dlg.proxy_password
         DB["proxy_port"] = utf8_to_unicode( str(self.dlg.proxy_port) )
         DB.save()
     self.unlock_ui()
     self.refresh()
     return True
Пример #5
0
 def get(cls, name):
     with DB() as db:
         try:
             return db['user.%s' % name]
         except KeyError:
             u = cls(name)
             db['user.%s' % name] = u
             return u
Пример #6
0
 def get(cls, id, name=None):
     with DB() as db:
         try:
             return db['controlpoint.%s' % id]
         except KeyError:
             logging.error('new ControlPoint %s %s', id, name)
             cp = cls(id, name)
             db['controlpoint.%s' % id] = cp
             return cp
Пример #7
0
 def __getattr__(self, attr):
     if attr == 'UDN':
         from persist import DB
         with DB() as db:
             try:
                 self.UDN = db['udn.%s' % self._id]
             except KeyError:
                 self.UDN = db['udn.%s' % self._id] = utils.genUUID()
         return self.UDN
     elif attr == 'friendlyName':
         self.friendlyName = self._id
         return self.friendlyName
     return super(BaseDevice, self).__getattr__(attr)
Пример #8
0
    def certificate(type):

        with DB() as db:
            try:
                pem = db['certfile.%s' % type]
                cert = crypto.load_certificate(crypto.FILETYPE_PEM, pem)
                key = crypto.load_privatekey(crypto.FILETYPE_PEM, pem)
            except KeyError:
                cert, key = _gen_certificate(type)
                pem = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)\
                    + crypto.dump_privatekey(crypto.FILETYPE_PEM, key)
                db['certfile.%s' % type] = pem

        return (cert, key)
Пример #9
0
 def language(self):
     langs = [(LABELS.loc.st_menu_en_us, u"en_us"),
              (LABELS.loc.st_menu_pt_br, u"pt_br"),
              (LABELS.loc.st_menu_es, u"es"),
              (LABELS.loc.st_menu_tr, u"tr"),
              (LABELS.loc.st_menu_it, u"it"),
              (LABELS.loc.st_menu_nl, u"nl"),
              (LABELS.loc.st_menu_de, u"de"),
              (LABELS.loc.st_menu_ro, u"ro"),
              (LABELS.loc.st_menu_zh_cn, u"zh_cn"),
              (LABELS.loc.st_menu_fr, u"fr"),
              (LABELS.loc.st_menu_ru, u"ru"),
              (LABELS.loc.st_menu_id, u"id")]
     langs.sort()
     item = popup_menu(map(lambda x:x[0], langs), LABELS.loc.st_pmenu_lang )
     if item is not None:
         loc = langs[item][1]
         if DB["language"] != loc:
             LABELS.set_locale(loc)
             DB["language"] = loc
             DB.save()
             self.refresh()
             BLOG.refresh() # update global defines
             self.lang_changed = True
Пример #10
0
def certificate_file(type):

    if type in _CERTFILES:
        return _CERTFILES[type].name

    with DB() as db:
        try:
            pem = db['certfile.%s' % type]
        except KeyError:
            cert, key = _gen_certificate(type)
            pem = db['certfile.%s' %
                     type] = cert.as_pem() + key.as_pem(cipher=None)

    from tempfile import NamedTemporaryFile
    temp = _CERTFILES[type] = NamedTemporaryFile('w', bufsize=0, suffix='.pem')
    temp.write(pem)

    return temp.name
Пример #11
0
 def all(cls):
     with DB(False) as db:
         return [db[key] for key in db if key.startswith('controlpoint.')]
Пример #12
0
 def all(cls):
     with DB(False) as db:
         return [db[key] for key in db if key.startswith('user.')]