Ejemplo n.º 1
0
 def __init__(self, *arg, **kw):
     '''Initialize an OptionalItem from a item dict from the
     InstallInfo.plist optional_installs array'''
     super(OptionalItem, self).__init__(*arg, **kw)
     if 'category' not in self:
         self['category'] = NSLocalizedString(u"Uncategorized",
                                              u"No Category name")
     if self['developer']:
         self['category_and_developer'] = u'%s - %s' % (self['category'],
                                                        self['developer'])
     else:
         self['category_and_developer'] = self['category']
     self['dependent_items'] = dependentItems(self['name'])
     if self.get('installer_item_size'):
         self['size'] = munki.humanReadable(self['installer_item_size'])
     elif self.get('installed_size'):
         self['size'] = munki.humanReadable(self['installed_size'])
     else:
         self['size'] = u''
     self['detail_link'] = u'detail-%s.html' % quote(self['name'])
     self['hide_cancel_button'] = u''
     if not self.get('note'):
         self['note'] = self._get_note_from_problem_items()
     if not self.get('status'):
         self['status'] = self._get_status()
Ejemplo n.º 2
0
 def __init__(self, *arg, **kw):
     '''Initialize an OptionalItem from a item dict from the
     InstallInfo.plist optional_installs array'''
     super(OptionalItem, self).__init__(*arg, **kw)
     if 'category' not in self:
         self['category'] = NSLocalizedString(u"Uncategorized",
                                              u"No Category name")
     if self['developer']:
         self['category_and_developer'] = u'%s - %s' % (
             self['category'], self['developer'])
     else:
         self['category_and_developer'] = self['category']
     self['dependent_items'] = dependentItems(self['name'])
     if self.get('installer_item_size'):
         self['size'] = munki.humanReadable(self['installer_item_size'])
     elif self.get('installed_size'):
         self['size'] = munki.humanReadable(self['installed_size'])
     else:
         self['size'] = u''
     self['detail_link'] = u'detail-%s.html' % quote(self['name'])
     self['hide_cancel_button'] = u''
     if not self.get('note'):
         self['note'] = self._get_note_from_problem_items()
     if not self.get('status'):
         self['status'] = self._get_status()
Ejemplo n.º 3
0
    def buildOptionalInstallsData(self):
        table = []
        selfservedata = munki.readSelfServiceManifest()
        selfserve_installs = selfservedata.get('managed_installs', [])
        selfserve_uninstalls = selfservedata.get('managed_uninstalls', [])

        for item in self._optionalInstalls:
            row = {}
            row['enabled'] = objc.YES
            # current install state
            row['installed'] = item.get("installed", objc.NO)
            # user desired state
            row['managed'] = (item['name'] in selfserve_installs)
            row['original_managed'] = (item['name'] in selfserve_installs)
            row['itemname'] = item['name']
            row['name'] = item.get("display_name") or item['name']
            row['version'] = munki.trimVersionString(
                                            item.get("version_to_install"))
            row['description'] = item.get("description", "")
            if item.get("installer_item_size"):
                row['size'] = munki.humanReadable(
                                                item.get("installer_item_size"))
            elif item.get("installed_size"):
                row['size'] = munki.humanReadable(item.get("installed_size"))
            else:
                row['size'] = ""

            if row['installed']:
                if item.get("needs_update"):
                    status = NSLocalizedString(u"Update available", None)
                elif item.get("will_be_removed"):
                    status = NSLocalizedString(u"Will be removed", None)
                elif not item.get('uninstallable'):
                    status = NSLocalizedString(u"Not removable", None)
                    row['enabled'] = objc.NO
                else:
                    row['size'] = "-"
                    status = NSLocalizedString(u"Installed", None)
            else:
                status = "Not installed"
                if item.get("will_be_installed"):
                    status = NSLocalizedString(u"Will be installed", None)
                elif 'licensed_seats_available' in item:
                    if not item['licensed_seats_available']:
                        status = NSLocalizedString(
                            u"No available license seats", None)
                        row['enabled'] = objc.NO
                elif item.get("note"):
                    # some reason we can't install
                    status = item.get("note")
                    row['enabled'] = objc.NO
            row['status'] = status
            row['original_status'] = status
            row_dict = NSMutableDictionary.dictionaryWithDictionary_(row)
            table.append(row_dict)

        self.optional_view_controller.setOptionallist_(table)
        self.optional_view_controller.tableView.deselectAll_(self)
