Permalink
Browse files

things:

 - cleanup
 - some more friendly text
 - nodeutil.took = float containing retrieval time
 - installer prompts about killing gnome-panel, tries to do awn too (issue with determining which user awn should be started as)
  • Loading branch information...
1 parent 7d3cff3 commit 9f9b49cf7a6dee83767a13a3837875060c6da382 Dale Maggee committed Oct 2, 2011
Showing with 64 additions and 19 deletions.
  1. +5 −3 create-self-extractor.sh
  2. +20 −10 internode-usage-report
  3. +21 −3 internode/nodeutil.py
  4. +18 −3 setup.sh
View
@@ -27,8 +27,8 @@ output_extract_script() {
cat <<EndOfHeader
#!/bin/bash
echo "Self-extracting bash script. By Dale Maggee."
-echo "Extracting..."
target=\`mktemp -d /tmp/XXXXXXXXX\`
+echo -n "Extracting to \$target..."
EndOfHeader
@@ -45,19 +45,21 @@ fi
cat <<EndOfFooter
-echo "(temp dir: \$target)"
-
#do the extraction...
ARCHIVE=\`awk '/^---BEGIN TGZ DATA---/ {print NR + 1; exit 0; }' \$0\`
tail -n+\$ARCHIVE \$0 | tar xz -C \$target
+echo -en ", Done.\nRunning Installer..."
+
CDIR=\`pwd\`
cd \$target
./installer
+echo -en ", Done.\nRemoving temp dir..."
cd \$CDIR
rm -rf \$target
+echo -e ", Done!\n\nAll Done!\n"
exit 0
---BEGIN TGZ DATA---
View
@@ -7,16 +7,26 @@
from internode.nodeutil import *
from optparse import OptionParser
-p = OptionParser(usage="Usage: %prog [options]\n\nRetrieves and displays stats on your Internode usage.",version="NodeUtil v%2.1f." % VERSION)
-p.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, help="Show more output")
-p.add_option("-s","--short", action="store_true",dest="short", default=False, help="Show short text (format: '<label>: <number> <unit>')")
-p.add_option("-H","--hunam-readable", action="store_true", dest="hunam_mode", default=False, help="Hunam-readable mode - program output is optimised for sapient lifeforms. This option supersedes everything below, and is the default mode if no options are passed.")
+p = OptionParser( usage="Usage: %%prog [options]\n\nRetrieves and displays stats on your Internode usage.\n\nIn order to be useful for scripting purposes, 'Internode report'-type info (e.g: Usage Report / Error messages) are sent to STDOUT, while things like status information (e.g: 'fetching') and log messages (when -v is used) are sent to STDERR.\n\nPart of the NodeUtils Suite v%2.1f, (C)opyright Dale Maggee, 2011. BSD License." % VERSION,
+ version="NodeUtil v%2.1f." % VERSION )
-p.add_option("-u","--show-used",action="store_true",dest="used", default=True,help="Show Used Data")
-p.add_option("-r","--show-remaining",action="store_true",dest="remaining", default="True",help="Show Remaining Data")
-p.add_option("-q","--show-quota",action="store_true",dest="quota", default=True,help="Show Quota")
+p.add_option( "-v", "--verbose", action="store_true", dest="verbose", default=False, help="Show more output" )
-p.add_option("-c","--csv-history",action="store_true",dest="csv",default=False,help="Output usage history data as a comma-separated table. Supersedes all other options.")
+p.add_option( "-s", "--short", action="store_true",dest="short", default=False,
+ help="Show short text (format: '<label>: <number> <unit>')" )
+
+p.add_option( "-H", "--hunam-readable", action="store_true", dest="hunam_mode", default=False,
+ help="Hunam-readable mode - program output is optimised for sapient lifeforms. This option supersedes everything below, and is the default mode if no options are passed.")
+
+p.add_option( "-u", "--show-used", action="store_true", dest="used", default=True, help="Show Used Data" )
+
+p.add_option( "-r", "--show-remaining", action="store_true", dest="remaining", default="True",
+ help="Show Remaining Data")
+
+p.add_option( "-q", "--show-quota", action="store_true", dest="quota", default=True, help="Show Quota" )
+
+p.add_option( "-c", "--csv-history", action="store_true", dest="csv", default=False,
+ help="Output usage history data as a comma-separated table. Supersedes all other options." )
#Parse command line...
(options, args) = p.parse_args()
@@ -43,7 +53,7 @@ while node.status == "Updating":
time.sleep(0.5)
if node.status == "OK":
- errprint("Usage data retrieved successfully.\n")
+ errprint("Usage data retrieved successfully (%2.3f seconds).\n" % node.took)
print "----------------------------------------------"
print "Internode Usage for: %s" % node.username
print "----------------------------------------------"
@@ -53,6 +63,6 @@ if node.status == "OK":
print " - This gives you %2.2f MB / day." % (node.remaining / node.daysleft)
print "\n"
else:
- errprint("There was an error retrieving usage data! >:(\n")
+ errprint("Error (%2.3f seconds): %s\n" % (node.took, node.error))
sys.exit(1)
View
@@ -111,6 +111,8 @@ def __init__(self):
self.show_used = False
self._time = 0
+ #how long retrieval took
+ self._took = 0
self._percent_used = 0
self._percent_remaining = 0
self._quota = 0
@@ -202,6 +204,17 @@ def set_time(self,value):
self._time = value
time = property(get_time,set_time)
+ # self.took is a float giving us the number of seconds
+ # we spent updating (i.e: how long it took to retrieve
+ # data from internode)
+ def get_took(self):
+ with self.lock:
+ return self._took
+ def set_took(self,value):
+ with self.lock:
+ self._took = value
+ took = property(get_took,set_took)
+
def get_percent_used(self):
with self.lock:
return self._percent_used
@@ -564,15 +577,20 @@ def update_thread_func(self):
if self.status != "Error": self.get_history(service)
if self.status != "Error": self.get_service_info(service)
if self.status != "Error": self.ip = self.fetch_ip_address()
-
- if (self.status == "Updating"):
+
+ #don't set status to OK if an error occurred:
+ if (self.status != "Error"):
self.status = "OK"
except:
if self.status != "Error": #don't overwrite existing error message
self.status = "Error"
self.set_error("An unexpected error occurred")
- log("Nodeutil.update complete")
+ #calculate how long we took and populate self.took
+ took = time.time() - self.time
+ self.took = took
+ log("Nodeutil.update complete after %2.3f seconds" % took)
+
#thread.interrupt_main()
#thread exits silently...
View
@@ -152,16 +152,31 @@ fi
echo " - Installing 'internode-usage-report' command-line app..."
ln -s $APPPATH/internode-usage-report /usr/bin/internode-usage-report
#everything's perfect, tell the user how to get the applets
+echo "-------------------------------------------------------------------------------"
echo -e "\n\nInstallation is complete. You'll need to restart the relevant program(s) with commands like:"
if [ -n "$AWNPREFIX" ]; then
echo " killall avant-window-navigator && avant-window-navigator &"
fi
if [ -n "$GNOMEPREFIX" ]; then
- killall gnome-panel
- echo " killall gnome-panel (shouldn't be required - I just ran this - your panel should be restarting now!)"
+ echo " killall gnome-panel"
fi
-echo -e "Or you can just log out and back in. or reboot. or alt-prtscn-k. or maybe ctrl-alt-bksp. or sudo killall xinit."
+echo -e "Or you can just log out and back in.\n"
echo -e "Once you've restarted your panel app(s), you should be able to add the internode applet to the Gnome panel and/or AWN\n"
+read -p "Shall I try to restart your panel app(s) now (Y/N)?" c
+if [ -n "`echo $c | egrep '[Yy]([Ee][Ss])?'`" ]; then
+ if [ -n "$GNOMEPREFIX" ]; then
+ echo " - Killing gnome-panel..."
+ killall gnome-panel
+ fi
+ if [ -n "$AWNPREFIX" ]; then
+ echo " - Killing avant-window-navigator..."
+ killall avant-window-navigator
+ sudo -u1000 avant-window-navigator &
+ echo " NOTE: You'll probably have to run 'avant-window-navigator' yourself"
+ fi
+ echo -e "Done!\n\n"
+fi
+
echo -e "You can get a usage report from the command-line by typing 'internode-usage-report'.\n"
echo "You can also run '$APPPATH/run_in_window' to get the GNOME applet in it's own small window."
echo -e "\nIf you have problems, check out /tmp/internode-applet.log. You can also email this file to antisol@internode.on.net with 'internode applet' in the subject."

0 comments on commit 9f9b49c

Please sign in to comment.