rclone-api 1.1.32__py2.py3-none-any.whl → 1.1.34__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,148 @@
1
+ """
2
+ Unit test file.
3
+ """
4
+
5
+ import os
6
+ import time
7
+
8
+ import psutil
9
+ from dotenv import load_dotenv
10
+
11
+ from rclone_api import Config, Rclone, SizeSuffix
12
+
13
+ load_dotenv()
14
+
15
+ BUCKET_NAME = os.getenv("BUCKET_NAME") # Default if not in .env
16
+
17
+
18
+ def _generate_rclone_config() -> Config:
19
+
20
+ # assert that .env exists for this test
21
+ assert os.path.exists(
22
+ ".env"
23
+ ), "this test requires that the secret .env file exists with the credentials"
24
+
25
+ # BUCKET_NAME = os.getenv("BUCKET_NAME", "TorrentBooks") # Default if not in .env
26
+
27
+ # Load additional environment variables
28
+ BUCKET_KEY_SECRET = os.getenv("BUCKET_KEY_SECRET")
29
+ BUCKET_KEY_PUBLIC = os.getenv("BUCKET_KEY_PUBLIC")
30
+ SRC_SFTP_HOST = os.getenv("SRC_SFTP_HOST")
31
+ SRC_SFTP_USER = os.getenv("SRC_SFTP_USER")
32
+ SRC_SFTP_PORT = os.getenv("SRC_SFTP_PORT")
33
+ SRC_SFTP_PASS = os.getenv("SRC_SFTP_PASS")
34
+ # BUCKET_URL = os.getenv("BUCKET_URL")
35
+ BUCKET_URL = "sfo3.digitaloceanspaces.com"
36
+
37
+ config_text = f"""
38
+ [dst]
39
+ type = s3
40
+ provider = DigitalOcean
41
+ access_key_id = {BUCKET_KEY_PUBLIC}
42
+ secret_access_key = {BUCKET_KEY_SECRET}
43
+ endpoint = {BUCKET_URL}
44
+ bucket = {BUCKET_NAME}
45
+
46
+ [src]
47
+ type = sftp
48
+ host = {SRC_SFTP_HOST}
49
+ user = {SRC_SFTP_USER}
50
+ port = {SRC_SFTP_PORT}
51
+ pass = {SRC_SFTP_PASS}
52
+
53
+ """
54
+ # _CONFIG_PATH.write_text(config_text, encoding="utf-8")
55
+ # print(f"Config file written to: {_CONFIG_PATH}")
56
+ return Config(config_text)
57
+
58
+
59
+ def _init() -> None:
60
+ """Check if all required environment variables are set before running tests."""
61
+ required_vars = [
62
+ "BUCKET_NAME",
63
+ "BUCKET_KEY_SECRET",
64
+ "BUCKET_KEY_PUBLIC",
65
+ "BUCKET_URL",
66
+ ]
67
+ missing = [var for var in required_vars if not os.getenv(var)]
68
+ if missing:
69
+ print(f"Missing required environment variables: {', '.join(missing)}")
70
+ os.environ["RCLONE_API_VERBOSE"] = "1"
71
+
72
+
73
+ def test_profile_copy_bytes() -> None:
74
+ print("Running test_profile_copy_bytes")
75
+ rclone = Rclone(_generate_rclone_config())
76
+ sizes = [
77
+ 1024 * 1024 * 1,
78
+ 1024 * 1024 * 2,
79
+ 1024 * 1024 * 4,
80
+ 1024 * 1024 * 8,
81
+ 1024 * 1024 * 16,
82
+ 1024 * 1024 * 32,
83
+ 1024 * 1024 * 64,
84
+ ]
85
+ # transfer_list = [1, 2, 4, 8, 16]
86
+ transfer_list = [1, 2, 4]
87
+
88
+ # src_file = "dst:rclone-api-unit-test/zachs_video/internaly_ai_alignment.mp4"
89
+ # sftp mount
90
+ src_file = "src:aa_misc_data/aa_misc_data/world_lending_library_2024_11.tar.zst"
91
+
92
+ for size in sizes:
93
+ for transfers in transfer_list:
94
+ print("\n\n")
95
+ print("#" * 80)
96
+ print(
97
+ f"# Started test download of {SizeSuffix(size)} with {transfers} transfers"
98
+ )
99
+ print("#" * 80)
100
+ net_io_start = psutil.net_io_counters()
101
+ start = time.time()
102
+ bytes_or_err: bytes | Exception = rclone.copy_bytes(
103
+ src=src_file,
104
+ offset=0,
105
+ length=size,
106
+ direct_io=True,
107
+ transfers=transfers,
108
+ )
109
+ diff = time.time() - start
110
+ net_io_end = psutil.net_io_counters()
111
+ if isinstance(bytes_or_err, Exception):
112
+ print(bytes_or_err)
113
+ assert False, f"Error: {bytes_or_err}"
114
+ assert isinstance(bytes_or_err, bytes)
115
+ # self.assertEqual(len(bytes_or_err), size)
116
+ assert len(bytes_or_err) == size, f"Length: {len(bytes_or_err)} != {size}"
117
+
118
+ # print io stats
119
+ bytes_sent = net_io_end.bytes_sent - net_io_start.bytes_sent
120
+ bytes_recv = net_io_end.bytes_recv - net_io_start.bytes_recv
121
+ packets_sent = net_io_end.packets_sent - net_io_start.packets_sent
122
+ efficiency = size / (bytes_recv)
123
+ efficiency_100 = efficiency * 100
124
+ efficiency_str = f"{efficiency_100:.2f}"
125
+
126
+ bytes_send_suffix = SizeSuffix(bytes_sent)
127
+ bytes_recv_suffix = SizeSuffix(bytes_recv)
128
+ range_size = SizeSuffix(size)
129
+
130
+ print(f"\nFinished downloading {range_size} with {transfers} transfers")
131
+ print("Net IO stats:")
132
+ print(f"Bytes sent: {bytes_send_suffix}")
133
+ print(f"Bytes received: {bytes_recv_suffix}")
134
+ print(f"Packets sent: {packets_sent}")
135
+ print(f"Efficiency: {efficiency_str}%")
136
+ print(f"Time: {diff:.1f} seconds")
137
+
138
+ print("done")
139
+
140
+
141
+ def main() -> None:
142
+ """Main entry point."""
143
+ _init()
144
+ test_profile_copy_bytes()
145
+
146
+
147
+ if __name__ == "__main__":
148
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.1.32
3
+ Version: 1.1.34
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -25,7 +25,7 @@ rclone_api/cmd/copy_large_s3.py,sha256=-rfedi-ZzPUdCSP8ai9LRL0y1xVkvN-viQQlk8HVU
25
25
  rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
