Changes

From Amahi Wiki
Jump to: navigation, search
2,748 bytes added ,  02:28, 2 April 2014
echo}}
==Weather==
{{Code|<pre>#!/bin/sh
METRIC<nowiki>=</nowiki>0 # 0 for F, 1 for C
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\<nowiki>=</nowiki>${METRIC}\&locCode\<nowiki>=</nowiki>$LOCCOD \
<nowiki>|</nowiki> sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'}}</pre> = A Log Checking Utility = Here is a simple script that displays all of the file updates and additions made to your hda and the date they happened. It simply reads the hda-updates.log file and parses out only the relevant changes. I use this script periodically so I can see what might have changed recently. '''Installation''' Log into your hda and create a bin directory under your home directory (if you don't already have one). The reason for this is that ~/bin is already in your $PATH when you log in, so it will automatically find any scripts you put there: cd /usr/bin Open up your favorite editor (I suggest gedit for this) and copy the code that follows into the editor. Save the file as '''hda-updates''' (or whatever you want to name it) and exit the editor. '''Code:'''<pre>#!/usr/bin/python## Dump update information from /var/log/hda-updates.log#!/usr/bin/python## Display the date and files that were modified/installed.## Reads the hda-updates log file and parses out just the file updates/additions.# It helps to see what has been modified and when.## radioz# 11/8/2010# log = '/var/log/hda-updates.log' f = open(log, 'r')lines = f.readlines()f.close() gotUpdates = FalsefirstUpdate = FalsedateInfo = ''for ll in lines : l = ll.strip() # Ignore dependency heading if l == 'Installing for dependencies:' : continue if l == '' : # A blank line terminates the updates for a particular date if gotUpdates : # Display a blank line between dates print gotUpdates = False continue if gotUpdates : if firstUpdate : # Display the date above the first update print '%s:' % dateInfo firstUpdate = False # Reformat the file info slightly updateInfo = l.split() print ' %-16s %-6s %-20s %-16s %-5s %s' % (tuple(updateInfo)) if 'hda update attempt' in l : # This header appears once per hour in the log. Very few represent real updates. # Save the date information in case this is a real update. dateInfo = ' '.join(l.split()[5:]) if 'Updating:' in l : # This is a real update, set up the flags gotUpdates = True firstUpdate = True</pre> Make the file executable: chmod +x hda-updates Now you can run it. '''Example'''  hda-updates Here is a snippet of its output on my system:  Sat Sep 4 15:02:32 PDT 2010: hdactl i386 3.5.1-1 amahi 218 k Sat Oct 30 22:02:14 PDT 2010: hda-greyhole i386 0.6.28-1 amahi 47 k hda-platform noarch 5.6-1 amahi 1.0 M hdactl i386 3.6-1 amahi 218 k Sun Nov 7 20:01:29 PST 2010: hda-platform noarch 5.6-8 amahi 1.0 M
12,424

edits