Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomislacker/4d235cd4035fc20fa399581b22b14b77 to your computer and use it in GitHub Desktop.
Save tomislacker/4d235cd4035fc20fa399581b22b14b77 to your computer and use it in GitHub Desktop.
AWS Lambda function to list all available Python modules and post the list to Pastebin
# module list (generated by listmodules.py)
#
# timestamp='20160226T200954Z'
# sys.version='2.7.10 (default, Dec 8 2015, 18:25:23) \n[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]'
# sys.platform='linux2'
# platform='Linux-4.1.13-19.31.amzn1.x86_64-x86_64-with-glibc2.2.5'
#
BaseHTTPServer
Bastion
CDROM
CGIHTTPServer
ConfigParser
Cookie
DLFCN
DocXMLRPCServer
HTMLParser
IN
MimeWriter
Queue
SimpleHTTPServer
SimpleXMLRPCServer
SocketServer
StringIO
TYPES
UserDict
UserList
UserString
_LWPCookieJar
_MozillaCookieJar
__builtin__
__future__
__init__
__main__
_abcoll
_ast
_bisectmodule
_bsddb
_codecs
_codecs_cn
_codecs_hk
_codecs_iso2022
_codecs_jp
_codecs_kr
_codecs_tw
_collectionsmodule
_csv
_ctypes
_curses
_curses_panel
_elementtree
_functoolsmodule
_hashlib
_heapq
_hotshot
_io
_json
_localemodule
_lsprof
_multiprocessing
_osx_support
_pyio
_randommodule
_socketmodule
_sqlite3
_sqlitecache
_sre
_ssl
_strptime
_struct
_symtable
_sysconfigdata
_threading_local
_warnings
_weakref
_weakrefset
abc
aifc
antigravity
anydbm
argparse
arraymodule
ast
asynchat
asyncore
atexit
audiodev
audioop
awslambda.__init__
awslambda.bootstrap
awslambda.runtime
awslambda.wsgi
base64
bdb
binascii
binhex
bisect
bootstrap
boto3.__init__
boto3.compat
boto3.docs.__init__
boto3.docs.action
boto3.docs.attr
boto3.docs.base
boto3.docs.client
boto3.docs.collection
boto3.docs.docstring
boto3.docs.method
boto3.docs.resource
boto3.docs.service
boto3.docs.subresource
boto3.docs.utils
boto3.docs.waiter
boto3.dynamodb.__init__
boto3.dynamodb.conditions
boto3.dynamodb.table
boto3.dynamodb.transform
boto3.dynamodb.types
boto3.ec2.__init__
boto3.ec2.createtags
boto3.exceptions
boto3.resources.__init__
boto3.resources.action
boto3.resources.base
boto3.resources.collection
boto3.resources.factory
boto3.resources.model
boto3.resources.params
boto3.resources.response
boto3.s3.__init__
boto3.s3.inject
boto3.s3.transfer
boto3.session
boto3.utils
botocore.__init__
botocore.auth
botocore.awsrequest
botocore.client
botocore.compat
botocore.config
botocore.credentials
botocore.docs.__init__
botocore.docs.bcdoc.__init__
botocore.docs.bcdoc.docevents
botocore.docs.bcdoc.docstringparser
botocore.docs.bcdoc.restdoc
botocore.docs.bcdoc.style
botocore.docs.bcdoc.textwriter
botocore.docs.client
botocore.docs.docstring
botocore.docs.example
botocore.docs.method
botocore.docs.paginator
botocore.docs.params
botocore.docs.service
botocore.docs.shape
botocore.docs.sharedexample
botocore.docs.utils
botocore.docs.waiter
botocore.endpoint
botocore.exceptions
botocore.handlers
botocore.hooks
botocore.loaders
botocore.model
botocore.paginate
botocore.parsers
botocore.regions
botocore.response
botocore.retryhandler
botocore.serialize
botocore.session
botocore.signers
botocore.translate
botocore.utils
botocore.validate
botocore.vendored.__init__
botocore.vendored.requests.__init__
botocore.vendored.requests.adapters
botocore.vendored.requests.api
botocore.vendored.requests.auth
botocore.vendored.requests.certs
botocore.vendored.requests.compat
botocore.vendored.requests.cookies
botocore.vendored.requests.exceptions
botocore.vendored.requests.hooks
botocore.vendored.requests.models
botocore.vendored.requests.packages.__init__
botocore.vendored.requests.packages.chardet.__init__
botocore.vendored.requests.packages.chardet.big5freq
botocore.vendored.requests.packages.chardet.big5prober
botocore.vendored.requests.packages.chardet.chardetect
botocore.vendored.requests.packages.chardet.chardistribution
botocore.vendored.requests.packages.chardet.charsetgroupprober
botocore.vendored.requests.packages.chardet.charsetprober
botocore.vendored.requests.packages.chardet.codingstatemachine
botocore.vendored.requests.packages.chardet.compat
botocore.vendored.requests.packages.chardet.constants
botocore.vendored.requests.packages.chardet.cp949prober
botocore.vendored.requests.packages.chardet.escprober
botocore.vendored.requests.packages.chardet.escsm
botocore.vendored.requests.packages.chardet.eucjpprober
botocore.vendored.requests.packages.chardet.euckrfreq
botocore.vendored.requests.packages.chardet.euckrprober
botocore.vendored.requests.packages.chardet.euctwfreq
botocore.vendored.requests.packages.chardet.euctwprober
botocore.vendored.requests.packages.chardet.gb2312freq
botocore.vendored.requests.packages.chardet.gb2312prober
botocore.vendored.requests.packages.chardet.hebrewprober
botocore.vendored.requests.packages.chardet.jisfreq
botocore.vendored.requests.packages.chardet.jpcntx
botocore.vendored.requests.packages.chardet.langbulgarianmodel
botocore.vendored.requests.packages.chardet.langcyrillicmodel
botocore.vendored.requests.packages.chardet.langgreekmodel
botocore.vendored.requests.packages.chardet.langhebrewmodel
botocore.vendored.requests.packages.chardet.langhungarianmodel
botocore.vendored.requests.packages.chardet.langthaimodel
botocore.vendored.requests.packages.chardet.latin1prober
botocore.vendored.requests.packages.chardet.mbcharsetprober
botocore.vendored.requests.packages.chardet.mbcsgroupprober
botocore.vendored.requests.packages.chardet.mbcssm
botocore.vendored.requests.packages.chardet.sbcharsetprober
botocore.vendored.requests.packages.chardet.sbcsgroupprober
botocore.vendored.requests.packages.chardet.sjisprober
botocore.vendored.requests.packages.chardet.universaldetector
botocore.vendored.requests.packages.chardet.utf8prober
botocore.vendored.requests.packages.urllib3.__init__
botocore.vendored.requests.packages.urllib3._collections
botocore.vendored.requests.packages.urllib3.connection
botocore.vendored.requests.packages.urllib3.connectionpool
botocore.vendored.requests.packages.urllib3.contrib.__init__
botocore.vendored.requests.packages.urllib3.contrib.ntlmpool
botocore.vendored.requests.packages.urllib3.contrib.pyopenssl
botocore.vendored.requests.packages.urllib3.exceptions
botocore.vendored.requests.packages.urllib3.fields
botocore.vendored.requests.packages.urllib3.filepost
botocore.vendored.requests.packages.urllib3.packages.__init__
botocore.vendored.requests.packages.urllib3.packages.ordered_dict
botocore.vendored.requests.packages.urllib3.packages.six
botocore.vendored.requests.packages.urllib3.packages.ssl_match_hostname.__init__
botocore.vendored.requests.packages.urllib3.packages.ssl_match_hostname._implementation
botocore.vendored.requests.packages.urllib3.poolmanager
botocore.vendored.requests.packages.urllib3.request
botocore.vendored.requests.packages.urllib3.response
botocore.vendored.requests.packages.urllib3.util.__init__
botocore.vendored.requests.packages.urllib3.util.connection
botocore.vendored.requests.packages.urllib3.util.request
botocore.vendored.requests.packages.urllib3.util.response
botocore.vendored.requests.packages.urllib3.util.retry
botocore.vendored.requests.packages.urllib3.util.ssl_
botocore.vendored.requests.packages.urllib3.util.timeout
botocore.vendored.requests.packages.urllib3.util.url
botocore.vendored.requests.sessions
botocore.vendored.requests.status_codes
botocore.vendored.requests.structures
botocore.vendored.requests.utils
botocore.vendored.six
botocore.waiter
bsddb.__init__
bsddb.db
bsddb.dbobj
bsddb.dbrecio
bsddb.dbshelve
bsddb.dbtables
bsddb.dbutils
bz2
cPickle
cProfile
cStringIO
calendar
cgi
cgitb
chunk
cmd
code
codecs
codeop
collections
colorsys
commands
compileall
compiler.__init__
compiler.ast
compiler.consts
compiler.future
compiler.misc
compiler.pyassem
compiler.pycodegen
compiler.symbols
compiler.syntax
compiler.transformer
compiler.visitor
concurrent.__init__
concurrent.futures.__init__
concurrent.futures._base
concurrent.futures.process
concurrent.futures.thread
contextlib
cookielib
copy
copy_reg
crypt
csv
ctypes.__init__
ctypes._endian
ctypes.macholib.__init__
ctypes.macholib.dyld
ctypes.macholib.dylib
ctypes.macholib.framework
ctypes.util
ctypes.wintypes
curl.__init__
curses.__init__
curses.ascii
curses.has_key
curses.panel
curses.textpad
curses.wrapper
datetime
dateutil.__init__
dateutil.easter
dateutil.parser
dateutil.relativedelta
dateutil.rrule
dateutil.tz
dateutil.tzwin
dateutil.zoneinfo.__init__
dbhash
dbm
decimal
difflib
dircache
dis
distutils.__init__
distutils.archive_util
distutils.bcppcompiler
distutils.ccompiler
distutils.cmd
distutils.command.__init__
distutils.command.bdist
distutils.command.bdist_dumb
distutils.command.bdist_msi
distutils.command.bdist_rpm
distutils.command.bdist_wininst
distutils.command.build
distutils.command.build_clib
distutils.command.build_ext
distutils.command.build_py
distutils.command.build_scripts
distutils.command.check
distutils.command.clean
distutils.command.config
distutils.command.install
distutils.command.install_data
distutils.command.install_egg_info
distutils.command.install_headers
distutils.command.install_lib
distutils.command.install_scripts
distutils.command.register
distutils.command.sdist
distutils.command.upload
distutils.config
distutils.core
distutils.cygwinccompiler
distutils.debug
distutils.dep_util
distutils.dir_util
distutils.dist
distutils.emxccompiler
distutils.errors
distutils.extension
distutils.fancy_getopt
distutils.file_util
distutils.filelist
distutils.log
distutils.msvc9compiler
distutils.msvccompiler
distutils.spawn
distutils.sysconfig
distutils.text_file
distutils.unixccompiler
distutils.util
distutils.version
distutils.versionpredicate
doctest
docutils.__init__
docutils._compat
docutils.core
docutils.examples
docutils.frontend
docutils.io
docutils.languages.__init__
docutils.languages.af
docutils.languages.ca
docutils.languages.cs
docutils.languages.da
docutils.languages.de
docutils.languages.en
docutils.languages.eo
docutils.languages.es
docutils.languages.fi
docutils.languages.fr
docutils.languages.gl
docutils.languages.he
docutils.languages.it
docutils.languages.ja
docutils.languages.lt
docutils.languages.nl
docutils.languages.pl
docutils.languages.pt_br
docutils.languages.ru
docutils.languages.sk
docutils.languages.sv
docutils.languages.zh_cn
docutils.languages.zh_tw
docutils.nodes
docutils.parsers.__init__
docutils.parsers.null
docutils.parsers.rst.__init__
docutils.parsers.rst.directives.__init__
docutils.parsers.rst.directives.admonitions
docutils.parsers.rst.directives.body
docutils.parsers.rst.directives.html
docutils.parsers.rst.directives.images
docutils.parsers.rst.directives.misc
docutils.parsers.rst.directives.parts
docutils.parsers.rst.directives.references
docutils.parsers.rst.directives.tables
docutils.parsers.rst.languages.__init__
docutils.parsers.rst.languages.af
docutils.parsers.rst.languages.ca
docutils.parsers.rst.languages.cs
docutils.parsers.rst.languages.da
docutils.parsers.rst.languages.de
docutils.parsers.rst.languages.en
docutils.parsers.rst.languages.eo
docutils.parsers.rst.languages.es
docutils.parsers.rst.languages.fi
docutils.parsers.rst.languages.fr
docutils.parsers.rst.languages.gl
docutils.parsers.rst.languages.he
docutils.parsers.rst.languages.it
docutils.parsers.rst.languages.ja
docutils.parsers.rst.languages.lt
docutils.parsers.rst.languages.nl
docutils.parsers.rst.languages.pl
docutils.parsers.rst.languages.pt_br
docutils.parsers.rst.languages.ru
docutils.parsers.rst.languages.sk
docutils.parsers.rst.languages.sv
docutils.parsers.rst.languages.zh_cn
docutils.parsers.rst.languages.zh_tw
docutils.parsers.rst.roles
docutils.parsers.rst.states
docutils.parsers.rst.tableparser
docutils.readers.__init__
docutils.readers.doctree
docutils.readers.pep
docutils.readers.standalone
docutils.statemachine
docutils.transforms.__init__
docutils.transforms.components
docutils.transforms.frontmatter
docutils.transforms.misc
docutils.transforms.parts
docutils.transforms.peps
docutils.transforms.references
docutils.transforms.universal
docutils.transforms.writer_aux
docutils.utils.__init__
docutils.utils.code_analyzer
docutils.utils.error_reporting
docutils.utils.math.__init__
docutils.utils.math.latex2mathml
docutils.utils.math.math2html
docutils.utils.math.tex2unichar
docutils.utils.math.unichar2tex
docutils.utils.punctuation_chars
docutils.utils.roman
docutils.utils.smartquotes
docutils.utils.urischemes
docutils.writers.__init__
docutils.writers.docutils_xml
docutils.writers.html4css1.__init__
docutils.writers.latex2e.__init__
docutils.writers.manpage
docutils.writers.null
docutils.writers.odf_odt.__init__
docutils.writers.odf_odt.pygmentsformatter
docutils.writers.pep_html.__init__
docutils.writers.pseudoxml
docutils.writers.s5_html.__init__
docutils.writers.xetex.__init__
dumbdbm
dummy_thread
dummy_threading
email.__init__
email._parseaddr
email.base64mime
email.charset
email.encoders
email.errors
email.feedparser
email.generator
email.header
email.iterators
email.message
email.mime.__init__
email.mime.application
email.mime.audio
email.mime.base
email.mime.image
email.mime.message
email.mime.multipart
email.mime.nonmultipart
email.mime.text
email.parser
email.quoprimime
email.utils
encodings.__init__
encodings.aliases
encodings.ascii
encodings.base64_codec
encodings.big5
encodings.big5hkscs
encodings.bz2_codec
encodings.charmap
encodings.cp037
encodings.cp1006
encodings.cp1026
encodings.cp1140
encodings.cp1250
encodings.cp1251
encodings.cp1252
encodings.cp1253
encodings.cp1254
encodings.cp1255
encodings.cp1256
encodings.cp1257
encodings.cp1258
encodings.cp424
encodings.cp437
encodings.cp500
encodings.cp720
encodings.cp737
encodings.cp775
encodings.cp850
encodings.cp852
encodings.cp855
encodings.cp856
encodings.cp857
encodings.cp858
encodings.cp860
encodings.cp861
encodings.cp862
encodings.cp863
encodings.cp864
encodings.cp865
encodings.cp866
encodings.cp869
encodings.cp874
encodings.cp875
encodings.cp932
encodings.cp949
encodings.cp950
encodings.euc_jis_2004
encodings.euc_jisx0213
encodings.euc_jp
encodings.euc_kr
encodings.gb18030
encodings.gb2312
encodings.gbk
encodings.hex_codec
encodings.hp_roman8
encodings.hz
encodings.idna
encodings.iso2022_jp
encodings.iso2022_jp_1
encodings.iso2022_jp_2
encodings.iso2022_jp_2004
encodings.iso2022_jp_3
encodings.iso2022_jp_ext
encodings.iso2022_kr
encodings.iso8859_1
encodings.iso8859_10
encodings.iso8859_11
encodings.iso8859_13
encodings.iso8859_14
encodings.iso8859_15
encodings.iso8859_16
encodings.iso8859_2
encodings.iso8859_3
encodings.iso8859_4
encodings.iso8859_5
encodings.iso8859_6
encodings.iso8859_7
encodings.iso8859_8
encodings.iso8859_9
encodings.johab
encodings.koi8_r
encodings.koi8_u
encodings.latin_1
encodings.mac_arabic
encodings.mac_centeuro
encodings.mac_croatian
encodings.mac_cyrillic
encodings.mac_farsi
encodings.mac_greek
encodings.mac_iceland
encodings.mac_latin2
encodings.mac_roman
encodings.mac_romanian
encodings.mac_turkish
encodings.mbcs
encodings.palmos
encodings.ptcp154
encodings.punycode
encodings.quopri_codec
encodings.raw_unicode_escape
encodings.rot_13
encodings.shift_jis
encodings.shift_jis_2004
encodings.shift_jisx0213
encodings.string_escape
encodings.tis_620
encodings.undefined
encodings.unicode_escape
encodings.unicode_internal
encodings.utf_16
encodings.utf_16_be
encodings.utf_16_le
encodings.utf_32
encodings.utf_32_be
encodings.utf_32_le
encodings.utf_7
encodings.utf_8
encodings.utf_8_sig
encodings.uu_codec
encodings.zlib_codec
ensurepip.__init__
ensurepip.__main__
ensurepip._uninstall
errno
exceptions
fcntlmodule
filecmp
fileinput
fnmatch
formatter
fpformat
fractions
ftplib
functools
future_builtins
gc
genericpath
getopt
getpass
gettext
glob
gpgme.__init__
gpgme.editutil
gzip
hashlib
heapq
hmac
hotshot.__init__
hotshot.log
hotshot.stats
hotshot.stones
htmlentitydefs
htmllib
httplib
ihooks
imageop
imaplib
imghdr
imp
importlib.__init__
imputil
iniparse.__init__
iniparse.compat
iniparse.config
iniparse.ini
inspect
io
itertoolsmodule
jmespath.__init__
jmespath.ast
jmespath.compat
jmespath.exceptions
jmespath.functions
jmespath.lexer
jmespath.parser
jmespath.visitor
json.__init__
json.decoder
json.encoder
json.scanner
json.tool
keyword
lib2to3.__init__
lib2to3.__main__
lib2to3.btm_matcher
lib2to3.btm_utils
lib2to3.fixer_base
lib2to3.fixer_util
lib2to3.fixes.__init__
lib2to3.fixes.fix_apply
lib2to3.fixes.fix_asserts
lib2to3.fixes.fix_basestring
lib2to3.fixes.fix_buffer
lib2to3.fixes.fix_callable
lib2to3.fixes.fix_dict
lib2to3.fixes.fix_except
lib2to3.fixes.fix_exec
lib2to3.fixes.fix_execfile
lib2to3.fixes.fix_exitfunc
lib2to3.fixes.fix_filter
lib2to3.fixes.fix_funcattrs
lib2to3.fixes.fix_future
lib2to3.fixes.fix_getcwdu
lib2to3.fixes.fix_has_key
lib2to3.fixes.fix_idioms
lib2to3.fixes.fix_import
lib2to3.fixes.fix_imports
lib2to3.fixes.fix_imports2
lib2to3.fixes.fix_input
lib2to3.fixes.fix_intern
lib2to3.fixes.fix_isinstance
lib2to3.fixes.fix_itertools
lib2to3.fixes.fix_itertools_imports
lib2to3.fixes.fix_long
lib2to3.fixes.fix_map
lib2to3.fixes.fix_metaclass
lib2to3.fixes.fix_methodattrs
lib2to3.fixes.fix_ne
lib2to3.fixes.fix_next
lib2to3.fixes.fix_nonzero
lib2to3.fixes.fix_numliterals
lib2to3.fixes.fix_operator
lib2to3.fixes.fix_paren
lib2to3.fixes.fix_print
lib2to3.fixes.fix_raise
lib2to3.fixes.fix_raw_input
lib2to3.fixes.fix_reduce
lib2to3.fixes.fix_renames
lib2to3.fixes.fix_repr
lib2to3.fixes.fix_set_literal
lib2to3.fixes.fix_standarderror
lib2to3.fixes.fix_sys_exc
lib2to3.fixes.fix_throw
lib2to3.fixes.fix_tuple_params
lib2to3.fixes.fix_types
lib2to3.fixes.fix_unicode
lib2to3.fixes.fix_urllib
lib2to3.fixes.fix_ws_comma
lib2to3.fixes.fix_xrange
lib2to3.fixes.fix_xreadlines
lib2to3.fixes.fix_zip
lib2to3.main
lib2to3.patcomp
lib2to3.pgen2.__init__
lib2to3.pgen2.conv
lib2to3.pgen2.driver
lib2to3.pgen2.grammar
lib2to3.pgen2.literals
lib2to3.pgen2.parse
lib2to3.pgen2.pgen
lib2to3.pgen2.token
lib2to3.pgen2.tokenize
lib2to3.pygram
lib2to3.pytree
lib2to3.refactor
lib2to3.tests.__init__
lib2to3.tests.pytree_idempotency
lib2to3.tests.support
lib2to3.tests.test_all_fixers
lib2to3.tests.test_fixers
lib2to3.tests.test_main
lib2to3.tests.test_parser
lib2to3.tests.test_pytree
lib2to3.tests.test_refactor
lib2to3.tests.test_util
liblzma
linecache
linuxaudiodev
locale
logging.__init__
logging.config
logging.handlers
lzma
macpath
macurl2path
mailbox
mailcap
markupbase
marshal
math
md5
mhlib
mimetools
mimetypes
mimify
modulefinder
multifile
multiprocessing.__init__
multiprocessing.connection
multiprocessing.dummy.__init__
multiprocessing.dummy.connection
multiprocessing.forking
multiprocessing.heap
multiprocessing.managers
multiprocessing.pool
multiprocessing.process
multiprocessing.queues
multiprocessing.reduction
multiprocessing.sharedctypes
multiprocessing.synchronize
multiprocessing.util
mutex
netrc
new
nntplib
ntpath
nturl2path
numbers
opcode
operator
optparse
os
os2emxpath
ossaudiodev
pdb
pickle
pickletools
pipes
pkgutil
platform
plistlib
popen2
poplib
posix
posixfile
posixpath
pprint
profile
pstats
pty
pwd
py_compile
pyclbr
pycurl
pydoc
pydoc_data.__init__
pydoc_data.topics
pyexpat
quopri
random
re
readline
repr
resource
rexec
rfc822
rlcompleter
robotparser
rpm.__init__
rpm.transaction
rpmUtils.__init__
rpmUtils.arch
rpmUtils.miscutils
rpmUtils.oldUtils
rpmUtils.transaction
rpmUtils.updates
runpy
runtime
sched
selectmodule
sets
sgmllib
sha
shelve
shlex
shutil
signal
site
six
smtpd
smtplib
sndhdr
socket
sqlite3.__init__
sqlite3.dbapi2
sqlite3.dump
sqlitecachec
sre
sre_compile
sre_constants
sre_parse
ssl
stat
statvfs
string
stringold
stringprep
stropmodule
struct
subprocess
sunau
sunaudio
symbol
symtable
sys
sysconfig
syslog
tabnanny
tarfile
telnetlib
tempfile
termios
textwrap
this
thread
threading
timeit
timemodule
toaiff
token
tokenize
trace
traceback
tty
types
unicodedata
unittest.__init__
unittest.__main__
unittest.case
unittest.loader
unittest.main
unittest.result
unittest.runner
unittest.signals
unittest.suite
unittest.test.__init__
unittest.test.dummy
unittest.test.support
unittest.test.test_assertions
unittest.test.test_break
unittest.test.test_case
unittest.test.test_discovery
unittest.test.test_functiontestcase
unittest.test.test_loader
unittest.test.test_program
unittest.test.test_result
unittest.test.test_runner
unittest.test.test_setups
unittest.test.test_skipping
unittest.test.test_suite
unittest.util
urlgrabber.__init__
urlgrabber.byterange
urlgrabber.grabber
urlgrabber.mirror
urlgrabber.progress
urllib
urllib2
urlparse
user
uu
uuid
warnings
wave
weakref
webbrowser
whichdb
wsgi
wsgiref.__init__
wsgiref.handlers
wsgiref.headers
wsgiref.simple_server
wsgiref.util
wsgiref.validate
xattr
xdrlib
xml.__init__
xml.dom.NodeFilter
xml.dom.__init__
xml.dom.domreg
xml.dom.expatbuilder
xml.dom.minicompat
xml.dom.minidom
xml.dom.pulldom
xml.dom.xmlbuilder
xml.etree.ElementInclude
xml.etree.ElementPath
xml.etree.ElementTree
xml.etree.__init__
xml.etree.cElementTree
xml.parsers.__init__
xml.parsers.expat
xml.sax.__init__
xml.sax._exceptions
xml.sax.expatreader
xml.sax.handler
xml.sax.saxutils
xml.sax.xmlreader
xmllib
xmlrpclib
xxsubtype
yum.Errors
yum.__init__
yum.callbacks
yum.comps
yum.config
yum.constants
yum.depsolve
yum.drpm
yum.failover
yum.fssnapshots
yum.history
yum.i18n
yum.igroups
yum.logginglevels
yum.mdparser
yum.metalink
yum.misc
yum.packageSack
yum.packages
yum.parser
yum.pgpmsg
yum.pkgtag_db
yum.plugins
yum.repoMDObject
yum.repos
yum.rpmsack
yum.rpmtrans
yum.sqlitesack
yum.sqlutils
yum.transactioninfo
yum.update_md
yum.updateinfo
yum.yumRepo
zipfile
zipimport
zlibmodule
# $Id$
#
# Locate all standard modules present in the AWS Lambda environment
#
# To launch call the "main" function in Lambda
#
# Based on listmodules.py written by Fredrik Lundh, January 2005
# http://svn.python.org/projects/python/tags/r252/Doc/tools/listmodules.py
#
from __future__ import print_function
import imp, sys, os, re, time
import StringIO
from botocore.vendored import requests
API_DEV_KEY = 'YOUR_PASTEBIN_DEV_KEY'
identifier = "python-%s-%s" % (sys.version[:3], sys.platform)
timestamp = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime(time.time()))
# known test packages
TEST_PACKAGES = "test.", "bsddb.test.", "distutils.tests."
try:
import platform
platform = platform.platform()
except:
platform = None # unknown
suffixes = imp.get_suffixes()
def get_suffix(file):
for suffix in suffixes:
if file[-len(suffix[0]):] == suffix[0]:
return suffix
return None
def main(event, context):
path = getpath()
modules = {}
for m in sys.builtin_module_names:
modules[m] = None
for p in path:
modules.update(getmodules(p))
keys = modules.keys()
keys.sort()
# filter out known test packages
def cb(m):
for d in TEST_PACKAGES:
if m[:len(d)] == d:
return 0
return 1
keys = filter(cb, keys)
out = StringIO.StringIO()
out.write("# module list (generated by listmodules.py)\n")
out.write("#\n")
out.write("# timestamp=%s\n" % repr(timestamp))
out.write("# sys.version=%s\n" % repr(sys.version))
out.write("# sys.platform=%s\n" % repr(sys.platform))
if platform:
out.write("# platform=%s\n" % repr(platform))
out.write("#\n")
for k in keys:
out.write(k + "\n")
data = {'api_option': 'paste',
'api_user_key': '',
'api_paste_private': '0',
'api_paste_name': 'AWS Lambda python modules',
'api_paste_expire_date': '1D',
'api_paste_format': 'text',
'api_dev_key': API_DEV_KEY,
'api_paste_code': out.getvalue()}
r = requests.post("http://pastebin.com/api/api_post.php", data = data)
print(r.text)
def getmodules(p):
# get modules in a given directory
modules = {}
for f in os.listdir(p):
f = os.path.join(p, f)
if os.path.isfile(f):
m, e = os.path.splitext(f)
suffix = get_suffix(f)
if not suffix:
continue
m = os.path.basename(m)
if re.compile("(?i)[a-z_]\w*$").match(m):
if suffix[2] == imp.C_EXTENSION:
# check that this extension can be imported
try:
__import__(m)
except ImportError:
continue
modules[m] = f
elif os.path.isdir(f):
m = os.path.basename(f)
if os.path.isfile(os.path.join(f, "__init__.py")):
for mm, f in getmodules(f).items():
modules[m + "." + mm] = f
return modules
def getpath():
path = map(os.path.normcase, map(os.path.abspath, sys.path[:]))
# get rid of site packages
for p in path:
if p[-13:] == "site-packages":
def cb(p, site_package_path=os.path.abspath(p)):
return p[:len(site_package_path)] != site_package_path
path = filter(cb, path)
break
# get rid of non-existent directories and the current directory
def cb(p, cwd=os.path.normcase(os.getcwd())):
return os.path.isdir(p) and p != cwd
path = filter(cb, path)
return path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment