Пример #1
0
    def _read(self):
        """
            Read the json file and parse it.
        """
        from src.app import App
        do_later = ["app_path", "icons_path", "icons"]
        try:
            with open(self._db_file, 'r') as db_obj:
                data = json.load(db_obj)
                for key, value in data.items():
                    if key not in do_later:
                        setattr(self, key, value)
        except (FileNotFoundError, ValueError, KeyError):
            Logger.error("Application file is broken: {}".format(
                self._db_file))

        self._parse_paths(data["app_path"], "app_path")
        self._parse_paths(data["icons_path"], "icons_path")
        self._parse_icons(data["icons"])

        if len(App.only()) == 1 and App.path():
            self.app_path.append(App.path())

        found = self.icons and self.app_path
        if self.force_create_folder and found:
            for icon_path in self.icons_path:
                create_dir(str(icon_path))
            self.dont_install = False
        else:
            self.dont_install = not (found and self.icons_path)

        # NWJS special case
        if self.get_type() == "nwjs" and not self.dont_install:
            self.dont_install = not App.get("nwjs")
Пример #2
0
args = parser.parse_args()
App.get_default(args)

if (not DESKTOP_ENV or DESKTOP_ENV == "other") and not App.icon_size():
    exit("You need to run the script using 'sudo -E'.\nPlease try again")

print("Welcome to Hardcode-Tray!")
print("Desktop Environment: {}".format(DESKTOP_ENV.title()))
print("Scaling Factor: {}".format(App.scaling_factor()))
print("Icon Size: {}".format(App.icon_size()))
if not isinstance(App.theme(), dict):
    print("Icon Theme: {}".format(App.theme()))
else:
    print("Dark Icon Theme: {}".format(App.theme("dark")))
    print("Light Icon Theme: {}".format(App.theme("light")))
print("Conversion Tool: {}".format(App.svg()))
print("To Do: ", end="")
print(", ".join(map(lambda x: x.title(), App.only())) if App.only() else "All")
# Clear backup cache
action = App.action()
if action == Action.APPLY:
    print("Applying now..\n")
elif action == Action.REVERT:
    print("Reverting now..\n")
elif action == Action.CLEAR_CACHE:
    print("Clearing cache...\n")
App.execute()

print("\nDone, Thank you for using the Hardcode-Tray fixer!")