Ejemplo n.º 4
0
    def buildOptionalInstallsData(self):
        table = []
        selfservedata = munki.readSelfServiceManifest()
        selfserve_installs = selfservedata.get('managed_installs', [])
        selfserve_uninstalls = selfservedata.get('managed_uninstalls', [])

        for item in self._optionalInstalls:
            row = {}
            row['enabled'] = objc.YES
            # current install state
            row['installed'] = item.get("installed", objc.NO)
            # user desired state
            row['managed'] = (item['name'] in selfserve_installs)
            row['original_managed'] = (item['name'] in selfserve_installs)
            row['itemname'] = item['name']
            row['name'] = item.get("display_name") or item['name']
            row['version'] = munki.trimVersionString(
                item.get("version_to_install"))
            row['description'] = item.get("description", "")
            if item.get("installer_item_size"):
                row['size'] = munki.humanReadable(
                    item.get("installer_item_size"))
            elif item.get("installed_size"):
                row['size'] = munki.humanReadable(item.get("installed_size"))
            else:
                row['size'] = ""

            if row['installed']:
                if item.get("needs_update"):
                    status = NSLocalizedString(u"Update available", None)
                else:
                    row['size'] = "-"
                    status = NSLocalizedString(u"Installed", None)
                if item.get("will_be_removed"):
                    status = NSLocalizedString(u"Will be removed", None)
                elif not item.get('uninstallable'):
                    status = NSLocalizedString(u"Not removable", None)
                    row['enabled'] = objc.NO
            else:
                status = "Not installed"
                if item.get("will_be_installed"):
                    status = NSLocalizedString(u"Will be installed", None)
                elif item.get("note"):
                    # some reason we can't install
                    status = item.get("note")
                    row['enabled'] = objc.NO
            row['status'] = status
            row['original_status'] = status
            row_dict = NSMutableDictionary.dictionaryWithDictionary_(row)
            table.append(row_dict)

        self.optional_view_controller.setOptionallist_(table)
        self.optional_view_controller.tableView.deselectAll_(self)
Ejemplo n.º 5
0
class GenericItem(dict):
    '''Base class for our types of Munki items'''
    def __init__(self, *arg, **kw):
        super(GenericItem, self).__init__(*arg, **kw)
        # now normalize values
        if not self.get('display_name'):
            self['display_name'] = self['name']
        self['display_name_lower'] = self['display_name'].lower()
        if not self.get('developer'):
            self['developer'] = self.guess_developer()
        if self.get('description'):
            try:
                self['raw_description'] = filtered_html(self['description'])
            except HTMLParseError, err:
                self['raw_description'] = (
                    'Invalid HTML in description for %s' %
                    self['display_name'])
            del (self['description'])
        if not 'raw_description' in self:
            self['raw_description'] = u''
        self['icon'] = self.getIcon()
        self['due_date_sort'] = NSDate.distantFuture()
        # sort items that need restart highest, then logout, then other
        if self.get('RestartAction') in [None, 'None']:
            self['restart_action_text'] = u''
            self['restart_sort'] = 2
        elif self['RestartAction'] in ['RequireRestart', 'RecommendRestart']:
            self['restart_sort'] = 0
            self['restart_action_text'] = NSLocalizedString(
                u"Restart Required", u"Restart Required title")
            self[
                'restart_action_text'] += u'<div class="restart-needed-icon"></div>'
        elif self['RestartAction'] in ['RequireLogout', 'RecommendLogout']:
            self['restart_sort'] = 1
            self['restart_action_text'] = NSLocalizedString(
                u"Logout Required", u"Logout Required title")
            self[
                'restart_action_text'] += u'<div class="logout-needed-icon"></div>'

        # sort bigger installs to the top
        if self.get('installed_size'):
            self['size_sort'] = -int(self['installed_size'])
            self['size'] = munki.humanReadable(self['installed_size'])
        elif self.get('installer_item_size'):
            self['size_sort'] = -int(self['installer_item_size'])
            self['size'] = munki.humanReadable(self['installer_item_size'])
        else:
            self['size_sort'] = 0
            self['size'] = u''
