#NEWLINE# def WMEnable( name = None ) : #NEWLINE# #INDENT# if ( name is None ) : #NEWLINE# #INDENT# name = os . path . splitext ( os . path . basename ( sys . argv [ 0 ] ) ) [ 0 ] #NEWLINE# #UNINDENT# if isinstance ( name , six . unicode ) : #NEWLINE# #INDENT# name = name . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# if ( not hasattr ( objc , 'loadBundleFunctions' ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# bndl = NSBundle . bundleWithPath_ ( objc . pathForFramework ( '/System/Library/Frameworks/ApplicationServices.framework' ) ) #NEWLINE# if ( bndl is None ) : #NEWLINE# #INDENT# print ( 'ApplicationServices missing' , file = sys . stderr ) #NEWLINE# return False #NEWLINE# #UNINDENT# d = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# app = NSApplication . sharedApplication ( ) #NEWLINE# objc . loadBundleFunctions ( bndl , d , FUNCTIONS ) #NEWLINE# for ( fn , sig ) in FUNCTIONS : #NEWLINE# #INDENT# if ( fn not in d ) : #NEWLINE# #INDENT# print ( 'Missing' , fn , file = sys . stderr ) #NEWLINE# return False #NEWLINE# #UNINDENT# #UNINDENT# ( err , psn ) = d [ 'GetCurrentProcess' ] ( ) #NEWLINE# if err : #NEWLINE# #INDENT# print ( 'GetCurrentProcess' , ( err , psn ) , file = sys . stderr ) #NEWLINE# return False #NEWLINE# #UNINDENT# err = d [ 'CPSSetProcessName' ] ( psn , name ) #NEWLINE# if err : #NEWLINE# #INDENT# print ( 'CPSSetProcessName' , ( err , psn ) , file = sys . stderr ) #NEWLINE# return False #NEWLINE# #UNINDENT# err = d [ 'CPSEnableForegroundOperation' ] ( psn ) #NEWLINE# if err : #NEWLINE# #INDENT# print ( 'CPSEnableForegroundOperation' , ( err , psn ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# err = d [ 'SetFrontProcess' ] ( psn ) #NEWLINE# if err : #NEWLINE# #INDENT# print ( 'SetFrontProcess' , ( err , psn ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True