Minor Eclipse util plugin

Posted by emil on February 28th, 2006

Workbench Restart ActionI have discovered that during development in Eclipse, you sometimes have to restart the workbench for various reasons. The "File->Switch workspace" feature is ok for that I guess, but sometimes when you are working with several different workspaces, the value in the switch workspace dialog is not in sync with what you are currently using - which will cause some unecessary delay.

Since it is so little effort needed creating something that just restarts from the current workspace, I decided to create a plug-in for it and publish it for anyone who feel the need to be able to restart Eclipse swiftly.

The only piece of code needed (except the bulk of plugin.xml, manifest etc..) is these lines in the action:

JAVA:
  1. public void run(IAction action) {
  2.     PlatformUI.getWorkbench().restart();
  3. }

And of course this little piece of code in the plugin.xml:

XML:
  1. <extension point="org.eclipse.ui.actionSets">
  2.     <actionset label="Restart set"
  3.         visible="true"
  4.         id="org.buglix.workspacerestarter.restart">
  5.         <action label="Restart workbench"
  6.             class="org.buglix.workspacerestarter.Action"
  7.             id="org.buglix.workspacerestarter.Action"
  8.             menubarPath="file/exit.ext" />
  9.     </actionset>
  10. </extension>

You can install the plug-in via my Eclipse update site http://buglix.org/update/, or download as a zip-file with source here.

Portage update checker

Posted by emil on February 27th, 2006

Here is a little script I once wrote to check if new updates exists in the Portage Tree (Gentoo). If so, it sends an e-mail to the owner of the script. Run it as a cron job and don't forget to change user_address and smtpserver.

PYTHON:
  1. #!/usr/bin/python
  2. # Copyright Emil Erlandsson 2005
  3. import os,smtplib
  4.  
  5. user_address = "receivers address"
  6. smtpserver = "some_smtp_server"
  7.  
  8. if os.spawnvp(os.P_WAIT, "emerge", ["emerge", "sync"]) == 0:
  9.     pipe = os.popen("emerge -vupD world", "r")
  10.     lines = []
  11.     for line in pipe.readlines():
  12.         if "ebuild" in line:
  13.             lines.append(line)
  14.  
  15.     if len(lines)> 0:
  16.         hostname = os.popen("hostname", "r").read().strip()
  17.         uptime = os.popen("uptime", "r").read().strip()
  18.         server = smtplib.SMTP(smtpserver)
  19.         msg = "Subject: New updates in your Gentoo distribution @%s\n\nThere are %d new updates.\n\nHere is a list of them:" % (hostname, len(lines))
  20.         for line in lines:
  21.             msg += line
  22.         msg += "\n\n\n/Your local Gentoo Gnome\n\nSysinfo: %s" % uptime
  23.         server.sendmail(user_address,user_address,msg)
  24.         server.close()
  25. else:
  26.     print "emerge sync failed..."

Hello world!

Posted by emil on February 25th, 2006

My previous installation of WordPress was completely FUBAR, so I dumped my database to a file and re-installed it completely. Now I've been able to salvage some of my previous posts, but sadly far from all. Perhaps I will upload them later when I have more time.