Skip to content

Commit

Permalink
Added reachability (check wifi vs 3g)
Browse files Browse the repository at this point in the history
  • Loading branch information
jon b committed Mar 27, 2016
1 parent dcc2bd0 commit caab932
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions reachability.py
@@ -0,0 +1,20 @@
# coding: utf-8
from objc_util import *

NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/SoftwareUpdateServices.framework').load()

def currentNetworkType():
''' 0: none
1: wifi
2+: cellular'''
netMon=ObjCClass('SUNetworkMonitor').sharedInstance()
return netMon.currentNetworkType()
def main():
networkType=currentNetworkType()
assert networkType>0, 'Network Not Connected'
if networkType>1:
ok_to_continue=raw_input('Using cellular data. Continue downloading? [y/n]')
assert ok_to_continue.lower()=='y', 'User Cancelled'

if __name__=='__main__':
main()

0 comments on commit caab932

Please sign in to comment.