From dc2dd3eb97e106e545f0bc36902d623d1951f313 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 11 Jul 2011 15:45:07 -0400 Subject: [PATCH] CC-2514:New airtime-import script - on -c, -copy, -l, -link, following msg will be displayed james@james-P35-DS3L:~/src/airtime/python_apps$ python airtime-import.py -l sdfdf usage: airtime-import.py [-h] [-c] [-l] {move,storage-dir,copy,watch} ... This script let you do following operations - import files - add/remove/list watch folders - set default storage folder positional arguments: {move,storage-dir,copy,watch} sub-command help copy copy file move move file watch operations on watch directory storage-dir operations on storage directory optional arguments: -h, --help show this help message and exit -c, --copy copy file(deprecated. Use "copy" sub-command) -l, --link link file(deprecated. Use "watch" sub-command) james@james-P35-DS3L:~/src/airtime/python_apps$ --- python_apps/airtime-import.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python_apps/airtime-import.py b/python_apps/airtime-import.py index 3e1ed24ef..6a88240d2 100644 --- a/python_apps/airtime-import.py +++ b/python_apps/airtime-import.py @@ -121,8 +121,11 @@ def helper_get_stor_dir(): res = api_client.list_all_watched_dirs() return res['dirs']['1'] -parser = argparse.ArgumentParser(description="This script let you do following operations- imports files\n- add/remove/list watch folders\n- set default storage folder", formatter_class=RawTextHelpFormatter) -subparsers = parser.add_subparsers() +parser = argparse.ArgumentParser(description="This script let you do following operations\n- import files\n- add/remove/list watch folders\n- set default storage folder", formatter_class=RawTextHelpFormatter) +# for subcommand move +parser.add_argument('-c','--copy', action='store_true', help='copy file(deprecated. Use "copy" sub-command)') +parser.add_argument('-l','--link', action='store_true', help='link file(deprecated. Use "watch" sub-command)') +subparsers = parser.add_subparsers(help='sub-command help') # for subcommand copy parser_copy = subparsers.add_parser('copy', help='copy file') @@ -134,6 +137,8 @@ parser_move = subparsers.add_parser('move', help='move file') parser_move.add_argument('path', nargs='+', help='path to the file or directory') parser_move.set_defaults(func=import_move) +#parser_deprecated1 = subparsers.add_parser('-c', help='copy file') + # for subcommand watch parser_watch = subparsers.add_parser('watch', help='operations on watch directory') watch_subparsers = parser_watch.add_subparsers() @@ -156,7 +161,12 @@ parser_set.add_argument('path', help='path to the directory') parser_set.set_defaults(func=set_stor_dir) parser_get.set_defaults(func=get_stor_dir) -args = parser.parse_args() + +if ("-c" in sys.argv or "-copy" in sys.argv or "-l" in sys.argv or "-link" in sys.argv): + args = parser.parse_args(['-h']) +else: + args = parser.parse_args() +print args #format args.path if(hasattr(args,'path')): if(args.path[-1] != '/'):