Ignore:
Timestamp:
01/30/06 19:19:27 (18 years ago)
Author:
Nicholas Riley
Message:

LocationDo.py: in 4111, open NX, move windows around (very brittle,
but seems to work OK), and don't SSH to yt until we can wait for
Kerberos tickets to be valid; at home, ensure Kerberos ticket
validity; add a bunch more locations

action.py: handle both "Expired" and "Expired (IP Address Changed)"
messages from Kerberos; open app with name action needed because NX
Client has no bundle ID or creator; move window action (very rough)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocationDo/action.py

    r205 r212  
    33from AppKit import NSWorkspace
    44from appscript import app, k, its
     5from appscript.specifier import CommandError
    56import os, osax, subprocess, tempfile, SCNetworkReachability
    67
     
    89
    910def ensureKerberosPrincipalsValid(principals):
     11    # XXX still doesn't play well with the automatic ticket renewal the Kerberos app does
    1012    kerberosApp = app(id='edu.mit.Kerberos.KerberosApp')
    11     validPrincipals = kerberosApp.caches.filter(its.time_remaining != 'Expired').principal.get()
     13    validPrincipals = kerberosApp.caches.filter((its.time_remaining.startswith('Expired')).NOT).principal.get()
    1214    for principal in principals:
    1315        if principal not in validPrincipals:
     
    4446    return ws.openFile_withApplication_andDeactivate_(path, None, False)
    4547
     48def openApplicationWithName(name):
     49    ws = NSWorkspace.sharedWorkspace()
     50    return ws.launchApplication_(name)
     51
    4652def setDisplayBrightnessPercent(percent):
    4753    # XXX create brightness module
     
    5864        adiumApp.my_status_message.set(status)
    5965    adiumApp.my_status_type.set(k.available)
     66
     67def moveWindow(appName, windowName, position, ifSizeMatches=None):
     68    # XXX support locations relative to screen corners
     69    systemEventsApp = app(id='com.apple.systemevents')
     70    try:
     71        if ifSizeMatches:
     72            size = tuple(systemEventsApp.processes[appName].windows[windowName].size())
     73            ifSizeMatches = tuple(ifSizeMatches)
     74            if size != ifSizeMatches:
     75                print "Window size didn't match: %s in %s" % (windowName, appName)
     76                print "- Wanted %s, got %s" % (ifSizeMatches, size)
     77                return False
     78        systemEventsApp.processes[appName].windows[windowName].position.set(position)
     79    except CommandError:
     80        print "CommandError: %s in %s" % (windowName, appName)
     81        return False
     82    return True
    6083
    6184def terminalDo(command):
Note: See TracChangeset for help on using the changeset viewer.