26
26
  rclone_api/experimental/flags.py,sha256=qCVD--fSTmzlk9hloRLr0q9elzAOFzPsvVpKM3aB1Mk,2739
27
27
  rclone_api/experimental/flags_base.py,sha256=ajU_czkTcAxXYU-SlmiCfHY7aCQGHvpCLqJ-Z8uZLk0,2102
28
- rclone_api/profiling/mount_copy_bytes.py,sha256=WfCikFiFhLoZhnTjiKzJkpPWb0dOsfgjfcRtkWoY2Fs,4794
28
+ rclone_api/profile/mount_copy_bytes.py,sha256=XpVmEh0x0S2XlivWf85OcDzUxpAv_lE2hVaiJtvt4fg,4537
29
29
  rclone_api/s3/api.py,sha256=qxtRDUpHYqJ7StJRtP8U_PbF_BvYRg705568SyvF-R0,3770
30
30
  rclone_api/s3/basic_ops.py,sha256=hK3366xhVEzEcjz9Gk_8lFx6MRceAk72cax6mUrr6ko,2104
31
31
  rclone_api/s3/chunk_file.py,sha256=YELR-EzR7RHpzCDGpYdzlwu21NZW5wttIDvLoONI4aU,3477
@@ -33,9 +33,9 @@ rclone_api/s3/chunk_types.py,sha256=LbXayXY1KgVU1LkdbASD_BQ7TpVpwVnzMjtz--8LBaE,
33
33
  rclone_api/s3/create.py,sha256=wgfkapv_j904CfKuWyiBIWJVxfAx_ftemFSUV14aT68,3149
34
34
  rclone_api/s3/types.py,sha256=yBnJ38Tjk6RlydJ-sqZ7DSfyFloy8KDYJ0mv3vlOzLE,1388
35
35
  rclone_api/s3/upload_file_multipart.py,sha256=1jQAdk35Fa9Tcq36bS65262cs7AcNG2DAFQ-NdYlWSw,9961
36
- rclone_api-1.1.32.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
37
- rclone_api-1.1.32.dist-info/METADATA,sha256=ar5X9lipUNxKc2mAzx3wBqIl1jMAyaoVJRicNBs4grY,4537
38
- rclone_api-1.1.32.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
39
- rclone_api-1.1.32.dist-info/entry_points.txt,sha256=6eNqTRXKhVf8CpWNjXiOa_0Du9tHiW_HD2iQSXRsUg8,132
40
- rclone_api-1.1.32.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
41
- rclone_api-1.1.32.dist-info/RECORD,,
36
+ rclone_api-1.1.34.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
37
+ rclone_api-1.1.34.dist-info/METADATA,sha256=7USuJIMKwDRzG2L9FP2ZV6Zwi1Ceg3qwykofMZ7ug0M,4537
38
+ rclone_api-1.1.34.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
39
+ rclone_api-1.1.34.dist-info/entry_points.txt,sha256=TV8kwP3FRzYwUEr0RLC7aJh0W03SAefIJNXTJ-FdMIQ,200
40
+ rclone_api-1.1.34.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
41
+ rclone_api-1.1.34.dist-info/RECORD,,
@@ -1,3 +1,4 @@
1
1
  [console_scripts]
2
2
  rclone-api-copylarge-s3 = rclone_api.cmd.copy_large_s3:main
3
3
  rclone-api-listfiles = rclone_api.cmd.list_files:main
