add args command name
This commit is contained in:
parent
ebc6206ec9
commit
7e484fa308
@ -11,7 +11,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument("--logfile", help="Log file", default="")
|
parser.add_argument("--logfile", help="Log file", default="")
|
||||||
parser.add_argument("--quiet", help="No console output", action="store_true")
|
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 = subparsers.add_parser("import")
|
||||||
import_parser.add_argument("--user", help="wordpress user", required=True)
|
import_parser.add_argument("--user", help="wordpress user", required=True)
|
||||||
@ -33,6 +33,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logger = logging.getLogger('insert wordpress')
|
logger = logging.getLogger('insert wordpress')
|
||||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
@ -57,15 +58,16 @@ if __name__ == '__main__':
|
|||||||
fileHandler.setFormatter(formatter)
|
fileHandler.setFormatter(formatter)
|
||||||
logger.addHandler(fileHandler)
|
logger.addHandler(fileHandler)
|
||||||
|
|
||||||
password = getpass()
|
if args.command == "export":
|
||||||
if len(password) == 0:
|
password = getpass()
|
||||||
logger.error("No password error !!! ")
|
if len(password) == 0:
|
||||||
exit(1)
|
logger.error("No password error !!! ")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
basic = HTTPBasicAuth(args.user, password)
|
basic = HTTPBasicAuth(args.user, password)
|
||||||
importWp = WPImport.WPimport(basic, args.wordpress, logger)
|
importWp = WPImport.WPimport(basic, args.wordpress, logger)
|
||||||
if len(args.file) > 0:
|
if len(args.file) > 0:
|
||||||
importWp.fromFile(args.file.split(","))
|
importWp.fromFile(args.file.split(","))
|
||||||
exit(0)
|
exit(0)
|
||||||
if len(args.directory) > 0:
|
if len(args.directory) > 0:
|
||||||
importWp.fromDirectory(args.directory)
|
importWp.fromDirectory(args.directory)
|
Loading…
x
Reference in New Issue
Block a user