Skip to content

Commit

Permalink
Merge branch 'Munki3dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregneagle committed Sep 21, 2017
2 parents 91b43fd + e13c21e commit bdfca0b
Show file tree
Hide file tree
Showing 55 changed files with 1,695 additions and 511 deletions.
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
650B29A419B69FC800A5E946 /* MSCToolbar.py in Resources */ = {isa = PBXBuildFile; fileRef = 650B29A319B69FC800A5E946 /* MSCToolbar.py */; };
C00A4C57185FCEC9004EB3B7 /* FoundationPlist.py in Resources */ = {isa = PBXBuildFile; fileRef = C00A4C56185FCEC9004EB3B7 /* FoundationPlist.py */; };
C00F67571F016C9F00D9007D /* CocoaWrapper.py in Resources */ = {isa = PBXBuildFile; fileRef = C00F67561F016C9F00D9007D /* CocoaWrapper.py */; };
C01B396D1EEA6A9000DFBA3B /* libpython2.7.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C01B396C1EEA6A9000DFBA3B /* libpython2.7.dylib */; };
C01FBD311EA64CD600AE97EE /* passwdutil.py in Resources */ = {isa = PBXBuildFile; fileRef = C01FBD301EA64CD600AE97EE /* passwdutil.py */; };
C02C98891911B81D00425167 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C02C98871911B81D00425167 /* Localizable.strings */; };
Expand Down Expand Up @@ -69,6 +70,7 @@
/* Begin PBXFileReference section */
650B29A319B69FC800A5E946 /* MSCToolbar.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = MSCToolbar.py; sourceTree = "<group>"; };
C00A4C56185FCEC9004EB3B7 /* FoundationPlist.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = FoundationPlist.py; sourceTree = "<group>"; };
C00F67561F016C9F00D9007D /* CocoaWrapper.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = CocoaWrapper.py; sourceTree = "<group>"; };
C01B396C1EEA6A9000DFBA3B /* libpython2.7.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpython2.7.dylib; path = ../../../../../../../../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib; sourceTree = SDKROOT; };
C01E26911B4DADDC005ACFFB /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/MainMenu.strings; sourceTree = "<group>"; };
C01E26921B4DADE4005ACFFB /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,7 +103,7 @@
C02C988F1911B82E00425167 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
C02C98901911B83000425167 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
C02C98911911B83100425167 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
C042CA141EAD86DE006CC681 /* MSCPasswordAlertController.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; name = MSCPasswordAlertController.py; path = "Managed Software Center/MSCPasswordAlertController.py"; sourceTree = "<group>"; };
C042CA141EAD86DE006CC681 /* MSCPasswordAlertController.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = MSCPasswordAlertController.py; sourceTree = "<group>"; };
C0453A201CCEF7B60002D396 /* MSCLogWindowController.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = MSCLogWindowController.py; sourceTree = "<group>"; };
C046261519FFF8C000AF1E48 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/MainMenu.strings; sourceTree = "<group>"; };
C046261619FFF8CC00AF1E48 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -190,7 +192,6 @@
C09004E216CDD84E00BE34CE = {
isa = PBXGroup;
children = (
C042CA141EAD86DE006CC681 /* MSCPasswordAlertController.py */,
C09004F916CDD84E00BE34CE /* Managed Software Center */,
C0EF96B21ADDB90B002C02FF /* MSCDockTilePlugin */,
C09004F016CDD84E00BE34CE /* Frameworks */,
Expand Down Expand Up @@ -230,6 +231,7 @@
C09004F916CDD84E00BE34CE /* Managed Software Center */ = {
isa = PBXGroup;
children = (
C042CA141EAD86DE006CC681 /* MSCPasswordAlertController.py */,
C0B9E8B519AF7E9E00DB7247 /* Managed Software Center 10_6.icns */,
C094B6CE188F7C7700E06897 /* MSCStatusController.py */,
C05C3CEE188391F200095E65 /* munki.py */,
Expand All @@ -251,6 +253,7 @@
C01FBD301EA64CD600AE97EE /* passwdutil.py */,
650B29A319B69FC800A5E946 /* MSCToolbar.py */,
C0453A201CCEF7B60002D396 /* MSCLogWindowController.py */,
C00F67561F016C9F00D9007D /* CocoaWrapper.py */,
);
path = "Managed Software Center";
sourceTree = "<group>";
Expand Down Expand Up @@ -427,6 +430,7 @@
C02C98891911B81D00425167 /* Localizable.strings in Resources */,
C090050B16CDD84E00BE34CE /* MainMenu.xib in Resources */,
C049C9951AEC77DD00251D45 /* updatesTemplate.png in Resources */,
C00F67571F016C9F00D9007D /* CocoaWrapper.py in Resources */,
C090050616CDD84E00BE34CE /* main.py in Resources */,
C0E098BC1857A3C80045DEEB /* msclib.py in Resources */,
C042CA151EAD86DE006CC681 /* MSCPasswordAlertController.py in Resources */,
Expand Down
Expand Up @@ -12,7 +12,6 @@
import munki
import msclog
import MunkiItems
from MSCPasswordAlertController import MSCPasswordAlertController

from objc import nil
from AppKit import *
Expand All @@ -36,7 +35,7 @@ def handlePossibleAuthRestart(self):
if (MunkiItems.updatesRequireRestart() and
authrestart.verify_user(username) and
not authrestart.verify_recovery_key_present()):
# FV is on and user is in list of FV users, so they can
# FV is on and user is in list of FV users, so they can
# authrestart, and we do not have a stored FV recovery
# key/password. So we should prompt the user for a password
# we can use for fdesetup authrestart
Expand Down Expand Up @@ -360,8 +359,7 @@ def alertedToFirmwareUpdatesAndCancelled(self):
firmware_alert_info = self.getFirmwareAlertInfo()
if not firmware_alert_info:
return False
power_info = munki.getPowerInfo()
on_battery_power = (power_info.get('PowerSource') == 'Battery Power')
on_battery_power = munki.onBatteryPower()
for item in firmware_alert_info:
alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
item['name'],
Expand Down Expand Up @@ -392,9 +390,7 @@ def alertedToFirmwareUpdatesAndCancelled(self):
def alertedToRunningOnBatteryAndCancelled(self):
'''Returns True if we are running on battery and user clicks
the Cancel button'''
power_info = munki.getPowerInfo()
if (power_info.get('PowerSource') == 'Battery Power'
and power_info.get('BatteryCharge', 0) < 50):
if munki.onBatteryPower() and munki.getBatteryPercentage() < 50:
alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
NSLocalizedString(
u"Your computer is not connected to a power source.",
Expand Down
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
#
# CocoaWrapper.py
# MunkiStatus
#
# Created by Greg Neagle on 6/26/17.
# Copyright (c) 2017 The Munki Project. All rights reserved.
#

"""Selectively import Cocoa symbols to speed up app launch.
Idea from Per Olofsson's AutoDMG"""

# PyLint cannot properly find names inside Cocoa libraries, so issues bogus
# No name 'Foo' in module 'Bar' warnings. Disable them.
# pylint: disable=no-name-in-module
#
# disable unused-import warning, since we don't use any of these here.
# pylint: disable=unused-import

# put all Foundation imports used by the project here
from Foundation import (
NSAppleEventManager,
NSBundle,
NSCachesDirectory,
NSData,
NSDate,
NSDateFormatter,
NSDateFormatterBehavior10_4,
NSFileHandle,
NSFileManager,
NSInsetRect,
NSLocalizedString,
NSLog,
NSMakePoint,
NSMakeRect,
NSMakeSize,
NSMinX,
NSMinY,
NSMutableArray,
NSObject,
NSOffsetRect,
NSPoint,
NSPredicate,
NSString,
NSTimer,
NSURL,
NSURLFileScheme,
NSURLRequest,
NSURLRequestReloadIgnoringLocalCacheData,
NSUTF8StringEncoding,
NSUserDomainMask,
NSUserName,
NSZeroRect,
kCFDateFormatterLongStyle,
kCFDateFormatterShortStyle,
)

# put all AppKit imports used by the project here
from AppKit import (
NSAlert,
NSAlertAlternateReturn,
NSAlertDefaultReturn,
NSAlertFirstButtonReturn,
NSAlertOtherReturn,
NSAlertSecondButtonReturn,
NSApp,
NSApplication,
NSBezierPath,
NSBitmapImageRep,
NSButton,
NSButtonCell,
NSColor,
NSCompositeCopy,
NSCriticalAlertStyle,
NSDistributedNotificationCenter,
NSDragOperationAll,
NSFontAttributeName,
NSFontManager,
NSGraphicsContext,
NSImage,
NSNotFound,
NSNotificationDeliverImmediately,
NSNotificationPostToAllSessions,
NSNotificationSuspensionBehaviorDeliverImmediately,
NSOnState,
NSPNGFileType,
NSPasteboard,
NSScreen,
NSUserNotificationCenter,
NSWindowController,
NSWorkspace,
)
Expand Up @@ -24,8 +24,12 @@

from objc import YES, NO, IBAction, IBOutlet, nil
import PyObjCTools
from Foundation import *
from AppKit import *
#from Foundation import *
#from AppKit import *
# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import


from MSCStatusController import MSCStatusController

Expand Down
Expand Up @@ -21,8 +21,12 @@
# builtin super doesn't work with Cocoa classes in recent PyObjC releases.
from objc import super

from Foundation import *
from AppKit import *
#from Foundation import *
#from AppKit import *
# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import


class MSCBadgedTemplateImage(NSImage):
'''Subclass to handle our updates template image with a badge showing the count
Expand Down
Expand Up @@ -11,14 +11,19 @@
#

from objc import YES, NO, IBAction, IBOutlet
## pylint: disable=wildcard-import
## pylint: disable=unused-wildcard-import
## pylint: disable=redefined-builtin
#from Foundation import *
#from AppKit import *
## pylint: enable=redefined-builtin
## pylint: enable=wildcard-import

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
# pylint: disable=redefined-builtin
from Foundation import *
from AppKit import *
# pylint: enable=redefined-builtin
from CocoaWrapper import *
# pylint: enable=wildcard-import


import munki
import os

Expand Down
Expand Up @@ -33,11 +33,20 @@
from objc import YES, NO, IBAction, IBOutlet, nil
from PyObjCTools import AppHelper

# Disable PyLint complaining about wildcard imports and unused symbols
# pylint: disable=W0401,W0614
from Foundation import *
from AppKit import *
from WebKit import *
## pylint: disable=wildcard-import
## pylint: disable=unused-wildcard-import
## pylint: disable=redefined-builtin
#from Foundation import *
#from AppKit import *
## pylint: enable=redefined-builtin
## pylint: enable=wildcard-import

# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import

#from WebKit import *
from WebKit import WebView, WebPreferences

# Disable PyLint complaining about 'invalid' camelCase names
# pylint: disable=C0103
Expand Down Expand Up @@ -155,7 +164,7 @@ def loadInitialView(self):
'''Called by app delegate from applicationDidFinishLaunching:'''
self.enableOrDisableSoftwareViewControls()
optional_items = MunkiItems.getOptionalInstallItems()
if not optional_items or self.getUpdateCount():
if not optional_items or self.getUpdateCount() or MunkiItems.getProblemItems():
self.loadUpdatesPage_(self)
else:
self.loadAllSoftwarePage_(self)
Expand Down Expand Up @@ -407,6 +416,13 @@ def checkForUpdates(self, suppress_apple_update_check=False):
else:
self.munkiStatusSessionEnded_(2)

@IBAction
def reloadPage_(self, sender):
'''User selected Reload page menu item. Reload the page and kick off an updatecheck'''
msclog.log('user', 'reload_page_menu_item_selected')
self.checkForUpdates()
self.webView.reload_(sender)

def kickOffInstallSession(self):
'''start an update install/removal session'''
# check for need to logout, restart, firmware warnings
Expand Down
Expand Up @@ -9,12 +9,17 @@
'''Controller for our custom alert that prompts for password'''

from objc import IBAction, IBOutlet, nil
from AppKit import *
from Foundation import *
from PyObjCTools import AppHelper
from Quartz import CAKeyframeAnimation, CGPathCreateMutable
from Quartz import CGPathAddLineToPoint, CGPathMoveToPoint
from Quartz import CGPathCloseSubpath
#from Foundation import *
#from AppKit import *

# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import


import authrestart
import msclog
Expand Down
Expand Up @@ -18,9 +18,13 @@


from objc import YES, IBOutlet, nil
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
#from Foundation import *
#from AppKit import *

# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import

import munki
import msclog
Expand Down
Expand Up @@ -10,8 +10,12 @@
from objc import super

from objc import YES, NO, nil
from Foundation import *
from AppKit import *
#from Foundation import *
#from AppKit import *
# pylint: disable=wildcard-import
from CocoaWrapper import *
# pylint: enable=wildcard-import



class MSCToolbarButton(NSButton):
Expand Down
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.6</string>
<string>4.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down

0 comments on commit bdfca0b

Please sign in to comment.