コード例 #1
0
			logging.info("{0} {1}".format(environ["REQUEST_METHOD"], environ["PATH_INFO"]))
			if "retro.app" not in environ: environ["retro.app"] = stack.app()
			return environ["retro.app"](environ, startResponse)
		if method == "GEVENT":
			try:
				from gevent import wsgi
			except ImportError:
				raise ImportError("gevent is required to run `gevent` method")
			# NOTE: This starts using gevent's WSGI server (faster!)
			wsgi.WSGIServer((host,port), application, spawn=None).serve_forever()
		elif method == BJOERN:
			try:
				import bjoern
			except ImportError:
				raise ImportError("bjoern is required to run `bjoern` method")
			if hasattr(logging, "install"): logging.install(level=logging.INFO)
			bjoern.run(logged_application, host, port)
		elif method == ROCKET:
			try:
				import rocket
			except ImportError:
				raise ImportError("rocket is required to run `rocket` method")
			rocket.Rocket((host, int(port)), "wsgi", {"wsgi_app":application}).start()
		elif method == WSGI:
			# When using standalone WSGI, we make sure to wrap RendezVous objects
			# that might be returned by the handlers, and make sure we wait for
			# them -- we could use a callback version instead for specific web
			# servers.
			def retro_rendezvous_wrapper( environ, start_response, request=None):
				results = stack(environ, start_response, request)
				for result in results:
コード例 #2
0
ファイル: rawcopy.py プロジェクト: pombredanne/rawcopy
def command(args=None, logger=False):
    args = sys.argv[1:] if args is None else args
    if logger:
        if hasattr(logging, "install"): logging.install(channel="stderr")
        else: logging.basicConfig(level=logging.DEBUG)
    parser = argparse.ArgumentParser(
        description=
        "Creates a raw copy of the given source tree, properly preserving hard links."
    )
    parser.add_argument("source",
                        metavar="SOURCE",
                        type=str,
                        nargs="+",
                        help="The source tree to backup")
    parser.add_argument(
        "-c",
        "--catalogue",
        type=str,
        help="Uses the given catalogue for all the files to copy.")
    parser.add_argument(
        "-o",
        "--output",
        type=str,
        help="The path where the source tree will be backed up.")
    parser.add_argument(
        "-r",
        "--range",
        type=str,
        help=
        "The range of elements (by index) to copy from the catalogue as START[-END]"
    )
    parser.add_argument(
        "-t",
        "--type",
        type=str,
        nargs="*",
        action="append",
        help=
        "Only processes the nodes of the given type ([D]irectory/[F]ile/[S]ymlink)"
    )
    parser.add_argument("-n",
                        "--name",
                        type=str,
                        nargs="*",
                        action="append",
                        help="Only processes the nodes with the given name")
    parser.add_argument(
        "-T",
        "--test",
        action="store_true",
        default=False,
        help="Does a test run (no actual copy/creation of files)")
    parser.add_argument(
        "-C",
        "--catalogue-only",
        action="store_true",
        default=False,
        help="Does not do any copying, simple creates the catalogue")
    parser.add_argument(
        "-l",
        "--list",
        action="store_true",
        default=False,
        help=
        "Does not do any copying, but outputs the catalogue as INDEX<TAB>TYPE<TAB>PATH"
    )
    args = parser.parse_args()
    run(args)
コード例 #3
0
ファイル: rawcopy.py プロジェクト: sebastien/rawcopy
		help="Only processes the nodes of the given type ([D]irectory/[F]ile/[S]ymlink)"
	)
	parser.add_argument("-n", "--name", type=str, nargs="*", action="append",
		help="Only processes the nodes with the given name"
	)
	parser.add_argument("-T", "--test", action="store_true", default=False,
		help="Does a test run (no actual copy/creation of files)"
	)
	parser.add_argument("-C", "--catalogue-only", action="store_true", default=False,
		help="Does not do any copying, simple creates the catalogue"
	)
	parser.add_argument("-l", "--list", action="store_true", default=False,
		help="Does not do any copying, but outputs the catalogue as INDEX<TAB>TYPE<TAB>PATH"
	)
	args = parser.parse_args()
	run(args)

# rawcopy -l PATH
#	Creates a list of all the files at the given path, stores it as readonly

# rawcopy -l PATH <DEST>
#	Creates a raw copy of all the files in at the given directory


if __name__ == "__main__":
	if hasattr(logging, "install"): logging.install(channel="stderr")
	else: logging.basicConfig(level=logging.DEBUG)
	command(sys.argv[1:])

# EOF - vim: ts=4 sw=4 noet