def main(): parse_command_line() if options.dump: print tmpl.code sys.exit(0) t = Timer(render) results = t.timeit(options.num) / options.num print '%0.3f ms per iteration' % (results*1000)
def main(): parse_command_line() if options.dump: print tmpl.code sys.exit(0) t = Timer(render) results = t.timeit(options.num) / options.num print '%0.3f ms per iteration' % (results * 1000)
def main(): """A simple test runner. This test runner is essentially equivalent to `unittest.main` from the standard library, but adds support for tornado-style option parsing and log formatting. The easiest way to run a test is via the command line:: python -m anzu.testing anzu.test.stack_context_test See the standard library unittest module for ways in which tests can be specified. Projects with many tests may wish to define a test script like anzu/test/runtests.py. This script should define a method all() which returns a test suite and then call anzu.testing.main(). Note that even when a test script is used, the all() test suite may be overridden by naming a single test on the command line:: # Runs all tests tornado/test/runtests.py # Runs one test tornado/test/runtests.py anzu.test.stack_context_test """ from anzu.options import define, options, parse_command_line define('autoreload', type=bool, default=False, help="DEPRECATED: use anzu.autoreload.main instead") define('httpclient', type=str, default=None) argv = [sys.argv[0]] + parse_command_line(sys.argv) if options.httpclient: from anzu.httpclient import AsyncHTTPClient AsyncHTTPClient.configure(options.httpclient) if __name__ == '__main__' and len(argv) == 1: print >> sys.stderr, "No tests specified" sys.exit(1) try: # In order to be able to run tests by their fully-qualified name # on the command line without importing all tests here, # module must be set to None. Python 3.2's unittest.main ignores # defaultTest if no module is given (it tries to do its own # test discovery, which is incompatible with auto2to3), so don't # set module if we're not asking for a specific test. if len(argv) > 1: unittest.main(module=None, argv=argv) else: unittest.main(defaultTest="all", argv=argv) except SystemExit, e: if e.code == 0: logging.info('PASS') else: logging.error('FAIL') if not options.autoreload: raise
def main(): """A simple test runner. This test runner is essentially equivalent to `unittest.main` from the standard library, but adds support for tornado-style option parsing and log formatting. The easiest way to run a test is via the command line:: python -m anzu.testing anzu.test.stack_context_test See the standard library unittest module for ways in which tests can be specified. Projects with many tests may wish to define a test script like anzu/test/runtests.py. This script should define a method all() which returns a test suite and then call anzu.testing.main(). Note that even when a test script is used, the all() test suite may be overridden by naming a single test on the command line:: # Runs all tests tornado/test/runtests.py # Runs one test tornado/test/runtests.py anzu.test.stack_context_test """ from anzu.options import define, options, parse_command_line define("autoreload", type=bool, default=False, help="DEPRECATED: use anzu.autoreload.main instead") define("httpclient", type=str, default=None) argv = [sys.argv[0]] + parse_command_line(sys.argv) if options.httpclient: from anzu.httpclient import AsyncHTTPClient AsyncHTTPClient.configure(options.httpclient) if __name__ == "__main__" and len(argv) == 1: print >>sys.stderr, "No tests specified" sys.exit(1) try: # In order to be able to run tests by their fully-qualified name # on the command line without importing all tests here, # module must be set to None. Python 3.2's unittest.main ignores # defaultTest if no module is given (it tries to do its own # test discovery, which is incompatible with auto2to3), so don't # set module if we're not asking for a specific test. if len(argv) > 1: unittest.main(module=None, argv=argv) else: unittest.main(defaultTest="all", argv=argv) except SystemExit, e: if e.code == 0: logging.info("PASS") else: logging.error("FAIL") if not options.autoreload: raise
def main(): from anzu.options import define, options, parse_command_line define("print_headers", type=bool, default=False) define("print_body", type=bool, default=True) define("follow_redirects", type=bool, default=True) args = parse_command_line() client = HTTPClient() for arg in args: try: response = client.fetch(arg, follow_redirects=options.follow_redirects) except HTTPError, e: if e.response is not None: response = e.response else: raise if options.print_headers: print response.headers if options.print_body: print response.body
def main(): parse_command_line() for i in xrange(options.num_runs): run()
from os import getlogin, makedirs, path, utime import codecs import logging import re import time import MySQLdb as mdb import pytz import yaml from anzu.escape import xhtml_unescape from anzu.options import parse_command_line, enable_pretty_logging from export_helper import get_page, get_part_of_page, get_gravatar_for enable_pretty_logging() parse_command_line() GMT = pytz.timezone('GMT') # current user/system timezone build_tz = pytz.timezone(time.strftime("%Z", time.gmtime())) plugin = re.compile(r'\[\w') print("MySQL connection data.") mysql_conn = { 'host': input(" host [localhost]: ") or "localhost", 'db': input(" database [%s_blog]: " % getlogin()) or getlogin() + "_blog", 'user': input(" mysql username [%s]: " % getlogin()) or getlogin(), 'passwd': input(" password: "******" table prefix [wp_]: ") or "wp_"
import MySQLdb as mdb import yaml import pytz from anzu.options import parse_command_line, enable_pretty_logging from anzu.escape import xhtml_unescape from export_helper import get_page, get_part_of_page, get_gravatar_for try: from collections import OrderedDict except: from thot.utils import OrderedDict enable_pretty_logging() parse_command_line() list_type = type([]) GMT = pytz.timezone('GMT') # current user/system timezone build_tz = pytz.timezone(time.strftime("%Z", time.gmtime())) plugin = re.compile(r'\[\w') print "MySQL connection data." mysql_conn = { 'host': raw_input(" host [localhost]: ") or "localhost", 'db': raw_input(" database [%s_blog]: " % getlogin()) or getlogin()+"_blog", 'user': raw_input(" mysql username [%s]: " % getlogin()) or getlogin(), 'passwd': raw_input(" password: "******" table prefix [wp_]: ") or "wp_"