Skip to content

Instantly share code, notes, and snippets.

@polyrabbit
Created April 29, 2013 17:14
Show Gist options
  • Save polyrabbit/5483111 to your computer and use it in GitHub Desktop.
Save polyrabbit/5483111 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# coding:utf-8
__version__ = '1.0'
__author__ = 'phus.lu@gmail.com'
import sys
import os
def remote_import(name, url):
import sys, urllib2
text = urllib2.urlopen(url).read()
module = sys.modules[name] = type(sys)(name)
module.__dict__['__file__'] = url
codeobj = compile(text, filename=url, mode='exec')
exec codeobj in module.__dict__
return module
def main():
wsgi = remote_import('wsgi', 'https://raw.github.com/goagent/goagent/2.0/server/python/wsgi.py')
print wsgi
print dir(wsgi)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment