CC-2633: moving to_unicode() to api_client.py

- move to_unicode() to api_client.py
- fixed how it decodes path in airtime-import.py
This commit is contained in:
James 2011-08-05 12:35:50 -04:00
parent e2a5344e6e
commit 375cfb2c2d
4 changed files with 34 additions and 26 deletions

View file

@ -4,7 +4,7 @@ import os
import logging
from configobj import ConfigObj
from optparse import OptionParser, OptionValueError
from api_clients import api_client
from api_clients import api_client as apc
import json
import shutil
@ -26,7 +26,7 @@ except Exception, e:
print('Error loading config file: %s', e)
sys.exit()
api_client = api_client.api_client_factory(config)
api_client = apc.api_client_factory(config)
#helper functions
# copy or move files
@ -37,9 +37,9 @@ def copy_or_move_files_to(paths, dest, flag):
path = os.path.realpath(path)
else:
path = currentDir+path
path = path.decode('utf-8')
path = apc.to_unicode(path)
path = path.encode('utf-8')
dest = dest.decode('utf-8')
dest = apc.to_unicode(dest)
dest = dest.encode('utf-8')
if(os.path.exists(path)):
if(os.path.isdir(path)):
@ -148,7 +148,7 @@ def WatchAddAction(option, opt, value, parser):
path = os.path.realpath(path)
else:
path = currentDir+path
path = path.decode('utf-8')
path = api_client.apc.to_unicode(path)
path = path.encode('utf-8')
if(os.path.isdir(path)):
res = api_client.add_watched_dir(path)
@ -189,7 +189,7 @@ def WatchRemoveAction(option, opt, value, parser):
path = os.path.realpath(path)
else:
path = currentDir+path
path = path.decode('utf-8')
path = apc.to_unicode(path)
path = path.encode('utf-8')
if(os.path.isdir(path)):
res = api_client.remove_watched_dir(path)
@ -235,7 +235,7 @@ def StorageSetAction(option, opt, value, parser):
path = os.path.realpath(path)
else:
path = currentDir+path
path = path.decode('utf-8')
path = apc.to_unicode(path)
path = path.encode('utf-8')
if(os.path.isdir(path)):
res = api_client.set_storage_dir(path)