From 59ccc0fd871c4bbd12066f2f6aacf835a839885d Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 8 Feb 2013 10:10:43 +0000 Subject: add nodes-to-json: parses retiolum/hosts folder into json --- retiolum/bin/find-supernodes | 21 ++++++++++++++++++ retiolum/bin/my-ip | 2 -- retiolum/bin/nodes-to-json.py | 37 ++++++++++++++++++++++++++++++++ retiolum/scripts/adv_graphgen/find_super | 21 ------------------ 4 files changed, 58 insertions(+), 23 deletions(-) create mode 100755 retiolum/bin/find-supernodes delete mode 100755 retiolum/bin/my-ip create mode 100644 retiolum/bin/nodes-to-json.py delete mode 100755 retiolum/scripts/adv_graphgen/find_super diff --git a/retiolum/bin/find-supernodes b/retiolum/bin/find-supernodes new file mode 100755 index 00000000..2c316d0e --- /dev/null +++ b/retiolum/bin/find-supernodes @@ -0,0 +1,21 @@ +#! /bin/dash +set -eu +cd /etc/tinc/retiolum/hosts +for name in ` + grep '^[[:space:]]*Address[[:space:]]*=' * | + cut -d: -f1 | sort | uniq +`; do + if eval "`sed -n ' + s/[[:space:]]\+//g + s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p + ' $name`"; then + port=${Port-655} + for host in $Address; do + if nc -zw 2 $host $port 2>/dev/null; then + echo "$name [('$host', $port)]" + fi & + done + wait + fi & +done +wait diff --git a/retiolum/bin/my-ip b/retiolum/bin/my-ip deleted file mode 100755 index fcfbba05..00000000 --- a/retiolum/bin/my-ip +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -curl http://euer.krebsco.de/live/ip.php diff --git a/retiolum/bin/nodes-to-json.py b/retiolum/bin/nodes-to-json.py new file mode 100644 index 00000000..ca9d3c8c --- /dev/null +++ b/retiolum/bin/nodes-to-json.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +def parse_hosts_path(path="/etc/tinc/retiolum/hosts"): + import os + import re + + needle_addr = re.compile("Subnet\s*=\s*(.*)/[0-9]+") + needle_port = re.compile("Port\s*=\s*(.*)") + for f in os.listdir(path): + with open(path+"/"+f) as of: + addrs = [] + port = "655" + + for line in of.readlines(): + + addr_found = needle_addr.match(line) + if addr_found: + addrs.append(addr_found.group(1)) + + port_found = needle_port.match(line) + if port_found: + port = port_found.group(1) + + if addrs : yield (f ,[(addr ,int(port)) for addr in addrs]) + + + +if __name__ == "__main__": + """ + usage + """ + import json + import sys + db={} + for host,addrs in parse_hosts_path(sys.argv[1] if len(sys.argv) > 2 else "/etc/tinc/retiolum/hosts"): + db[host] = addrs + print(json.dumps(db)) diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super deleted file mode 100755 index 2c316d0e..00000000 --- a/retiolum/scripts/adv_graphgen/find_super +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/dash -set -eu -cd /etc/tinc/retiolum/hosts -for name in ` - grep '^[[:space:]]*Address[[:space:]]*=' * | - cut -d: -f1 | sort | uniq -`; do - if eval "`sed -n ' - s/[[:space:]]\+//g - s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p - ' $name`"; then - port=${Port-655} - for host in $Address; do - if nc -zw 2 $host $port 2>/dev/null; then - echo "$name [('$host', $port)]" - fi & - done - wait - fi & -done -wait -- cgit v1.2.3 From d7ff9d79f3a7a589e92dd4eec835953af5fea21f Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 8 Feb 2013 17:09:18 +0100 Subject: added comments and better stringsplit --- ircbot/bot.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ircbot/bot.py b/ircbot/bot.py index 607e65c7..25a1014f 100755 --- a/ircbot/bot.py +++ b/ircbot/bot.py @@ -18,7 +18,11 @@ class TestBot(irc.bot.SingleServerIRCBot): self.oldnews = [] self.sendqueue = [] for entry in self.feed.entries: - self.sendqueue.append(entry.title + " " + entry.link) + try: + self.sendqueue.append(entry.title + " " + entry.link + " com: " + entry.comments) + except AttributeError: + self.sendqueue.append(entry.title + " " + entry.link) + self.oldnews.append(entry.link) def start(self): @@ -32,7 +36,10 @@ class TestBot(irc.bot.SingleServerIRCBot): self.feed = feedparser.parse(self.url) for entry in self.feed.entries: if not entry.link in self.oldnews: - self.send(entry.title + " " + entry.link) + try: + self.send(entry.title + " " + entry.link + " com: " + entry.comments) + except AttributeError: + self.send(entry.title + " " + entry.link) self.oldnews.append(entry.link) def sendall(self): @@ -44,8 +51,11 @@ class TestBot(irc.bot.SingleServerIRCBot): if len(string) < 450: self.connection.privmsg(self.chan, string) else: - for x in range(math.ceil(len(string)/450)): - self.connection.privmsg(self.chan, string[x*450:(x+1)*450]) + space = 0 + for x in range(math.ceil(len(string)/400)): + oldspace = space + space = string.find(" ", (x+1)*400, (x+1)*400+50) + self.connection.privmsg(self.chan, string[oldspace:space]) sleep(1) -- cgit v1.2.3 From 4107615bf00330f9645e8e4d97faa903a936e76b Mon Sep 17 00:00:00 2001 From: timm Date: Fri, 8 Feb 2013 17:22:40 +0100 Subject: print message after building for the mr3020, too --- minikrebs/profiles/init | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/minikrebs/profiles/init b/minikrebs/profiles/init index df9fcfcd..0add700e 100755 --- a/minikrebs/profiles/init +++ b/minikrebs/profiles/init @@ -29,6 +29,14 @@ You can use the following images: Factory : $PWD/bin/ar71xx/openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin System Upgrade: $PWD/bin/ar71xx/openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-sysupgrade.bin EOF +elif [ -e bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin ]; +then + cat << EOF +finished building +You can use the following images: + Factory : $PWD/bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin + System Upgrade: $PWD/bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-sysupgrade.bin +EOF else cat << EOF It seems like the factory image has not been created, it is most -- cgit v1.2.3