def attach(afp_url):
    applescript_template = '''
        set mountedDiskName to "AirPort Time Capsule"
        set diskIsMounted to false

        on isDiskMounted(diskName)
            tell application "System Events" to set diskNames to name of every disk
            return diskName is in diskNames
        end isDiskMounted


        on mountAFP(afpURL, diskName)
            set folderPath to "/Volumes/" & diskName
            do shell script "/bin/mkdir -p " & folderPath
            try
                do shell script "/sbin/mount_afp " & afpURL & " " & folderPath
            on error err
                do shell script "/bin/rmdir " & folderPath
            end try
        end mountAFP


        if not isDiskMounted("{1}") then
            mountAFP("{0}", "{1}")
        end if
    '''
    drive_name = os.path.split(afp_url)[1]
    processutil.call(['osascript', '-e', applescript_template.format(afp_url, drive_name)])
Beispiel #2
0
def open(app_name):
    script = '''
        if application "%s" is not running then
            tell application "%s" to activate
        end if
        ''' % (app_name, app_name)

    processutil.call(['/usr/bin/osascript', '-e', script])
Beispiel #3
0
def call(parameters):
    command = parameters["command"]
    cwd = parameters.get('cwd', None)
    ret_code, out, err = processutil.call(command, cwd=cwd)

    logutil.info('Return Code', str(ret_code))
    logutil.info('Output', out)
    logutil.info('Error', err)
Beispiel #4
0
def update():
    if not os.path.exists('/usr/local/bin/terminal-notifier'):
        processutil.call(['/usr/local/bin/brew', 'install', 'terminal-notifier'])

    command = ['pip3', 'install', '-r', 'requirements.txt', '-U']
    processutil.call(command)

    command = ['python3', 'setup.py', 'py2app']
    processutil.call(command)

    if os.path.exists(SYMLINK_PATH):
        os.remove(SYMLINK_PATH)

    shutil.move(os.path.abspath(os.path.join('dist', APP_NAME)), DST_PATH)
    shutil.rmtree('dist')
    shutil.rmtree('build')
    os.symlink(DST_PATH, SYMLINK_PATH)
Beispiel #5
0
def close(app_name):
    script = 'tell application "%s" to quit' % app_name
    processutil.call(['/usr/bin/osascript', '-e', script])
def detach(volume_name):
    processutil.call(['hdiutil', 'detach', '/Volumes/%s' % volume_name])