wxPython

Maybe I’m just being crazy, but I’m not really finding wxPython particularly pythonic. For instance, I’m trying to make a fairly simple application that has a SplitterWindow, and I seem to have to do a whole lot of sub-classing to actually get it to work. Feels more like Java than Python. Which I’m really not keen on doing.

Notice • Gomez • Chillout Sessions 9

Getting Finder Comments in different languages

bash: mdls filename | grep FinderComment AppleScript: tell application "Finder"     comment of file end tell python: #!/usr/bin/pythonw from appscript import * path = '/Users/NAME/your/path/here' comment = app('Finder').items[path.replace('/', ':')].comment.get()

NSLU2 and USB 2.0 Hubs

Having more than two USB drives with an NSLU2 is possible, if you are using a firmware other than the original Linksys rubbish. Some people report having gotten some hubs to work fine. I originally had both drives working using a spare 1.0 hub I had lying around, but it was dog slow. So I bought a 2.0 hub. This worked for the first couple of gigs it copied across from another disk, but then reported errors. It appeared the device just decided to unmount and remount in a different place. I went and bought another hub today, from a different shop. Same problems. I think they are actually the same hub in different packaging, but another 2.0 hub I have lying about fails worse - the drives don’t even mount to begin with. So I went for plan D. It seems that the USB controller chip used can drive up to 5 USB ports, so I cut a USB extension cable, and wired it onto the board in the correct locations. Didn’t work. Disconnecting made it work again. Finally, I was able to get it to work by not using the power connections on the other port, but the +5V and GND locations elsewhere on the board. This was the only way I was able to get the NSLU2 to still boot with the extra port connected. I may have been able to use unpowered ports. That might be cooler. I just thought that the PSU might not be +5V, in which case stuff could go badly wrong. Better check…

Eve Online login window CPU hog

Eve Online has a daily system restart, and when this happens, I sometimes leave the login window open, so I can keep checking and log back in as soon as downtime finishes. However, I’ve noticed that the login screen seems to consume a heck of a lot more CPU cycles than the application itself. Interesting.

USB1.0 is s...l...o...w

Man, 12 Mbit/s is slow. I’ve got a USB 1.0 “full-speed” hub, and tried to copy across 60GB of files. In about 18 hours, that was only about 3GB copied… So I bought a USB 2.0 hub, and that is much faster.

Preparing a Disk for OpenSlug

I got a new 250GB USB drive today, and plugged in a hub into my NSLU2, and connected this up. These are the commands I needed to execute to get it all set up (it was an NTFS formatted disk initially).

First of all, use dmesg to ensure the disk has been recognised and mounted. I had to change from my USB2.0 hub to a USB1.0 hub. I’ll get a new 2.0 hub in the next few days to try that out. Apparently some of them don’t work.

From dmesg, the hub has been recognised:

usb 2-1.1: new full speed USB device using ohci_hcd and address 3 usb 2-1.1: not running at top speed; connect to a high speed hub

The new disk has been mounted as an NTFS (dirty) disk:

NTFS volume version 3.1. NTFS-fs error (device sdc1): load_system_files(): $LogFile is not clean. Mounting read-only. Mount in Windows.

Things to note:

  • the device name in this case is /dev/sdc1. This is the third USB device in my chain.

  • /dev/sda(1,2,3) are the root, swap and user partitions on the boot disk,

  • /dev/sdb1 is the first 250GB drive I bought.

    nslu2:~ root$ umount /media/sdc1/ nslu2:~ root$ fdisk /dev/sdc1/

Then you will need to delete the partition (d), and create a new one (n). (p): Primary partition, #1, accept default start and end blocks.

Then use (w) to write the partition out to disk.

nslu2:~ root$ reboot

Wait for the machine to reboot fully.

nslu2:~ root$ umount /media/sdc1/ 
nslu2:~ root$ mkfs.ext3 /dev/sdc1 mke2fs 1.38 (30-Jun-2005) ...

It takes a while to process. Worthwhile rebooting after this just to be sure.

All done.

Waiting for an Application to launch

I use an AppleScript to implement “Open Terminal Here” functionality on my Macs, and just now I noticed on the Intel machine it had stopped working properly if Terminal wasn’t already running. For some reason, on PPC it still sends the message through, but on x86 it doesn’t. So, I had to use the following code to get it to work if Terminal wasn’t already running, which can be generalised to any application: repeat while "Terminal" is not in name of processes     delay 0.5 end repeat The whole script, which can be saved as an application bundle, set to not show in dock, and then placed in the Toolbar:

 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
    -- when the toolbar script icon is clicked
    --
    on run
    	tell application "Finder"
    		activate
    		try
    			set this_folder to (the target of the front window) as alias
    			--display dialog POSIX path of this_folder
    		on error
    			set this_folder to startup disk as alias
    		end try
    		my process_item(this_folder)
    	end tell
    end run
    
    
    
    -- This handler processes folders dropped onto the toolbar script icon
    --
    on open these_items
    	repeat with i from 1 to the count of these_items
    		set this_item to item i of these_items
    		my process_item(this_item)
    	end repeat
    end open
    
    
    -- this subroutine processes does the actual work
    --
    on process_item(this_item)
    	tell application "System Events"
    		try
    			get process "Terminal"
    			
    			tell application "Terminal"
    				activate
    				do script "cd " & (quoted form of POSIX path of this_item)
    			end tell
    		on error -- Terminal Not running, launch and run in first window.
    			launch application "Terminal"
    			-- May need to wait until Terminal finishes launching
    			repeat while "Terminal" is not in name of processes
    				delay 0.5
    			end repeat
    			tell application "Terminal"
    				activate
    				-- So we don't create a new window: in window 1
    				do script "cd " & (quoted form of POSIX path of this_item) in window 1
    			end tell
    		end try
    	end tell
    end process_item
    

Installing Missing Sync on a Hackintosh

I am a registered user of Missing Sync for PalmOS, but it wouldn’t install on my Dell running OS X. Easy to fix: copy the installer package somewhere writable, and then open the package, find the file Contents/Resources/InstallationCheck. Edit this file in a text editor (luckily, they made it a bash script!), and before the final line (exit $RETVAL), insert: exit 0 Crude hack, but it gets it installed. Now to reboot and see if it will actually run!

Reinstalling Windows, Again

Here I go, reinstalling WinXP for the umpteenth time this week. I seem to have some corrupted files which prevents me from running all but the most simple of applications. Including IE, and Firefox, btw.

Mounting a share before running an application

I have all of my Music, Movies and TV shows stored digitally on a server, located just below my feet at the moment, but soon to be shifted to another location. This server just runs SMB file sharing, and provides access to the same files, as well as a heap of other data, to all of the machines in my network. It also provides easy access to media and installers for guest users, too. The one thing I like about Windows1 over OS X is that you can have shares set to auto-mount on bootup. I used to use an AppleScript to do this, which was okay, except OS X still disconnects when you sleep. Not that I sleep my machine much, anyway. Then today, I read a great hint on MacOSXHints: Make sure iTunes mounts a networked music library. Basically, instead of running iTunes from the location it is installed in, you create an alias on the music server volume, and run it (via another alias back into the dock) from there. Then, before loading iTunes, it mounts the volume, if it can find it. Otherwise, iTunes will not run. Which is fine by me, since all of my music is on that server!

  1. Mind you, Windows does have some other crappiness in conjunction with this. Lately, I’ve been finding that it won’t always mount all of the shares, even though I chose automatically mount after rebooting, and it sometimes forgets my passwords. Similarly, you cannot connect more than once to a server with different credentials. I mean, seriously?