CC-2584: airtime-import fails

- fixed relative path problem
- handle the case where file name contains '-'
This commit is contained in:
james 2011-07-22 16:24:31 -04:00
parent a84cb7fc37
commit ccdb886b9a
2 changed files with 13 additions and 2 deletions

View file

@ -3,6 +3,8 @@
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate . ${virtualenv_bin}activate
invokePwd=$PWD
airtime_import_path="/usr/lib/airtime/utils/airtime-import/" airtime_import_path="/usr/lib/airtime/utils/airtime-import/"
airtime_import_script="airtime-import.py" airtime_import_script="airtime-import.py"
@ -14,6 +16,6 @@ exec 2>&1
export PYTHONPATH=${api_client_path} export PYTHONPATH=${api_client_path}
# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr # 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 # EOF

View file

@ -33,6 +33,10 @@ api_client = api_client.api_client_factory(config)
# flag should be 'copy' or 'move' # flag should be 'copy' or 'move'
def copy_or_move_files_to(paths, dest, flag): def copy_or_move_files_to(paths, dest, flag):
for path in paths: 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.exists(path)):
if(os.path.isdir(path)): if(os.path.isdir(path)):
path = format_dir_string(path) path = format_dir_string(path)
@ -73,7 +77,7 @@ def helper_get_stor_dir():
def checkOtherOption(args): def checkOtherOption(args):
for i in args: for i in args:
if('-' in i): if(i[0] == '-'):
return True return True
def errorIfMultipleOption(args, msg=''): 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('--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') 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): 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" print "\nThe [-l][--link] option is deprecated. Please use the --watch-add option.\nTry 'airtime-import -h' for more detail.\n"
sys.exit() sys.exit()