diff --git a/.gitignore b/.gitignore index 9c16294..58d39de 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,6 @@ coscmd/*.swn coscmd/*.swo *.project *.pydevproject -.settings/ \ No newline at end of file +.settings/ +.vscode/ +xcoscmd.egg-info diff --git a/README.rst b/README.rst index 27a6368..85a7655 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -COSCMD +XCOSCMD ####################### .. image:: https://img.shields.io/pypi/v/coscmd.svg @@ -16,16 +16,43 @@ _______ 安装指南 __________ -使用pip安装 :: +:: - pip install -U coscmd + python setup.py install + cd dist + sudo easy_install coscmd-1.8.6.3-py3.6.egg # 提前安装easy_install + ln -s {{PYTHON_DIR}}/bin/coscmd xcoscmd # [可选]为避免和官方coscmd冲突,通过软链使用此版本 +或 +:: + pip install xcoscmd -i https://pypi.tuna.tsinghua.edu.cn/simple +或 +:: + pip install xcoscmd -i https://pypi.doubanio.com/simple +或 +:: + pip install xcoscmd -i http://mirrors.tencent.com/pypi/simple + +改造 +__________ +上传命令,支持上传同名文件不覆盖,直接跳过 -手动安装:: +命令:: - python setup.py install + xcoscmd -rm ./app /app + +上传结果输出优化:上传失败的log红色显示,上传成功的log绿色显示,更加直观的显示上传结果 使用方法 __________ 使用coscmd,参照 https://cloud.tencent.com/document/product/436/10976 +附录:CentOS Python环境安装 +__________ + +:: + + yum install python3 + wget https://bootstrap.pypa.io/3.2/get-pip.py + python3 get-pip.py + diff --git a/RELEASE.rst b/RELEASE.rst new file mode 100644 index 0000000..8176406 --- /dev/null +++ b/RELEASE.rst @@ -0,0 +1,12 @@ +XCOSCMD + +发布指南 +__________ + +:: + + python setup.py sdist bdist_wheel + pip install twine + twine check dist/* + twine upload dist/* + diff --git a/coscmd/cos_global.py b/coscmd/cos_global.py deleted file mode 100644 index 0537fde..0000000 --- a/coscmd/cos_global.py +++ /dev/null @@ -1 +0,0 @@ -Version = "1.8.6.3" diff --git a/setup.py b/setup.py index 552ae8e..0e8045f 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages from platform import python_version_tuple -from coscmd import cos_global +from xcoscmd import cos_global def requirements(): @@ -22,19 +22,19 @@ def long_description(): setup( - name='coscmd', + name='xcoscmd', version=cos_global.Version, url='https://www.qcloud.com/', license='MIT', - author='lewzylu', - author_email='327874225@qq.com', - description='simple command for cos', + author='aslinwang', + author_email='dream_jet@qq.com', + description='simple command for cos, forked from https://github.com/tencentyun/coscmd', long_description=long_description(), packages=find_packages(), install_requires=requirements(), entry_points={ 'console_scripts': [ - 'coscmd=coscmd.cos_cmd:_main', + 'xcoscmd=xcoscmd.cos_cmd:_main', ], } ) diff --git a/coscmd/__init__.py b/xcoscmd/__init__.py similarity index 100% rename from coscmd/__init__.py rename to xcoscmd/__init__.py diff --git a/coscmd/cos_auth.py b/xcoscmd/cos_auth.py similarity index 92% rename from coscmd/cos_auth.py rename to xcoscmd/cos_auth.py index a5d0fec..2491196 100644 --- a/coscmd/cos_auth.py +++ b/xcoscmd/cos_auth.py @@ -10,13 +10,13 @@ from requests.auth import AuthBase if sys.version > '3': - from coscmd.cos_global import Version - from coscmd.cos_comm import to_bytes + from xcoscmd.cos_global import Version + from xcoscmd.cos_comm import to_bytes else: from cos_global import Version from cos_comm import to_bytes -logger = logging.getLogger("coscmd") +logger = logging.getLogger("xcoscmd") class CosS3Auth(AuthBase): @@ -80,7 +80,7 @@ def __call__(self, r): r.headers['Authorization'] = "" if self._token is not None: r.headers['x-cos-security-token'] = self._token - r.headers['User-agent'] = 'coscmd-v' + Version + r.headers['User-agent'] = 'xcoscmd-v' + Version logger.debug("sign_key" + str(sign_key)) logger.debug(r.headers['Authorization']) diff --git a/coscmd/cos_client.py b/xcoscmd/cos_client.py similarity index 95% rename from coscmd/cos_client.py rename to xcoscmd/cos_client.py index 3b200b1..cae81e1 100644 --- a/coscmd/cos_client.py +++ b/xcoscmd/cos_client.py @@ -24,15 +24,17 @@ import qcloud_cos if sys.version > '3': - from coscmd.cos_auth import CosS3Auth - from coscmd.cos_threadpool import SimpleThreadPool - from coscmd.cos_comm import * + from xcoscmd.cos_auth import CosS3Auth + from xcoscmd.cos_threadpool import SimpleThreadPool + from xcoscmd.cos_comm import * + from xcoscmd.cos_color import * else: from cos_auth import CosS3Auth from cos_threadpool import SimpleThreadPool from cos_comm import * + from cos_color import * -logger = logging.getLogger("coscmd") +logger = logging.getLogger("xcoscmd") class CoscmdConfig(object): @@ -154,6 +156,15 @@ def check_file_md5(self, _local_path, _cos_path, _md5): return False else: return True + + def check_file_name(self, _local_path, _cos_path): + url = self._conf.uri(path=quote(to_printable_str(_cos_path))) + rt = self._session.head( + url=url, auth=CosS3Auth(self._conf), stream=True) + if rt.status_code != 200: #资源不存在 + return False + else: + return True def sign_url(self, cos_path, timeout=10000): cos_path = to_printable_str(cos_path) @@ -298,10 +309,6 @@ def upload_file_list(upload_filelist): return -1 def single_upload(self, local_path, cos_path, _http_headers='{}', **kwargs): - logger.info(u"Upload {local_path} => cos://{bucket}/{cos_path}".format( - bucket=self._conf._bucket, - local_path=local_path, - cos_path=cos_path)) _md5 = "" try: _http_header = yaml.safe_load(_http_headers) @@ -327,6 +334,13 @@ def single_upload(self, local_path, cos_path, _http_headers='{}', **kwargs): logger.info( u"The file on cos is the same as the local file, skip upload") return -2 + if kwargs['mutex'] is True: + if self.check_file_name(local_path, cos_path): + logger.error( + u"The file {cos_path} on cos has same name as the local file, skip upload".format( + cos_path=cos_path + )) + return -2 try: if len(local_path) == 0: data = "" @@ -340,7 +354,7 @@ def single_upload(self, local_path, cos_path, _http_headers='{}', **kwargs): for j in range(self._retry): try: if j > 0: - logger.info(u"Retry to upload {local_path} => cos://{bucket}/{cos_path}".format( + logger.warn(u"Retry to upload {local_path} => cos://{bucket}/{cos_path}".format( bucket=self._conf._bucket, local_path=local_path, cos_path=cos_path)) @@ -349,6 +363,10 @@ def single_upload(self, local_path, cos_path, _http_headers='{}', **kwargs): rt = self._session.put(url=url, auth=CosS3Auth(self._conf), data=data, headers=http_header) if rt.status_code == 200: + logger.info(u"Upload {local_path} => cos://{bucket}/{cos_path} success".format( + bucket=self._conf._bucket, + local_path=local_path, + cos_path=cos_path)) return 0 else: time.sleep(2**j) @@ -502,10 +520,6 @@ def complete_multiupload(): logger.warn(e) return -1 - logger.info(u"Upload {local_path} => cos://{bucket}/{cos_path}".format( - bucket=self._conf._bucket, - local_path=local_path, - cos_path=cos_path)) _md5 = "" try: _http_header = yaml.safe_load(_http_headers) @@ -531,6 +545,13 @@ def complete_multiupload(): logger.info( u"The file on cos is the same as the local file, skip upload") return -2 + if kwargs['mutex'] is True: + if self.check_file_name(local_path, cos_path): + logger.error( + u"The file {cos_path} on cos has same name as the local file, skip upload".format( + cos_path=cos_path + )) + return -2 rt = init_multiupload() if 0 == rt: logger.debug(u"Init multipart upload ok") @@ -546,7 +567,10 @@ def complete_multiupload(): return -1 rt = complete_multiupload() if 0 == rt: - logger.debug(u"Complete multipart upload ok") + logger.info(u"Upload {local_path}(multipart) => cos://{bucket}/{cos_path} success".format( + bucket=self._conf._bucket, + local_path=local_path, + cos_path=cos_path)) else: logger.warn(u"Complete multipart upload failed") return -1 @@ -2040,6 +2064,7 @@ def probe(self, **kwargs): kw = { "skipmd5": True, "sync": False, + "mutex": False, "force": True, "ignore": ""} time_start = time.time() diff --git a/coscmd/cos_cmd.py b/xcoscmd/cos_cmd.py similarity index 94% rename from coscmd/cos_cmd.py rename to xcoscmd/cos_cmd.py index 2662cf2..3b105a0 100644 --- a/coscmd/cos_cmd.py +++ b/xcoscmd/cos_cmd.py @@ -9,16 +9,16 @@ import json import requests from threading import Thread -from coscmd import cos_global +from xcoscmd import cos_global if sys.version > '3': - from coscmd.cos_client import CoscmdConfig, CosS3Client - from coscmd.cos_global import Version + from xcoscmd.cos_client import CoscmdConfig, CosS3Client + from xcoscmd.cos_global import Version else: from cos_client import CoscmdConfig, CosS3Client from cos_global import Version -logger = logging.getLogger("coscmd") +logger = logging.getLogger("xcoscmd") fs_coding = sys.getfilesystemencoding() @@ -95,7 +95,7 @@ def load_conf(): conf_path = os.path.expanduser(config_path) if not os.path.exists(conf_path): - logger.warn("{conf} couldn't be found, please use \'coscmd config -h\' to learn how to config coscmd!".format(conf=to_printable_str(conf_path))) + logger.warn("{conf} couldn't be found, please use \'xcoscmd config -h\' to learn how to config xcoscmd!".format(conf=to_printable_str(conf_path))) raise IOError else: logger.debug('{conf} is found'.format(conf=to_printable_str(conf_path))) @@ -218,6 +218,7 @@ def upload(args): args.cos_path = args.cos_path[1:] kwargs = {} kwargs['sync'] = args.sync + kwargs['mutex'] = args.mutex kwargs['skipmd5'] = args.skipmd5 kwargs['ignore'] = args.ignore.split(',') kwargs['force'] = args.force @@ -639,15 +640,15 @@ def get_version(): def version_check(): try: - ret = requests.get("https://pypi.org/pypi/coscmd/json").content + ret = requests.get("https://pypi.org/pypi/xcoscmd/json").content res_json = json.loads(ret) latest_version = res_json["info"]["version"] lat_spl = latest_version.split('.') cur_spl = cos_global.Version.split('.') if cur_spl[0] < lat_spl[0] or cur_spl[1] < lat_spl[1] or cur_spl[2] < lat_spl[2]: - logger.info("The current version of coscmd is {v1} \ + logger.info("The current version of xcoscmd is {v1} \ and the latest version is {v2}. It is recommended \ -to upgrade coscmd with the command'pip install coscmd -U'.".format(v1=cos_global.Version, v2=latest_version)) +to upgrade xcoscmd with the command'pip install xcoscmd -U'.".format(v1=cos_global.Version, v2=latest_version)) except Exception as e: logger.debug(e) @@ -656,8 +657,8 @@ def command_thread(): global res res = -1 desc = """an easy-to-use but powerful command-line tool. - try \'coscmd -h\' to get more informations. - try \'coscmd sub-command -h\' to learn all command usage, likes \'coscmd upload -h\'""" + try \'xcoscmd -h\' to get more informations. + try \'xcoscmd sub-command -h\' to learn all command usage, likes \'xcoscmd upload -h\'""" parser = ArgumentParser(description=desc) parser.add_argument('-d', '--debug', help="Debug mode", action="store_true", default=False) parser.add_argument('-b', '--bucket', help="Specify bucket", type=str, default="") @@ -690,6 +691,7 @@ def command_thread(): parser_upload.add_argument('-r', '--recursive', help="Upload recursively when upload directory", action="store_true", default=False) parser_upload.add_argument('-H', '--headers', help="Specify HTTP headers", type=str, default='{}') parser_upload.add_argument('-s', '--sync', help="Upload and skip the same file", action="store_true", default=False) + parser_upload.add_argument('-m', '--mutex', help="Upload and skip the file has same name", action="store_true", default=False) parser_upload.add_argument('-f', '--force', help="upload without history breakpoint", action="store_true", default=False) parser_upload.add_argument('--ignore', help='Specify ignored rules, separated by commas; Example: *.txt,*.docx,*.ppt', type=str, default="") parser_upload.add_argument('--skipmd5', help='Upload without x-cos-meta-md5', action="store_true", default=False) @@ -801,7 +803,7 @@ def command_thread(): args = parser.parse_args() - logger = logging.getLogger('coscmd') + logger = logging.getLogger('xcoscmd') logger.setLevel(logging.INFO) console = logging.StreamHandler() console.setLevel(logging.INFO) @@ -811,7 +813,7 @@ def command_thread(): handler = RotatingFileHandler(os.path.expanduser(args.log_path), maxBytes=128*1024*1024, backupCount=1) handler.setFormatter(logging.Formatter('%(asctime)s - [%(levelname)s]: %(message)s')) logger.addHandler(handler) - logging.getLogger('coscmd').addHandler(console) + logging.getLogger('xcoscmd').addHandler(console) global pre_appid, pre_bucket, pre_region, config_path config_path = args.config_path pre_bucket = args.bucket diff --git a/xcoscmd/cos_color.py b/xcoscmd/cos_color.py new file mode 100644 index 0000000..bab0a8a --- /dev/null +++ b/xcoscmd/cos_color.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# encoding: utf-8 +import logging +# now we patch Python code to add color support to logging.StreamHandler +def add_coloring_to_emit_windows(fn): + # add methods we need to the class + def _out_handle(self): + import ctypes + return ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE) + out_handle = property(_out_handle) + + def _set_color(self, code): + import ctypes + # Constants from the Windows API + self.STD_OUTPUT_HANDLE = -11 + hdl = ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE) + ctypes.windll.kernel32.SetConsoleTextAttribute(hdl, code) + + setattr(logging.StreamHandler, '_set_color', _set_color) + + def new(*args): + FOREGROUND_BLUE = 0x0001 # text color contains blue. + FOREGROUND_GREEN = 0x0002 # text color contains green. + FOREGROUND_RED = 0x0004 # text color contains red. + FOREGROUND_INTENSITY = 0x0008 # text color is intensified. + FOREGROUND_WHITE = FOREGROUND_BLUE|FOREGROUND_GREEN |FOREGROUND_RED + # winbase.h + STD_INPUT_HANDLE = -10 + STD_OUTPUT_HANDLE = -11 + STD_ERROR_HANDLE = -12 + + # wincon.h + FOREGROUND_BLACK = 0x0000 + FOREGROUND_BLUE = 0x0001 + FOREGROUND_GREEN = 0x0002 + FOREGROUND_CYAN = 0x0003 + FOREGROUND_RED = 0x0004 + FOREGROUND_MAGENTA = 0x0005 + FOREGROUND_YELLOW = 0x0006 + FOREGROUND_GREY = 0x0007 + FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified. + + BACKGROUND_BLACK = 0x0000 + BACKGROUND_BLUE = 0x0010 + BACKGROUND_GREEN = 0x0020 + BACKGROUND_CYAN = 0x0030 + BACKGROUND_RED = 0x0040 + BACKGROUND_MAGENTA = 0x0050 + BACKGROUND_YELLOW = 0x0060 + BACKGROUND_GREY = 0x0070 + BACKGROUND_INTENSITY = 0x0080 # background color is intensified. + + levelno = args[1].levelno + if(levelno>=50): + color = BACKGROUND_YELLOW | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY + elif(levelno>=40): + color = FOREGROUND_RED | FOREGROUND_INTENSITY + elif(levelno>=30): + color = FOREGROUND_YELLOW | FOREGROUND_INTENSITY + elif(levelno>=20): + color = FOREGROUND_GREEN + elif(levelno>=10): + color = FOREGROUND_MAGENTA + else: + color = FOREGROUND_WHITE + args[0]._set_color(color) + + ret = fn(*args) + args[0]._set_color( FOREGROUND_WHITE ) + #print "after" + return ret + return new + +def add_coloring_to_emit_ansi(fn): + # add methods we need to the class + def new(*args): + levelno = args[1].levelno + if(levelno>=50): # fatal,critical + color = '\x1b[31m' # red + elif(levelno>=40): # error + color = '\x1b[31m' # red + elif(levelno>=30): # warn,warning + color = '\x1b[33m' # yellow + elif(levelno>=20): # info + color = '\x1b[32m' # green + elif(levelno>=10): # debug + color = '\x1b[35m' # pink + else: + color = '\x1b[0m' # normal + args[1].msg = color + args[1].msg + '\x1b[0m' # normal + #print "after" + return fn(*args) + return new + +import platform +if platform.system()=='Windows': + # Windows does not support ANSI escapes and we are using API calls to set the console color + logging.StreamHandler.emit = add_coloring_to_emit_windows(logging.StreamHandler.emit) +else: + # all non-Windows platforms are supporting ANSI escapes so we use them + logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit) + #log = logging.getLogger() + #log.addFilter(log_filter()) + #//hdlr = logging.StreamHandler() + #//hdlr.setFormatter(formatter()) \ No newline at end of file diff --git a/coscmd/cos_comm.py b/xcoscmd/cos_comm.py similarity index 100% rename from coscmd/cos_comm.py rename to xcoscmd/cos_comm.py diff --git a/xcoscmd/cos_global.py b/xcoscmd/cos_global.py new file mode 100644 index 0000000..7b2bb25 --- /dev/null +++ b/xcoscmd/cos_global.py @@ -0,0 +1 @@ +Version = "1.8.6.4" diff --git a/coscmd/cos_threadpool.py b/xcoscmd/cos_threadpool.py similarity index 95% rename from coscmd/cos_threadpool.py rename to xcoscmd/cos_threadpool.py index 2e678e9..a5dcc4d 100644 --- a/coscmd/cos_threadpool.py +++ b/xcoscmd/cos_threadpool.py @@ -6,7 +6,7 @@ from threading import Lock import gc import time -logger = getLogger("coscmd") +logger = getLogger("xcoscmd") class WorkerThread(Thread): diff --git a/coscmd/test.py b/xcoscmd/test.py similarity index 65% rename from coscmd/test.py rename to xcoscmd/test.py index 46544f1..e47f6df 100644 --- a/coscmd/test.py +++ b/xcoscmd/test.py @@ -43,17 +43,17 @@ def gen_file(path, size): def setUp(): """create testbucket""" os.system("python setup.py install") - os.system("python coscmd/cos_cmd.py config -a %s -s %s -b %s -r %s" % (access_id, access_key, bucket_name, region)) + os.system("python xcoscmd/cos_cmd.py config -a %s -s %s -b %s -r %s" % (access_id, access_key, bucket_name, region)) print("创建bucket") - os.system("python coscmd/cos_cmd.py createbucket >/dev/null 2>&1") + os.system("python xcoscmd/cos_cmd.py createbucket >/dev/null 2>&1") time.sleep(5) def tearDown(): """delete testbucket""" print("删除bucket") - os.system("python coscmd/cos_cmd.py delete -rf / >/dev/null 2>&1") - os.system("python coscmd/cos_cmd.py deletebucket >/dev/null 2>&1") + os.system("python xcoscmd/cos_cmd.py delete -rf / >/dev/null 2>&1") + os.system("python xcoscmd/cos_cmd.py deletebucket >/dev/null 2>&1") time.sleep(5) @@ -63,7 +63,7 @@ def test_upload_object_1MB(): with open(file_name, 'rb') as f: etag = get_raw_md5(f.read()) - rt = os.system("python coscmd/cos_cmd.py upload {local_path} {cos_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) + rt = os.system("python xcoscmd/cos_cmd.py upload {local_path} {cos_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) assert rt == 0 return etag @@ -71,7 +71,7 @@ def test_upload_object_1MB(): def test_download_object_1MB(): """下载1MB小文件""" etag = test_upload_object_1MB() - rt = os.system("python coscmd/cos_cmd.py download -f {cos_path} {local_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) + rt = os.system("python xcoscmd/cos_cmd.py download -f {cos_path} {local_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) assert rt == 0 with open(file_name, 'rb') as f: @@ -88,7 +88,7 @@ def test_upload_object_30MB(): with open(file_name, 'rb') as f: etag = get_raw_md5(f.read()) - rt = os.system("python coscmd/cos_cmd.py upload {local_path} {cos_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) + rt = os.system("python xcoscmd/cos_cmd.py upload {local_path} {cos_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) assert rt == 0 return etag @@ -96,7 +96,7 @@ def test_upload_object_30MB(): def test_download_object_30MB(): """下载30MB文件""" etag = test_upload_object_30MB() - rt = os.system("python coscmd/cos_cmd.py download -f {cos_path} {local_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) + rt = os.system("python xcoscmd/cos_cmd.py download -f {cos_path} {local_path} >/dev/null 2>&1".format(local_path=file_name, cos_path=file_name)) assert rt == 0 with open(file_name, 'rb') as f: @@ -110,7 +110,7 @@ def test_download_object_30MB(): def test_delete_object_1MB(): """删除1MB小文件""" test_upload_object_1MB() - rt = os.system("python coscmd/cos_cmd.py delete -f {cos_path} >/dev/null 2>&1".format(cos_path=file_name)) + rt = os.system("python xcoscmd/cos_cmd.py delete -f {cos_path} >/dev/null 2>&1".format(cos_path=file_name)) assert rt == 0 if os.path.exists(file_name): @@ -119,15 +119,15 @@ def test_delete_object_1MB(): def test_bucketacl(): """Bucket ACL测试""" - rt = os.system("python coscmd/cos_cmd.py putbucketacl --grant-read anyone --grant-write anyone --grant-full-control anyone >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py putbucketacl --grant-read anyone --grant-write anyone --grant-full-control anyone >/dev/null 2>&1") assert rt == 0 - rt = os.system("python coscmd/cos_cmd.py getbucketacl >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py getbucketacl >/dev/null 2>&1") assert rt == 0 def test_probe(): """探测测试""" - rt = os.system("python coscmd/cos_cmd.py probe >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py probe >/dev/null 2>&1") assert rt == 0 @@ -141,10 +141,10 @@ def test_upload_folder(): for i in range(file_num): gen_file("testfolder/testfile_" + str(i), 0.01) print("文件夹上传") - rt = os.system("python coscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") assert rt == 0 print("文件夹同步上传") - rt = os.system("python coscmd/cos_cmd.py upload -rs testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py upload -rs testfolder testfolder >/dev/null 2>&1") assert rt == 0 os.system("rm -rf testfolder/") @@ -159,14 +159,14 @@ def test_download_folder(): for i in range(file_num): gen_file("testfolder/testfile_" + str(i), 0.01) print("文件夹上传") - rt = os.system("python coscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") assert rt == 0 time.sleep(5) print("文件夹下载") - rt = os.system("python coscmd/cos_cmd.py download -rf testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py download -rf testfolder testfolder >/dev/null 2>&1") assert rt == 0 print("文件夹同步下载") - rt = os.system("python coscmd/cos_cmd.py download -rsf testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py download -rsf testfolder testfolder >/dev/null 2>&1") assert rt == 0 os.system("rm -rf testfolder/") @@ -181,11 +181,11 @@ def test_copy_folder(): for i in range(file_num): gen_file("testfolder/testfile_" + str(i), 0.01) print("文件夹上传") - rt = os.system("python coscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") assert rt == 0 time.sleep(5) print("文件夹复制") - rt = os.system("python coscmd/cos_cmd.py copy -r %s.cos.%s.myqcloud.com/testfolder testfolder2 >/dev/null 2>&1" % (bucket_name, region)) + rt = os.system("python xcoscmd/cos_cmd.py copy -r %s.cos.%s.myqcloud.com/testfolder testfolder2 >/dev/null 2>&1" % (bucket_name, region)) assert rt == 0 os.system("rm -rf testfolder/") @@ -200,13 +200,13 @@ def test_list_folder(): for i in range(file_num): gen_file("testfolder/testfile_" + str(i), 0.01) print("文件夹上传") - rt = os.system("python coscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py upload -r testfolder testfolder >/dev/null 2>&1") assert rt == 0 time.sleep(5) print("打印对象") - rt = os.system("python coscmd/cos_cmd.py list -n 10 >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py list -n 10 >/dev/null 2>&1") print("打印全部对象") - rt = os.system("python coscmd/cos_cmd.py list -ar >/dev/null 2>&1") + rt = os.system("python xcoscmd/cos_cmd.py list -ar >/dev/null 2>&1") assert rt == 0 os.system("rm -rf testfolder/")