Beispiel #1
0
    def update_local(self):
        installed_apps = []
        file_apps = []
        available_apps = []
        try:
            exchange_data = yaml.load(open(self._exchange_local))
        except:
            return
        if (not exchange_data):
            return
        for app in exchange_data['apps']:
            appc = ExchangeApp()
            appc.name = app['app']
            appc.display_name = app['display']
            deb = app['debian']
            self._debs[app['app']] = deb
            appc.latest_version = self.get_available_version(deb)
            appc.hidden = False
            try:
                if(app['hidden']):
                    appc.hidden = True
            except:
                pass

            local_path = os.path.join(self._directory, app['app'])
            if (os.path.exists(local_path)):
                format = ""
                if (os.path.exists(os.path.join(local_path, "app.yaml"))):
                    print local_path
                    data = yaml.load(open(os.path.join(local_path, "app.yaml")))
                    try:
                        appc.description = data['description']
                    except:
                        if (appc.hidden):
                            appc.description = "Descriptionless hidden app"
                        else:
                            appc.description = "No description set, likely an error in the yaml file"
                    try:
                        format = data['icon_format']
                    except:
                        pass
                if (os.path.exists(os.path.join(local_path, "icon" + format)) and format != ""):
                    icon = Icon()
                    icon.format = format.strip(".")
                    if (icon.format == "jpg"): icon.format = "jpeg"
                    icon.data = open(os.path.join(local_path, "icon" + format), "rb").read()
                    appc.icon = icon
            if (self.is_installed(deb)):
                appc.version = self.get_installed_version(deb)
                installed_apps.append(appc)
                file_apps.append(app) #Should remove debian tag?
            else:
                available_apps.append(appc)
        
        f = open(self._exchange_file, "w")
        yaml.dump({"apps": file_apps}, f)
        f.close()
        self._installed_apps = installed_apps
        self._available_apps = available_apps
Beispiel #2
0
def read_Icon_file(filename):
    icon = Icon()
    if filename == None or filename == "":
        return icon
    basename, extension = os.path.splitext(filename)
    if extension.lower() == ".jpg" or extension.lower() == ".jpeg":
        icon.format = "jpeg"
    elif extension.lower() == ".png":
        icon.format = "png"
    else:
        icon.format = ""
        return icon
    icon.data = open(filename, "rb").read()
    return icon
Beispiel #3
0
    def update_local(self):
        installed_apps = []
        file_apps = []
        available_apps = []
        try:
            exchange_data = yaml.load(open(self._exchange_local))
        except:
            return
        if (not exchange_data):
            return
        for app in exchange_data['apps']:
            appc = ExchangeApp()
            appc.name = app['app']
            appc.display_name = app['display']
            deb = app['debian']
            self._debs[app['app']] = deb
            appc.latest_version = self.get_available_version(deb)
            appc.hidden = False
            try:
                if (app['hidden']):
                    appc.hidden = True
            except:
                pass

            local_path = os.path.join(self._directory, app['app'])
            if (os.path.exists(local_path)):
                format = ""
                if (os.path.exists(os.path.join(local_path, "app.yaml"))):
                    print local_path
                    data = yaml.load(open(os.path.join(local_path,
                                                       "app.yaml")))
                    try:
                        appc.description = data['description']
                    except:
                        if (appc.hidden):
                            appc.description = "Descriptionless hidden app"
                        else:
                            appc.description = "No description set, likely an error in the yaml file"
                    try:
                        format = data['icon_format']
                    except:
                        pass
                if (os.path.exists(os.path.join(local_path, "icon" + format))
                        and format != ""):
                    icon = Icon()
                    icon.format = format.strip(".")
                    if (icon.format == "jpg"): icon.format = "jpeg"
                    icon.data = open(os.path.join(local_path, "icon" + format),
                                     "rb").read()
                    appc.icon = icon
            if (self.is_installed(deb)):
                appc.version = self.get_installed_version(deb)
                installed_apps.append(appc)
                file_apps.append(app)  #Should remove debian tag?
            else:
                available_apps.append(appc)

        f = open(self._exchange_file, "w")
        yaml.dump({"apps": file_apps}, f)
        f.close()
        self._installed_apps = installed_apps
        self._available_apps = available_apps