Drinking the Apple Juice
http://blog.drinkingtheapplejuice.com
Drinking the Apple Juice

Mac OS X, Automator and Subversion (SVN) Fun

I finally decided to play around the the Automator application that is part of Mac OS X. I am a big fan of workflow based technologies so I was excited to see what it has to offer.

My goal was to create a Finder Automator plug-in that would display any subversion project that I had modified and needed to be committed back to the repository. To make things even more interesting I decided to use a number of different tasks just to see how they all interact through Automator.

I fired up Automator and got to work.

1. I dragged the "Get Selected Items" action onto the workflow designer window. This is the action that would receive the list of folders I selected from any Finder window.

2. I dragged in the "Get Folder Contents" action. This action would return the list of items (folders) under the subversion repository folder that was selected in step 1.

3. Because Automator does not contain subversion actions (there are CVS ones) I had to go it on my own. I dragged in a "Run Shell Script" action and after much work and syntax frustrations and two other people helping me I ended up with a very small and simple script.

for fn in "$@"
    do
        svn status $fn | grep ^M >nul
        if [ "$?" = "0" ]; then
            p=`echo $fn | awk 'BEGIN{FS="/"} {print $NF}'`
            echo "$p has been modified"
        fi
    done

Automator will pass in the list of items found in step 2. So I created a simple for loop to cycle through them all. For each item I run the subversion status command, pipe it to grep looking for a modified flag. grep will return a code identifying whether or not it found any matches. If the project has any modified files I use awk to strip out just the file name from the full path and turned it into a more readable message.

4a. Now that we have a list of modified projects from step 3 we need to provide feedback on the modified projects. This is where I had some fun by dragging in the "Speak Text" action. Now when the automator workflow is run it will speak what  subversion projects have been modified. Lot's of fun but eventually does get a little old.

4b. To make things a little more bearable and less annoying to my co-workers I decided to modify the workflow to display a pop-up window with the modified projects listed. This is where I was really surprised to find out that Automator does not have any default action for displaying a message.  Therefore I decided to try some AppleScript and dragged in an "AppleScript" action and added the following code.

on run {input, parameters}
   
    if input is not {} then
        if the class of the input is list then
            set s to ""
            repeat with i from 1 to length of input
                set s to s & item i of input & "
"
            end repeat
            display dialog s
        else
            display dialog "No SVN Projects Have been modified"
        end if
    else
        display dialog "No SVN Projects Have Been Modified." buttons {"OK"}
    end if
    return input
end run

