[pywin32-checkins] pywin32/isapi install.py,1.14,1.15
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Jason R. C. <ja...@us...> - 2008-12-17 00:00:10
|
Update of /cvsroot/pywin32/pywin32/isapi In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12842 Modified Files: install.py Log Message: Fixed issue in ReallyCreateDirectory where an old variable name was lingering. Refactored HandleCommandLine to unify argument handlers. Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** install.py 16 Dec 2008 02:59:24 -0000 1.14 --- install.py 17 Dec 2008 00:00:04 -0000 1.15 *************** *** 255,259 **** # unless the directory exists on the filesystem. try: ! path = params.Path or webDir.Path newDir.Path = path except AttributeError: --- 255,259 ---- # unless the directory exists on the filesystem. try: ! path = params.Path or iis_dir.Path newDir.Path = path except AttributeError: *************** *** 568,572 **** return dll_name ! def InstallModule(conf_module_name, params, options): if not hasattr(sys, "frozen"): conf_module_name = os.path.abspath(conf_module_name) --- 568,573 ---- return dll_name ! def InstallModule(conf_module_name, params, options, log): ! "Install the extension" if not hasattr(sys, "frozen"): conf_module_name = os.path.abspath(conf_module_name) *************** *** 577,591 **** _PatchParamsModule(params, loader_dll) Install(params, options) ! def UninstallModule(conf_module_name, params, options): loader_dll = GetLoaderModuleName(conf_module_name, False) _PatchParamsModule(params, loader_dll, False) Uninstall(params, options) ! standard_arguments = { ! "install" : "Install the extension", ! "remove" : "Remove the extension" } # We support 2 ways of extending our command-line/install support. # * Many of the installation items allow you to specify "PreInstall", --- 578,613 ---- _PatchParamsModule(params, loader_dll) Install(params, options) + log(1, "Installation complete.") ! def UninstallModule(conf_module_name, params, options, log): ! "Remove the extension" loader_dll = GetLoaderModuleName(conf_module_name, False) _PatchParamsModule(params, loader_dll, False) Uninstall(params, options) + log(1, "Uninstallation complete.") ! standard_arg_handlers = { ! "install" : InstallModule, ! "remove" : UninstallModule, } + def build_usage(handler_map): + docstrings = [handler.__doc__ for handler in handler_map.values()] + all_args = dict(zip(handler_map.keys(), docstrings)) + arg_names = "|".join(all_args.keys()) + usage_string = "%prog [options] [" + arg_names + "]\n" + usage_string += "commands:\n" + for arg, desc in all_args.items(): + usage_string += " %-10s: %s" % (arg, desc) + "\n" + return usage_string[:-1] + + def MergeStandardOptions(options, params): + """ + Take an options object generated by the command line and merge + the values into the IISParameters object. + """ + pass + + # We support 2 ways of extending our command-line/install support. # * Many of the installation items allow you to specify "PreInstall", *************** *** 627,639 **** # build a usage string if we don't have one. if not parser.get_usage(): ! all_args = standard_arguments.copy() ! for arg, handler in custom_arg_handlers.items(): ! all_args[arg] = handler.__doc__ ! arg_names = "|".join(all_args.keys()) ! usage_string = "%prog [options] [" + arg_names + "]\n" ! usage_string += "commands:\n" ! for arg, desc in all_args.items(): ! usage_string += " %-10s: %s" % (arg, desc) + "\n" ! parser.set_usage(usage_string[:-1]) parser.add_option("-q", "--quiet", --- 649,659 ---- # build a usage string if we don't have one. if not parser.get_usage(): ! all_handlers = standard_arg_handlers.copy() ! all_handlers.update(custom_arg_handlers) ! parser.set_usage(build_usage(all_handlers)) ! ! # allow the user to use uninstall as a synonym for remove if it wasn't ! # defined by the custom arg handlers. ! all_handlers.setdefault('uninstall', all_handlers['remove']) parser.add_option("-q", "--quiet", *************** *** 648,651 **** --- 668,672 ---- (options, args) = parser.parse_args(argv[1:]) + MergeStandardOptions(options, params) verbose = options.verbose if not args: *************** *** 653,669 **** try: for arg in args: ! if arg == "install": ! InstallModule(conf_module_name, params, options) ! log(1, "Installation complete.") ! elif arg in ["remove", "uninstall"]: ! UninstallModule(conf_module_name, params, options) ! log(1, "Uninstallation complete.") ! else: ! handler = custom_arg_handlers.get(arg, None) ! if handler is None: ! parser.error("Invalid arg '%s'" % (arg,)) ! handler(options, log, arg) except (ItemNotFound, InstallationError), details: if options.verbose > 1: traceback.print_exc() print "%s: %s" % (details.__class__.__name__, details) --- 674,683 ---- try: for arg in args: ! handler = all_handlers[arg] ! handler(conf_module_name, params, options, log) except (ItemNotFound, InstallationError), details: if options.verbose > 1: traceback.print_exc() print "%s: %s" % (details.__class__.__name__, details) + except KeyError, e: + parser.error("Invalid arg '%s'" % arg) \ No newline at end of file |