Changeset 212


Ignore:
Timestamp:
01/30/06 19:19:27 (19 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)

Location:
trunk/LocationDo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocationDo/LocationDo.py

    r205 r212  
    7878    if '4111 SC' in location:
    7979        action.openInBackground('~/Documents/Research/Research progress.oo3')
    80         # XXX wait for yt to be accessible
    81         # XXX start NX
    82         # XXX move windows
    83         action.terminalDo('kswitch -p njriley@ACM.UIUC.EDU;(sleep 10;kswitch -p njriley@AD.UIUC.EDU)&! ;clear;ssh yt')
     80        # XXX complain that NX has no creator nor bundle ID
     81        action.openApplicationWithName('NX Client for OSX')
     82        # XXX make these changes dependent on screen resolution
     83        action.moveWindow('iTunes', 'iTunes', (2123, 1534), ifSizeMatches=(129, 65))
     84        action.moveWindow('Adium', 'Contacts', (1280, 1553))
     85        action.moveWindow('Adium', 'AOL System Msg', (1448, 1320))
     86        # XXX need better way to do this
     87        action.moveWindow('OmniOutliner Pro', 'Research progress', (1634, 847))
     88        action.moveWindow('OmniOutliner Pro', '◇ Research progress', (1634, 847))
     89        # XXX wait for yt to be accessible and Kerberos, then open the terminal window
     90        # action.terminalDo('kswitch -p njriley@ACM.UIUC.EDU;(sleep 10;kswitch -p njriley@AD.UIUC.EDU)&! ;clear;ssh yt')
    8491        action.setDisplayBrightnessPercent(0.9)
    8592        action.setAdiumStatus('Working in 4111 SC')
     
    8996        action.setAdiumStatus('At ACM')
    9097    if 'Champaign' in location:
     98        action.ensureKerberosPrincipalsValid(['njriley@ACM.UIUC.EDU',
     99                                              'njriley@AD.UIUC.EDU'])
    91100        action.openInBackground('~/Documents/To do.oo3')
    92101        action.setDisplayBrightnessPercent(0.2)
     
    158167                    elif bssid == '00:13:c4:ce:66:a0':
    159168                        location.add('13[12]0 DCL')
     169                    elif bssid in ['00:0e:83:05:78:02', '00:0e:83:05:77:42']:
     170                        location.add('1304 SC')
     171                    elif bssid == '00:0e:83:05:78:a2':
     172                        location.add('3124 SC')
     173                    elif bssid == '00:0e:83:05:76:b2':
     174                        location.add('Siebel 2nd floor atrium')
    160175                    elif bssid in ['00:14:1c:ad:5c:80', '00:14:1c:ad:64:50']:
    161176                        location.add('MEB')
    162177                    elif bssid == '00:02:2d:2c:cb:34':
    163178                        location.add('B02 CSL')
     179                    elif bssid == '00:11:5c:fe:31:00':
     180                        location.add('CAB')
    164181                    elif bssid == '00:13:c4:78:e1:a0':
    165182                        location.add('Engineering Hall')
     183                    elif bssid in ['00:0c:30:d4:b7:2d', '00:0c:30:d4:b6:70']:
     184                        location.add('Illini Union')
    166185                    elif bssid == '00:0d:93:ed:e0:bc':
    167186                        location.add('340 Marlborough St.')
    168187                    elif bssid == '00:40:96:5a:5e:0f':
    169188                        location.add('BMI baggage claim')
     189                    elif bssid == '00:12:0e:10:1f:83':
     190                        location.add('Waterville Valley')
    170191                    elif bssid == '44:44:44:44:44:44':
    171192                        location.add('No AirPort network')
     
    192213                    elif ssid == 'Wackyland':
    193214                        location.add('340 Marlborough St.')
     215                    elif ssid == '05B408706826':
     216                        location.add('Waterville Valley')
    194217                    elif ssid == 'CIRA':
    195218                        location.add('BMI')
  • 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.