本文整理汇总了Python中snakebite.client.Client.test方法的典型用法代码示例。如果您正苦于以下问题:Python Client.test方法的具体用法?Python Client.test怎么用?Python Client.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snakebite.client.Client
的用法示例。
在下文中一共展示了Client.test方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HDFSStat
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import test [as 别名]
class HDFSStat(object):
cluster = 'hostname'
port = 8020
default_path = '/user/hive/warehouse'
@staticmethod
def build_path(table):
nm = table.split('.')[0]
tb = table.split('.')[1]
return default_path + '/' + nm + '.db/' + tb
def __init__(self):
self.client = Client(HDFSStat.cluster, HDFSStat.port, use_trash=False)
def latest_partition(self, table_name, table_path=None):
t_path = HDFSStat.build_path(table_name) if table_path is None else table_path
latest_dir = list(self.client.ls([t_path])).pop()
return path.basename(latest_dir['path']).split('=')[1]
def poke_partition(self, table_name, partition_name, partition, table_path=None):
t_path = HDFSStat.build_path(table_name) if table_path is None else table_path
partition_path = t_path + '/' + partition_name + '=' + partition
return self.client.test(partition_path, exists=True, directory=True, zero_length=False)
示例2: is_exist
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import test [as 别名]
def is_exist(dirPath, master = public.SPARK_MASTER, port = public.SPARK_MASTER_PORT):
client = Client(master, port, use_trash=False)
return client.test(dirPath, exists=True, directory=True)
示例3: exists
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import test [as 别名]
def exists(self):
client = Client(self._host, self._port, effective_user=self._user, use_trash=False)
return client.test(self._partial, exists=True)
示例4: timedelta
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import test [as 别名]
swiftConf.set(key, value)
swift_client = swift.Connection(
user = swift_user,
key = swift_key,
authurl = swift_authurl)
# read list of files
src_files = []
if run_mode == "hdfs":
# spotify's snakebite as hdfs client
src_files = [ hdfs_url + files['path'] for files in hdfs_client.ls([source_files]) ]
# deleting output directory if exists
if (hdfs_client.test(target_dir, exists = True, directory = True)):
hdfs_client.delete(target_dir)
hdfs_client.rmdir(target_dir)
elif run_mode == "swift":
# read list of files from swift src_files = []
source_files = '|'.join([ '(pagecounts-' + (datetime.now() - timedelta(hours=i)).strftime("%Y%m%d-%H") + '(.*))' for i in range(48, 71) ])
src_file_regex = re.compile(source_files)
for data in swift_client.get_container(source_dir)[1]:
if src_file_regex.match(data['name']):
src_files.append(data['name'])
src_files.sort(key = lambda x: os.path.basename(x))
else:
# read list of files from local
示例5: Client
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import test [as 别名]
#!/usr/bin/env python
from snakebite.client import Client
client = Client("trevally.amer.nevint.com", 9000, use_trash=False)
def list_recursive(path):
for x in client.ls([path]):
if x['file_type']=='d':
list_recursive(x['path'])
else:
print x['path']
target = '/data/hub/vehicle/MKZ-Grey'
if client.test(target,directory=True):
list_recursive(target)