From ccdb886b9aab3aa922164a4a1181cbf3447f0555 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 22 Jul 2011 16:24:31 -0400 Subject: [PATCH] CC-2584: airtime-import fails - fixed relative path problem - handle the case where file name contains '-' --- utils/airtime-import/airtime-import | 4 +++- utils/airtime-import/airtime-import.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/airtime-import/airtime-import b/utils/airtime-import/airtime-import index 135b19252..ed62c8a72 100755 --- a/utils/airtime-import/airtime-import +++ b/utils/airtime-import/airtime-import @@ -3,6 +3,8 @@ virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" . ${virtualenv_bin}activate +invokePwd=$PWD + airtime_import_path="/usr/lib/airtime/utils/airtime-import/" airtime_import_script="airtime-import.py" @@ -14,6 +16,6 @@ exec 2>&1 export PYTHONPATH=${api_client_path} # Note the -u when calling python! we need it to get unbuffered binary stdout and stderr -exec python -u ${airtime_import_path}${airtime_import_script} "$@" +exec python -u ${airtime_import_path}${airtime_import_script} --dir "$invokePwd" "$@" # EOF diff --git a/utils/airtime-import/airtime-import.py b/utils/airtime-import/airtime-import.py index bf369bc51..5d00a8f1d 100644 --- a/utils/airtime-import/airtime-import.py +++ b/utils/airtime-import/airtime-import.py @@ -33,6 +33,10 @@ api_client = api_client.api_client_factory(config) # flag should be 'copy' or 'move' def copy_or_move_files_to(paths, dest, flag): for path in paths: + if (path[0] == "/" or path[0] == "~"): + path = os.path.realpath(path) + else: + path = currentDir+path if(os.path.exists(path)): if(os.path.isdir(path)): path = format_dir_string(path) @@ -73,7 +77,7 @@ def helper_get_stor_dir(): def checkOtherOption(args): for i in args: - if('-' in i): + if(i[0] == '-'): return True def errorIfMultipleOption(args, msg=''): @@ -243,6 +247,11 @@ parser.add_option('--storage-dir-set', action='callback', callback=StorageSetAct parser.add_option('--storage-dir-get', action='callback', callback=StorageGetAction, help='Show the current storage dir.') parser.add_option('-h', '--help', dest='help', action='store_true', help='show this help message and exit') +# pop "--dir" +sys.argv.pop(1) +# pop "invoked pwd" +currentDir = sys.argv.pop(1)+'/' + if('-l' in sys.argv or '--link' in sys.argv): print "\nThe [-l][--link] option is deprecated. Please use the --watch-add option.\nTry 'airtime-import -h' for more detail.\n" sys.exit()