The above AppleScript is simply converting the list that is passed in to a large string because the 'display dialog' will not handle the list. There are some quirks with the display dialog; not being able to set the title bar text (there might be a way I but didn't quickly find it); and the window size not growing when there is a lot of text.

5. Finally I saved the Automator workflow as a Finder plug-in which made it accessible off of the finder pop-up menu.

Conclusion:

Automator is a fun tool and has some interesting possibilities. However, its lack of branching actions will limit its use to simple sequential data processing chores.

Mac OS X Leopard Lockup #4


Here we go again. The typical symptom are the same as the last two lockups:

Can’t put Leopard into sleep mode from the Menu or Expose
When I reopen my MacBook and I don’t login in right away the login screen disappears and the only way to get it back is to close the lid again, wait and reopen and quickly login.
Leopard won’t shutdown. I have to hold down the power button.


There appears to be a new Mac OS X 10.5.4 Leopard update tonight, which some have suggested will correct the problem. I am hoping for the best.

Mac OS X Two Month Update

Well it has been two months since my purchase and the start of my conversion from Windows XP. As noted in a previous entry I finally went cold turkey on a 6/9 business trip leaving my Thinkpad behind. Everything went well and I have not had to switch back since then. Although I do occasionally wake up my Thinkpad to utilize as a second development box my MacBook has officially taken over as my primary office and development box.

VMware is still running fast and smooth - a better Windows than Windows. One thing I did notice right away is that ActiveSync is much more stable under VMware. On my Thinkpad I would often have to reboot to restore ActiveSync connectivity - yes, I know about stopping it in task manager and restarting it but that would rarely fix the problem 5% of the time. During my own analysis of ActiveSync failures it appears that it really was not ActiveSync itself that was failing but rather the USB port. By constantly switching between different PDAs and cradles I think the USB port got a slight voltage spike and according to the USB spec when this occurs the driver can disable the port until the computer is rebooted. Because VMware is virtualizing the USB port this no longer appears to be an issue. I will continue tracking this one more closely.

Smart Folders and Spotlight simply rock. I am slowly getting to the point that I no longer care what folders are holding my documents because It is quicker to find them with Spotlight.

Using the keyboard between native Mac OS X and XP running under VMware fusion has definitely been keeping my brain working overtime - no need for Nintendo Brain Age here!

Overall I am really liking my MacBook, almost to the point that I am wondering if the keyboard itself is laced with some sort of chemical at the factory to produce this unexpected enjoyment. I actually now prefer typing on my modern chick-let style keyboard over my old Thinkpad.

I near future entries I plan to detail the Windows Software I left behind in favor of a Mac OS replacement.


VMWare Fusion to Mac OS X Leopard Come in Please...

I have been struggling to setup proper filesystem sharing between my VMware XP instance and Mac. Now I could  simply just checkout the SVN projects within VMWare just fine but I want to keep all my SVN projects checked out on the Mac side for the following reasons:

I don’t want to have to install anything I absolutely need in the VMware XP install. The more I install the slower XP gets - we all know that equation.
Having SVN locally allows Time Machine to backup my files pre check in.
I no longer need XYPlorer (a great utility) installed in XP which I used to quickly search for and in my source files because Mac has this awesome feature called Spotlight

By default VMware created a default read only share to my Mac file system which does allow me read only access from XP. However, it is a little slow, is only read only, and most Windows XP applications (including Visual Studio) fail accessing it because it starts with a . and that can’t be changed.

I tried turning on Mac SMB sharing, with limited success. Access was established but I could never get the read/write permissions to stick properly. I have to admit that Unix file permissions are very weak compared to Windows. This was a long battle which I finally lost do to time and frustration.

I finally resorted to creating another share within VMware with read/write access. Then, within XP, I mapped a drive letter to the share. This eliminated the problem with Windows applications choking on the URL that started with a period.

Several blogs and news group posts reported issues with the VMware share’s reliability, but so far I have not had any issues.

Mac OS X Leopard Lockup #3

Hmmm, same as lockup #2.

Some blogs have suggested it was a Firefox issue, well I am happy to say it is not in my case. I stopped using Firefox and the problem still appeared. Now, I did not uninstall it, but if just having Firefox installed causes such a problem with Mac OS X I would seriously have to reconsider Windows.

Crash #2

I was using my MacBook off and on all day today with no problem. Then I opened it up and staring back at me was the little rainbow spinner. I waited and waited, closed and reopened, waited some more all to no avail. I guess I shouldn't believe all of the marketing hype (of Mac being such a reliable system) after all.

Hard reboot #2 is in the books.


My first solo flight

I am heading out on another business trip, this time (and for the first time) with just my MacBook and not my trusty little Thinkpad. This will be the true test and I hope all goes well...

VPN up and Running

Today is both a happy and sad day. The final piece my my migration puzzle from Windows to Mac is for the most part complete - I have VPN access to my Sonicwall. Of course it came at a sad cost of $199 which was the price of  VPN Tracker. Now I must admit that VPN Tracker seems to be every bit worth its price. The documentation and application are both outstanding - I was connected in about 15 mins.

It is a shame that I had to purchase a VPN client and with the information provided by VPN Tracker I am almost certain I can now get IPSecuritas configured and running. Although I now feel somewhat obligated to VPN Tracked and I really do like their application so I think I will stay with them and use their $79 VPN Player for my other Mac co-workers. 

At some point in time I will revisit the IPSecuritas application to see what I did wrong. But for now I am up and running.

The most advanced operating system in the world - unless you need VPN access.

For an operating system that touts itself as the most advanced in the world yet can't connect to most of the major VPN appliances seems like something straight out of the Microsoft play book.

Obviously I have been struggling (and according to the forums and blogs I am not alone) for quite some to establish a VPN connection to a Sonicwall device over L2TP using Mac's built VPN capabilities.  After many failed attempts is appears that all of the research on the web confirms that it can't be done out of the box and I need to use IPSec VPN.  Of course the most advanced OS in the world does not support IPSec VPN access so I am experimenting with IPSecuritas and so far have managed to get it very close but as of right now still no joy.

Cupertino we have a problem!


Today I had my first system lockup.

I first started realizing something was wrong when my MacBook would no longer enter sleep mode when I moved my cursor to the upper left (as I setup in Expose ). I figured I messed something up so I initially was not too concerned. Later in the day I went to turn on the bluetooth radio - no joy here either. This is when I realized something was very wrong. Time to shutdown and restart - the only problem is that I could not shutdown either. I checked for hanging applications, applications running amuck, the usual suspects  - nothing. I finally had to restore to the old Windows style of holding down the power button.

After restarting everything seemed to be just fine. But this early in the game for a total lockup is troubling - especially when I am still using my Windows based laptop for more hours during the day than my Mac.