from tuby.core import TubyStream try: TUBY = TUBY # @UndefinedVariable except Exception: TUBY = TubyStream() import os from tuby.core import modpath, readfile, _mkmodfn for dirpath, dirnames, filenames in os.walk(modpath): for fn in filenames: if not fn.endswith('.py'): continue if fn.startswith('tb_module_manifest'): # infinite loop continue module = compile(''.join(readfile(_mkmodfn(fn[:-3]))), '<string>', 'exec') scope = {'TUBY': TubyStream()} try: exec module in scope except Exception: pass def getvalue(key): if key not in scope['TUBY']: return 'na' return scope['TUBY'][key].encode('utf8') version = getvalue('__version__') author = getvalue('__author__') email = getvalue('__email__')
try: TUBY = TUBY # @UndefinedVariable except Exception: from tuby.core import TubyStream TUBY = TubyStream() import sys import struct import socket def ip2int(addr): return int(struct.unpack("!I", socket.inet_aton(addr))[0]) def int2ip(addr): return socket.inet_ntoa(struct.pack("!I", addr)) def genlist(src): iptxt, cidr = [p.strip() for p in src.split('/')] ipnum = ip2int(iptxt) rest = ~((1 << (32 - int(cidr))) - 1) minr = ipnum & rest maxr = minr ^ ~rest for i in range(minr, maxr): yield int2ip(i) def helper(ip): for ip in genlist(ip):