Selaa lähdekoodia

Fixed inconsistency between `networksetup` and `scutil` in the naming of the Airport/Wi-Fi device

tags/v1.0.0
Robert Klep 12 vuotta sitten
vanhempi
commit
135f8b7a90
2 muutettua tiedostoa jossa 10 lisäystä ja 8 poistoa
  1. +4
    -1
      README.md
  2. +6
    -7
      ToggleProxy.py

+ 4
- 1
README.md Näytä tiedosto

@@ -12,6 +12,9 @@ only an up-arrow when the proxy is not active.
Toggle the on/off state by clicking the icon, quit the application by
`Ctrl`-clicking the icon.

*NB*: this is not a proxy manager, you have to configure proxies from Mac
OS X Network preferences first before this app makes any sense.

## Prerequisites

* PyObjC: this should be already installed on your Mac, possible after
@@ -40,7 +43,7 @@ this from the same directory as `setup.py`:
./dist/ToggleProxy.app/Contents/MacOS/ToggleProxy

This should output any errors to stdout, so you might get a clue as to why
it's not working. If it warrants an issue-report, you're welcome!
it's not working. If it warrants an issue report, you're welcome!

## Author & License



+ 6
- 7
ToggleProxy.py Näytä tiedosto

@@ -35,9 +35,10 @@ class ToggleProxy(NSObject):

def loadNetworkServices(self):
""" load list of network services """
self.services = {}
for key, dictionary in SCDynamicStoreCopyMultiple(self.store, None, [ 'Setup:/Network/Service/.*/Interface' ]).items():
self.services[dictionary['DeviceName']] = dictionary['UserDefinedName']
self.services = {}
output = commands.getoutput("/usr/sbin/networksetup listnetworkserviceorder")
for service, device in re.findall(r'Hardware Port:\s*(.*?), Device:\s*(.*?)\)', output):
self.services[device] = service

def watchForProxyChanges(self):
""" install a watcher for proxy changes """
@@ -76,10 +77,8 @@ class ToggleProxy(NSObject):

def toggleProxy_(self, sender):
""" callback for clicks on menu item """
event = NSApp.currentEvent()

# Ctrl pressed? if so, quit
if event.modifierFlags() & NSControlKeyMask:
if NSApp.currentEvent().modifierFlags() & NSControlKeyMask:
NSApp.terminate_(self)
return

@@ -88,7 +87,7 @@ class ToggleProxy(NSObject):
NSLog("interface '%s' not found in services?" % self.interface)
return
newstate = self.active and "off" or "on"
commands.getoutput("networksetup setwebproxystate %s %s" % (
commands.getoutput("/usr/sbin/networksetup setwebproxystate %s %s" % (
servicename,
newstate
))


Ladataan…
Peruuta
Tallenna