diff --git a/import_export_canalblog.py b/import_export_canalblog.py index f1e07df..7e5ea30 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -11,7 +11,7 @@ if __name__ == '__main__': parser.add_argument("--logfile", help="Log file", default="") parser.add_argument("--quiet", help="No console output", action="store_true") - subparsers = parser.add_subparsers() + subparsers = parser.add_subparsers(dest="command") import_parser = subparsers.add_parser("import") import_parser.add_argument("--user", help="wordpress user", required=True) @@ -33,6 +33,7 @@ if __name__ == '__main__': args = parser.parse_args() + logger = logging.getLogger('insert wordpress') formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') @@ -57,15 +58,16 @@ if __name__ == '__main__': fileHandler.setFormatter(formatter) logger.addHandler(fileHandler) - password = getpass() - if len(password) == 0: - logger.error("No password error !!! ") - exit(1) + if args.command == "export": + password = getpass() + if len(password) == 0: + logger.error("No password error !!! ") + exit(1) - basic = HTTPBasicAuth(args.user, password) - importWp = WPImport.WPimport(basic, args.wordpress, logger) - if len(args.file) > 0: - importWp.fromFile(args.file.split(",")) - exit(0) - if len(args.directory) > 0: - importWp.fromDirectory(args.directory) \ No newline at end of file + basic = HTTPBasicAuth(args.user, password) + importWp = WPImport.WPimport(basic, args.wordpress, logger) + if len(args.file) > 0: + importWp.fromFile(args.file.split(",")) + exit(0) + if len(args.directory) > 0: + importWp.fromDirectory(args.directory) \ No newline at end of file