Ejemplo n.º 6
0
    def __init__(self, *arg, **kw):
        super(GenericItem, self).__init__(*arg, **kw)
        # now normalize values
        if not self.get('display_name'):
            self['display_name'] = self['name']
        self['display_name_lower'] = self['display_name'].lower()
        if not self.get('developer'):
            self['developer'] = self.guess_developer()
        if self.get('description'):
            try:
                self['raw_description'] = filtered_html(self['description'])
            except HTMLParseError:
                self['raw_description'] = (
                    'Invalid HTML in description for %s' % self['display_name'])
            del self['description']
        if not 'raw_description' in self:
            self['raw_description'] = u''
        self['icon'] = self.getIcon()
        self['due_date_sort'] = NSDate.distantFuture()
        # sort items that need restart highest, then logout, then other
        if self.get('RestartAction') in [None, 'None']:
            self['restart_action_text'] = u''
            self['restart_sort'] = 2
        elif self['RestartAction'] in ['RequireRestart', 'RecommendRestart']:
            self['restart_sort'] = 0
            self['restart_action_text'] = NSLocalizedString(
                u"Restart Required", u"Restart Required title")
            self['restart_action_text'] += (
                u'<div class="restart-needed-icon"></div>')
        elif self['RestartAction'] in ['RequireLogout', 'RecommendLogout']:
            self['restart_sort'] = 1
            self['restart_action_text'] = NSLocalizedString(
                u"Logout Required", u"Logout Required title")
            self['restart_action_text'] += (
                u'<div class="logout-needed-icon"></div>')

        # sort bigger installs to the top
        if self.get('installed_size'):
            self['size_sort'] = -int(self['installed_size'])
            self['size'] = munki.humanReadable(self['installed_size'])
        elif self.get('installer_item_size'):
            self['size_sort'] = -int(self['installer_item_size'])
            self['size'] = munki.humanReadable(self['installer_item_size'])
        else:
            self['size_sort'] = 0
            self['size'] = u''
Ejemplo n.º 7
0
    def buildUpdateTableData(self):
        table = []
        self.restart_required = False
        self.logout_required = False
        for item in self._listofupdates:
            row = {}
            if item.get("force_install_after_date"):
                row['image'] = self._exclamationImage
            elif item.get("RestartAction") == "RequireRestart" or item.get(
                    "RestartAction") == "RecommendRestart":
                row['image'] = self._restartImage
                self.restart_required = True
            elif item.get("RestartAction") == "RequireLogout" or item.get(
                    "RestartAction") == "RecommendLogout":
                row['image'] = self._logoutImage
                self.logout_required = True
            else:
                row['image'] = self._emptyImage
            row['name'] = item.get("display_name") or item.get("name", "")
            row['version'] = munki.trimVersionString(
                item.get("version_to_install"))
            if item.get("installer_item_size"):
                row['size'] = munki.humanReadable(
                    item.get("installer_item_size"))
            elif item.get("installed_size"):
                row['size'] = munki.humanReadable(item.get("installed_size"))
            else:
                row['size'] = ""
            row['description'] = item.get("description", "")
            row_dict = NSDictionary.dictionaryWithDictionary_(row)
            table.append(row_dict)

        self.update_view_controller.setUpdatelist_(table)
        self.update_view_controller.tableView.deselectAll_(self)
        if self.restart_required:
            self.update_view_controller.restartInfoFld.setStringValue_(
                NSLocalizedString(u"Restart will be required.", None))
            self.update_view_controller.restartImageFld.setImage_(
                self._restartImage)
        elif self.logout_required:
            self.update_view_controller.restartInfoFld.setStringValue_(
                NSLocalizedString(u"Logout will be required.", None))
            self.update_view_controller.restartImageFld.setImage_(
                self._logoutImage)
