Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to run blockfinder (patched to run in cron without requiring a TTY), and then report the daily differences via email to the user running the script.
#!/bin/bash
TODAY=`date "+%Y-%m-%d"`
case $OSTYPE in
darwin*) YESTERDAY=`date -v -1d "+%Y-%m-%d"` ;;
linux*) YESTERDAY=`date --date="yesterday" "+%Y-%m-%d"` ;;
*bsd*) YESTERDAY=`date -v -1d "+%Y-%m-%d"` ;;
*) echo "unknown: $OSTYPE" ;;
esac
cd ~/dev/github/blockfinder
./blockfinder -i > /dev/null
./blockfinder -v -t ca:asn > ca-asn-$TODAY.txt
/usr/bin/diff -u ca-asn-$YESTERDAY.txt ca-asn-$TODAY.txt |\
mail -s "[ASN-diffs] Canada $TODAY" `whoami`
diff --git a/blockfinder b/blockfinder
index a53de9f..b5aaa81 100755
--- a/blockfinder
+++ b/blockfinder
@@ -524,23 +524,7 @@ class DownloaderParser:
def _update_progress_bar(self, received_bytes, expected_bytes,
seconds_elapsed):
""" Write a progress bar to the console. """
- if is_win32:
- rows = 100 # use some WinCon function for these?
- columns = 80 # but not really important.
- EOL = "\r"
- else:
- rows, columns = list(map(int, os.popen('stty size', 'r'
- ).read().split()))
- EOL = "\x1b[G"
- if seconds_elapsed == 0:
- seconds_elapsed = 1
- percent_done = float(received_bytes) / float(expected_bytes)
- caption = "%.2f K/s" % (received_bytes / 1024 / seconds_elapsed)
- width = columns - 4 - len(caption)
- sys.stdout.write("[%s>%s] %s%s" % (
- "=" * int(percent_done * width),
- "." * (width - int(percent_done * width)), caption, EOL))
- sys.stdout.flush()
+ pass
def check_rir_file_mtimes(self):
""" Return True if the mtime of any RIR file in our cache directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment