diff --git a/qingstor/qsctl/commands/base.py b/qingstor/qsctl/commands/base.py index 02066167..e6f1a51a 100644 --- a/qingstor/qsctl/commands/base.py +++ b/qingstor/qsctl/commands/base.py @@ -101,8 +101,8 @@ def validate_bucket(cls, bucket): current_bucket = cls.client.Bucket(bucket, cls.bucket_map[bucket]) resp = current_bucket.head() if resp.status_code != HTTP_OK: - print("Error: Please check if you have " - "enough permission to access it." % bucket) + print("Error: Please check if you have enough" + " permission to access bucket <%s>." % bucket) sys.exit(-1) @classmethod diff --git a/qingstor/qsctl/commands/transfer.py b/qingstor/qsctl/commands/transfer.py index 94ff69a3..2f9c2505 100644 --- a/qingstor/qsctl/commands/transfer.py +++ b/qingstor/qsctl/commands/transfer.py @@ -151,7 +151,8 @@ def upload_file(cls, options): else: key = prefix if os.path.isfile(options.source_path): - if cls.confirm_key_upload(options, options.source_path, bucket, key): + if cls.confirm_key_upload(options, options.source_path, bucket, + key): cls.send_local_file(options.source_path, bucket, key) elif options.source_path == '-': cls.send_data_from_stdin(bucket, key) @@ -273,7 +274,6 @@ def send_data_from_stdin(cls, bucket, key): else: print("Error: Failed to upload file '%s'" % '-') - @classmethod def send_file(cls, local_path, bucket, key): with open(local_path, "rb") as data: diff --git a/tests/commands/test_transfer.py b/tests/commands/test_transfer.py index 176a58ad..48e15dac 100644 --- a/tests/commands/test_transfer.py +++ b/tests/commands/test_transfer.py @@ -77,15 +77,14 @@ def test_upload_file(self): def test_upload_file_from_stdin(self): # Create a large file(~8MB) with open("tmp/large_file", 'w') as f: - f.seek(8*1024*1024) + f.seek(8 * 1024 * 1024) f.write("just for testing") options = MockOptions( source_path="-", dest_path="qs://" + test_bucket1, exclude=None, include=None, - force=True - ) + force=True) with open("tmp/large_file", 'rb') as f: with patch("qingstor.qsctl.utils.sys.stdin", f): self.Transfer.upload_file(options) @@ -98,8 +97,7 @@ def test_upload_file_from_stdin(self): dest_path="qs://" + test_bucket1, exclude=None, include=None, - force=True - ) + force=True) with open("tmp/small_file", 'rb') as f: with patch("qingstor.qsctl.utils.sys.stdin", f): self.Transfer.upload_file(options)