Ejemplo n.º 8
0
    def buildUpdateTableData(self):
        table = []
        self.restart_required = False
        self.logout_required = False
        for item in self._listofupdates:
            row = {}
            row['image'] = self._emptyImage
            if (item.get("RestartAction") == "RequireRestart" 
                or item.get("RestartAction") == "RecommendRestart"):
                row['image'] = self._restartImage
                self.restart_required = True
            elif (item.get("RestartAction") == "RequireLogout" 
                  or item.get("RestartAction") == "RecommendLogout"):
                row['image'] = self._logoutImage
                self.logout_required = True
            if item.get("force_install_after_date"):
                row['image'] = self._exclamationImage
            row['name'] = item.get("display_name") or item.get("name","")
            row['version'] = munki.trimVersionString(
                                            item.get("version_to_install"))
            if item.get("installer_item_size"):
                row['size'] = munki.humanReadable(
                                            item.get("installer_item_size"))
            elif item.get("installed_size"):
                row['size'] = munki.humanReadable(item.get("installed_size"))
            else:
                row['size'] = ""
            row['description'] = item.get("description","")
            row_dict = NSDictionary.dictionaryWithDictionary_(row)
            table.append(row_dict)

        self.update_view_controller.setUpdatelist_(table)
        self.update_view_controller.tableView.deselectAll_(self)
        if self.restart_required:
            self.update_view_controller.restartInfoFld.setStringValue_(
                NSLocalizedString(u"Restart will be required.", None))
            self.update_view_controller.restartImageFld.setImage_(
                                                            self._restartImage)
        elif self.logout_required:
            self.update_view_controller.restartInfoFld.setStringValue_(
                NSLocalizedString(u"Logout will be required.", None))
            self.update_view_controller.restartImageFld.setImage_(
                                                            self._logoutImage)
Ejemplo n.º 9
0
for c in CATALOGS:
    for item in updatecheck.CATALOG[c]['items']:
        for path_key in [
                'installer_item_location', 'uninstaller_item_location'
        ]:
            if path_key in item.keys():
                report_item = {}
                report_item['path'] = os.path.join(PKGS_ROOT, item[path_key])
                report_item['size'] = item['installer_item_size']
                defined_locations.append(report_item)

totalbytes = 0
print "%-100s %-16s" % ("Path", "Size")
print

for r, d, f in os.walk(PKGS_ROOT):
    for phile in f:
        if (phile.endswith('.dmg') or phile.endswith('.pkg')) and \
            '.AppleDouble' not in r and \
            not phile.startswith('._'):
            repo_pkg_path = os.path.join(r, phile)
            relative_path = repo_pkg_path.split(PKGS_ROOT + '/')[1]
            if repo_pkg_path not in [k['path'] for k in defined_locations]:
                item_size = os.path.getsize(repo_pkg_path)
                print "%-100s %-16s" % (relative_path,
                                        humanReadable(item_size / 1024))
                totalbytes += item_size

print
print "Total size: %s" % (humanReadable(totalbytes / 1024))
Ejemplo n.º 10
0
updatecheck.getCatalogs(CATALOGS)
defined_locations = []
for c in CATALOGS:
    for item in updatecheck.CATALOG[c]['items']:
        for path_key in ['installer_item_location', 'uninstaller_item_location']:
            if path_key in item.keys():
                report_item = {}
                report_item['path'] = os.path.join(PKGS_ROOT, item[path_key])
                report_item['size'] = item['installer_item_size']
                defined_locations.append(report_item)

totalbytes = 0
print "%-100s %-16s" % ("Path", "Size")
print

for r, d, f in os.walk(PKGS_ROOT):
    for phile in f:
        if (phile.endswith('.dmg') or phile.endswith('.pkg')) and \
            '.AppleDouble' not in r and \
            not phile.startswith('._'):
            repo_pkg_path = os.path.join(r, phile)
            relative_path = repo_pkg_path.split(PKGS_ROOT + '/')[1]
            if repo_pkg_path not in [k['path'] for k in defined_locations]:
                item_size = os.path.getsize(repo_pkg_path)
                print "%-100s %-16s" % (relative_path, humanReadable(item_size / 1024))
                totalbytes += item_size

print
print "Total size: %s" % (humanReadable(totalbytes / 1024))