This file is indexed.

/usr/lib/python2.7/dist-packages/dispcalGUI/util_mac.py is in dispcalgui 1.7.1.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
# -*- coding: utf-8 -*-

import subprocess as sp
from time import sleep

from meta import name as appname
from options import verbose


def get_osascript_args(applescript):
	""" Return arguments ready to use for osascript """
	if isinstance(applescript, basestring):
		applescript = applescript.splitlines()
	args = []
	for line in applescript:
		args += ['-e', line]
	return args


def get_osascript_args_or_run(applescript, run=True):
	""" Return arguments ready to use for osascript or run the AppleScript """
	if run:
		return osascript(applescript)
	else:
		return get_osascript_args(applescript)


def mac_app_activate(delay=0, mac_app_name="Finder"):
	"""
	Activate (show & bring to front) an application if it is running.
	
	"""
	applescript = [
		'on appIsRunning(appName)',
			'tell application "System Events" to (name of processes) contains '
			'appName',
		'end appIsRunning',
		'if appIsRunning("%s") then' % mac_app_name,
			'tell app "%s" to activate' % mac_app_name,
		'end if'
	]
	if delay:
		sleep(delay)
	return osascript(applescript)


def mac_terminal_do_script(script=None, do=True):
	"""
	Run a script in Terminal.
	
	"""
	applescript = [
		'on appIsRunning(appName)',
			'tell application "System Events" to (name of processes) contains '
			'appName',
		'end appIsRunning',
		'if appIsRunning("Terminal") then',
			'tell app "Terminal"',
				'activate',
				'do script ""',  # Terminal is already running, open a new 
								 # window to make sure it is not blocked by 
								 # another process
			'end tell',
		'else',
			'tell app "Terminal" to activate',  # Terminal is not yet running, 
											    # launch & use first window
		'end if'
	]
	if script:
		applescript += [
			'tell app "Terminal"',
				'do script "%s" in first window' % script.replace('"', '\\"'),
			'end tell'
		]
	return get_osascript_args_or_run(applescript, script and do)


def mac_terminal_set_colors(background="black", cursor="gray", text="gray", 
							text_bold="gray", do=True):
	"""
	Set Terminal colors.
	
	"""
	applescript = [
		'tell app "Terminal"',
		'set background color of first window to "%s"' % background,
		'set cursor color of first window to "%s"' % cursor,
		'set normal text color of first window to "%s"' % text,
		'set bold text color of first window to "%s"' % text_bold,
		'end tell'
	]
	return get_osascript_args_or_run(applescript, do)


def osascript(applescript):
	"""
	Run AppleScript with the 'osascript' command
	
	Return osascript's exit code.
	
	"""
	args = get_osascript_args(applescript)
	p = sp.Popen(['osascript'] + args, stdin=sp.PIPE, stdout=sp.PIPE, 
				 stderr=sp.PIPE)
	output, errors = p.communicate()
	retcode = p.wait()
	return retcode, output, errors