Beispiel #1
0
    def load_state():
        with app.State(AppRPC.APPSTATE_PATH, lock=True) as state:
            storage = state.get("storage", {})

            # base data
            caller_id = app.get_session_var("caller_id")
            storage['cid'] = app.get_cid()
            storage['coreVersion'] = __version__
            storage['coreSystype'] = util.get_systype()
            storage['coreCaller'] = (str(caller_id).lower()
                                     if caller_id else None)
            storage['coreSettings'] = {
                name: {
                    "description": data['description'],
                    "default_value": data['value'],
                    "value": app.get_setting(name)
                }
                for name, data in app.DEFAULT_SETTINGS.items()
            }

            storage['homeDir'] = expanduser("~")
            storage['projectsDir'] = storage['coreSettings']['projects_dir'][
                'value']

            # skip non-existing recent projects
            storage['recentProjects'] = [
                p for p in storage.get("recentProjects", [])
                if is_platformio_project(p)
            ]

            state['storage'] = storage
            return state.as_dict()
Beispiel #2
0
    def load_state():
        with app.State(AppRPC.APPSTATE_PATH, lock=True) as state:
            storage = state.get("storage", {})

            # base data
            caller_id = app.get_session_var("caller_id")
            storage["cid"] = app.get_cid()
            storage["coreVersion"] = __version__
            storage["coreSystype"] = util.get_systype()
            storage["coreCaller"] = str(
                caller_id).lower() if caller_id else None
            storage["coreSettings"] = {
                name: {
                    "description": data["description"],
                    "default_value": data["value"],
                    "value": app.get_setting(name),
                }
                for name, data in app.DEFAULT_SETTINGS.items()
            }

            storage["homeDir"] = fs.expanduser("~")
            storage["projectsDir"] = storage["coreSettings"]["projects_dir"][
                "value"]

            # skip non-existing recent projects
            storage["recentProjects"] = [
                p for p in storage.get("recentProjects", [])
                if is_platformio_project(p)
            ]

            state["storage"] = storage
            state.modified = False  # skip saving extra fields
            return state.as_dict()
Beispiel #3
0
 def save_state(state):
     with app.State(AppRPC.APPSTATE_PATH, lock=True) as s:
         s.clear()
         s.update(state)
         storage = s.get("storage", {})
         for k in AppRPC.IGNORE_STORAGE_KEYS:
             if k in storage:
                 del storage[k]
     return True
Beispiel #4
0
 def cleanup_expired_downloads(self):
     with app.State(self.get_download_usagedb_path(), lock=True) as state:
         # remove outdated
         for fname in list(state.keys()):
             if state[fname] > (time.time() - self.DOWNLOAD_CACHE_EXPIRE):
                 continue
             del state[fname]
             dl_path = os.path.join(self.get_download_dir(), fname)
             if os.path.isfile(dl_path):
                 os.remove(dl_path)
Beispiel #5
0
 def save_state(state):
     with app.State(AppRPC.APPSTATE_PATH, lock=True) as s:
         # s.clear()
         s.update(state)
     return True
Beispiel #6
0
 def set_download_utime(self, path, utime=None):
     with app.State(self.get_download_usagedb_path(), lock=True) as state:
         state[os.path.basename(path)] = int(
             time.time() if not utime else utime)