4
+ rclone-api-profile-mount = rclone_api.profile.mount_copy_bytes:main
@@ -1,146 +0,0 @@
1
- """
2
- Unit test file.
3
- """
4
-
5
- import os
6
- import time
7
- import unittest
8
-
9
- import psutil
10
- from dotenv import load_dotenv
11
-
12
- from rclone_api import Config, Rclone, SizeSuffix
13
-
14
- load_dotenv()
15
-
16
- BUCKET_NAME = os.getenv("BUCKET_NAME") # Default if not in .env
17
-
18
-
19
- def _generate_rclone_config() -> Config:
20
-
21
- # assert that .env exists for this test
22
- assert os.path.exists(
23
- ".env"
24
- ), "this test requires that the secret .env file exists with the credentials"
25
-
26
- # BUCKET_NAME = os.getenv("BUCKET_NAME", "TorrentBooks") # Default if not in .env
27
-
28
- # Load additional environment variables
29
- BUCKET_KEY_SECRET = os.getenv("BUCKET_KEY_SECRET")
30
- BUCKET_KEY_PUBLIC = os.getenv("BUCKET_KEY_PUBLIC")
31
- SRC_SFTP_HOST = os.getenv("SRC_SFTP_HOST")
32
- SRC_SFTP_USER = os.getenv("SRC_SFTP_USER")
33
- SRC_SFTP_PORT = os.getenv("SRC_SFTP_PORT")
34
- SRC_SFTP_PASS = os.getenv("SRC_SFTP_PASS")
35
- # BUCKET_URL = os.getenv("BUCKET_URL")
36
- BUCKET_URL = "sfo3.digitaloceanspaces.com"
37
-
38
- config_text = f"""
39
- [dst]
40
- type = s3
41
- provider = DigitalOcean
42
- access_key_id = {BUCKET_KEY_PUBLIC}
43
- secret_access_key = {BUCKET_KEY_SECRET}
44
- endpoint = {BUCKET_URL}
45
- bucket = {BUCKET_NAME}
46
-
47
- [src]
48
- type = sftp
49
- host = {SRC_SFTP_HOST}
50
- user = {SRC_SFTP_USER}
51
- port = {SRC_SFTP_PORT}
52
- pass = {SRC_SFTP_PASS}
53
-
54
- """
55
- # _CONFIG_PATH.write_text(config_text, encoding="utf-8")
56
- # print(f"Config file written to: {_CONFIG_PATH}")
57
- return Config(config_text)
58
-
59
-
60
- class RcloneProfileCopyBytes(unittest.TestCase):
61
- """Test rclone functionality."""
62
-
63
- def setUp(self) -> None:
64
- """Check if all required environment variables are set before running tests."""
65
- required_vars = [
66
- "BUCKET_NAME",
67
- "BUCKET_KEY_SECRET",
68
- "BUCKET_KEY_PUBLIC",
69
- "BUCKET_URL",
70
- ]
71
- missing = [var for var in required_vars if not os.getenv(var)]
72
- if missing:
73
- self.skipTest(
74
- f"Missing required environment variables: {', '.join(missing)}"
75
- )
76
- os.environ["RCLONE_API_VERBOSE"] = "1"
77
-
78
- def test_profile_copy_bytes(self) -> None:
79
- print("Running test_profile_copy_bytes")
80
- rclone = Rclone(_generate_rclone_config())
81
- sizes = [
82
- 1024 * 1024 * 1,
83
- 1024 * 1024 * 2,
84
- 1024 * 1024 * 4,
85
- 1024 * 1024 * 8,
86
- 1024 * 1024 * 16,
87
- 1024 * 1024 * 32,
88
- 1024 * 1024 * 64,
89
- ]
90
- # transfer_list = [1, 2, 4, 8, 16]
91
- transfer_list = [1, 2, 4]
92
-
93
- # src_file = "dst:rclone-api-unit-test/zachs_video/internaly_ai_alignment.mp4"
94
- # sftp mount
95
- src_file = "src:aa_misc_data/aa_misc_data/world_lending_library_2024_11.tar.zst"
96
-
97
- for size in sizes:
98
- for transfers in transfer_list:
99
- print("\n\n")
100
- print("#" * 80)
101
- print(
102
- f"# Started test download of {SizeSuffix(size)} with {transfers} transfers"
103
- )
104
- print("#" * 80)
105
- net_io_start = psutil.net_io_counters()
106
- start = time.time()
107
- bytes_or_err: bytes | Exception = rclone.copy_bytes(
108
- src=src_file,
109
- offset=0,
110
- length=size,
111
- direct_io=True,
112
- transfers=transfers,
113
- )
114
- diff = time.time() - start
115
- net_io_end = psutil.net_io_counters()
116
- if isinstance(bytes_or_err, Exception):
117
- print(bytes_or_err)
118
- self.fail(f"Error: {bytes_or_err}")
119
- assert isinstance(bytes_or_err, bytes)
120
- self.assertEqual(len(bytes_or_err), size)
121
-
122
- # print io stats
123
- bytes_sent = net_io_end.bytes_sent - net_io_start.bytes_sent
124
- bytes_recv = net_io_end.bytes_recv - net_io_start.bytes_recv
125
- packets_sent = net_io_end.packets_sent - net_io_start.packets_sent
126
- efficiency = size / (bytes_recv)
127
- efficiency_100 = efficiency * 100
128
- efficiency_str = f"{efficiency_100:.2f}"
129
-
130
- bytes_send_suffix = SizeSuffix(bytes_sent)
131
- bytes_recv_suffix = SizeSuffix(bytes_recv)
132
- range_size = SizeSuffix(size)
133
-
134
- print(f"\nFinished downloading {range_size} with {transfers} transfers")
135
- print("Net IO stats:")
136
- print(f"Bytes sent: {bytes_send_suffix}")
137
- print(f"Bytes received: {bytes_recv_suffix}")
138
- print(f"Packets sent: {packets_sent}")
139
- print(f"Efficiency: {efficiency_str}%")
140
- print(f"Time: {diff:.1f} seconds")
141
-
142
- print("done")
143
-
144
-
145
- if __name__ == "__main__":
146
- unittest.main()