def serv_module(modname=None): log.debug('%s: %s', request.method, modname) if modname is None: args = request_parser(request) modname = args._ modname = modname.decode('utf8').strip().replace(u'.', u'_') if modname == '_': path = Path.join(basepath, 'tuby', 'core.py') if not Path.exists(path): return Err.file_not_found, 404 return Response(mini(readfile(path)), mimetype=MIME_RESPONSE) path = None for storepath in [modpath, Path.abspath(Path.join(basepath, Path.pardir, 'smodule'))]: path = Path.join(storepath, u'%s.py' % modname) if not Path.exists(path): continue content = readfile(path) if content is not None: return Response(mini(content), mimetype=MIME_RESPONSE) log.error('File not found: %s', path) return Err.file_not_found
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: 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__') msg = '%s %s\n' % (version, fn[:-3], author, email) TUBY.stdout.write(msg)